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