1 // Copyright 2011 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 #include "base/scoped_native_library.h" 6 7 namespace base { 8 Free(NativeLibrary library)9void NativeLibraryTraits::Free(NativeLibrary library) { 10 UnloadNativeLibrary(library); 11 } 12 13 using BaseClass = ScopedGeneric<NativeLibrary, NativeLibraryTraits>; 14 ScopedNativeLibrary()15ScopedNativeLibrary::ScopedNativeLibrary() : BaseClass(), error_() {} 16 17 ScopedNativeLibrary::~ScopedNativeLibrary() = default; 18 ScopedNativeLibrary(NativeLibrary library)19ScopedNativeLibrary::ScopedNativeLibrary(NativeLibrary library) 20 : BaseClass(library), error_() {} 21 ScopedNativeLibrary(const FilePath & library_path)22ScopedNativeLibrary::ScopedNativeLibrary(const FilePath& library_path) 23 : ScopedNativeLibrary() { 24 reset(LoadNativeLibrary(library_path, &error_)); 25 } 26 ScopedNativeLibrary(ScopedNativeLibrary && scoped_library)27ScopedNativeLibrary::ScopedNativeLibrary(ScopedNativeLibrary&& scoped_library) 28 : BaseClass(scoped_library.release()), error_() {} 29 GetFunctionPointer(const char * function_name) const30void* ScopedNativeLibrary::GetFunctionPointer(const char* function_name) const { 31 if (!is_valid()) 32 return nullptr; 33 return GetFunctionPointerFromNativeLibrary(get(), function_name); 34 } 35 GetError() const36const NativeLibraryLoadError* ScopedNativeLibrary::GetError() const { 37 return &error_; 38 } 39 40 } // namespace base 41