scoped_ioplugininterface.h 984 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 {
  9. namespace mac {
  10. namespace internal {
  11. template <typename T>
  12. struct ScopedIOPluginInterfaceTraits {
  13. static T InvalidValue() { return nullptr; }
  14. static T Retain(T t) {
  15. (*t)->AddRef(t);
  16. return t;
  17. }
  18. static void Release(T t) { (*t)->Release(t); }
  19. };
  20. } // namespace internal
  21. // Just like ScopedCFTypeRef but for IOCFPlugInInterface and friends
  22. // (IOUSBInterfaceStruct and IOUSBDeviceStruct320 in particular).
  23. template <typename T>
  24. using ScopedIOPluginInterface =
  25. ScopedTypeRef<T**, internal::ScopedIOPluginInterfaceTraits<T**>>;
  26. } // namespace mac
  27. } // namespace base
  28. #endif // BASE_MAC_SCOPED_IOPLUGININTERFACE_H_