com_init_util.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_WIN_COM_INIT_UTIL_H_
  5. #define BASE_WIN_COM_INIT_UTIL_H_
  6. #include "base/base_export.h"
  7. #include "base/check_op.h"
  8. namespace base {
  9. namespace win {
  10. enum class ComApartmentType {
  11. // Uninitialized or has an unrecognized apartment type.
  12. NONE,
  13. // Single-threaded Apartment.
  14. STA,
  15. // Multi-threaded Apartment.
  16. MTA,
  17. };
  18. #if DCHECK_IS_ON()
  19. // DCHECKs if COM is not initialized on this thread as an STA or MTA.
  20. // |message| is optional and is used for the DCHECK if specified.
  21. BASE_EXPORT void AssertComInitialized(const char* message = nullptr);
  22. // DCHECKs if |apartment_type| is not the same as the current thread's apartment
  23. // type.
  24. BASE_EXPORT void AssertComApartmentType(ComApartmentType apartment_type);
  25. #else // DCHECK_IS_ON()
  26. inline void AssertComInitialized() {}
  27. inline void AssertComApartmentType(ComApartmentType apartment_type) {}
  28. #endif // DCHECK_IS_ON()
  29. } // namespace win
  30. } // namespace base
  31. #endif // BASE_WIN_COM_INIT_UTIL_H_