scoped_ioplugininterface.h 958 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2012 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_MAC_SCOPED_IOPLUGININTERFACE_H_
  5. #define BASE_MAC_SCOPED_IOPLUGININTERFACE_H_
  6. #include <IOKit/IOKitLib.h>
  7. #include "base/mac/scoped_typeref.h"
  8. namespace base::mac {
  9. namespace internal {
  10. template <typename T>
  11. struct ScopedIOPluginInterfaceTraits {
  12. static T InvalidValue() { return nullptr; }
  13. static T Retain(T t) {
  14. (*t)->AddRef(t);
  15. return t;
  16. }
  17. static void Release(T t) { (*t)->Release(t); }
  18. };
  19. } // namespace internal
  20. // Just like ScopedCFTypeRef but for IOCFPlugInInterface and friends
  21. // (IOUSBInterfaceStruct and IOUSBDeviceStruct320 in particular).
  22. template <typename T>
  23. using ScopedIOPluginInterface =
  24. ScopedTypeRef<T**, internal::ScopedIOPluginInterfaceTraits<T**>>;
  25. } // namespace base::mac
  26. #endif // BASE_MAC_SCOPED_IOPLUGININTERFACE_H_