1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_MAC_SCOPED_IOPLUGININTERFACE_H_ 6 #define BASE_MAC_SCOPED_IOPLUGININTERFACE_H_ 7 8 #include <IOKit/IOKitLib.h> 9 10 #include "base/apple/scoped_typeref.h" 11 12 namespace base::mac { 13 14 namespace internal { 15 16 template <typename T> 17 struct ScopedIOPluginInterfaceTraits { InvalidValueScopedIOPluginInterfaceTraits18 static T InvalidValue() { return nullptr; } RetainScopedIOPluginInterfaceTraits19 static T Retain(T t) { 20 (*t)->AddRef(t); 21 return t; 22 } ReleaseScopedIOPluginInterfaceTraits23 static void Release(T t) { (*t)->Release(t); } 24 }; 25 26 } // namespace internal 27 28 // Just like ScopedCFTypeRef but for IOCFPlugInInterface and friends 29 // (IOUSBInterfaceStruct and IOUSBDeviceStruct320 in particular). 30 template <typename T> 31 using ScopedIOPluginInterface = 32 apple::ScopedTypeRef<T**, internal::ScopedIOPluginInterfaceTraits<T**>>; 33 34 } // namespace base::mac 35 36 #endif // BASE_MAC_SCOPED_IOPLUGININTERFACE_H_ 37