blob: 6146a8ca5e4c7fe090c206d3d095f9278ec5cdf3 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2011 The Chromium Authors
[email protected]709a847e2010-11-10 01:16:112// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]e0785902011-05-19 23:34:175#include "base/scoped_native_library.h"
[email protected]709a847e2010-11-10 01:16:116
7namespace base {
8
Cliff Smolinskyf395bef2019-04-12 23:45:449void NativeLibraryTraits::Free(NativeLibrary library) {
10 UnloadNativeLibrary(library);
11}
12
13using BaseClass = ScopedGeneric<NativeLibrary, NativeLibraryTraits>;
14
Peter Kasting811504a72025-01-09 03:18:5015ScopedNativeLibrary::ScopedNativeLibrary() = default;
Cliff Smolinskyf395bef2019-04-12 23:45:4416
17ScopedNativeLibrary::~ScopedNativeLibrary() = default;
[email protected]709a847e2010-11-10 01:16:1118
19ScopedNativeLibrary::ScopedNativeLibrary(NativeLibrary library)
Peter Kasting811504a72025-01-09 03:18:5020 : BaseClass(library) {}
Cliff Smolinskyf395bef2019-04-12 23:45:4421
22ScopedNativeLibrary::ScopedNativeLibrary(const FilePath& library_path)
23 : ScopedNativeLibrary() {
24 reset(LoadNativeLibrary(library_path, &error_));
[email protected]709a847e2010-11-10 01:16:1125}
26
Cliff Smolinskyf395bef2019-04-12 23:45:4427ScopedNativeLibrary::ScopedNativeLibrary(ScopedNativeLibrary&& scoped_library)
Peter Kasting811504a72025-01-09 03:18:5028 : BaseClass(scoped_library.release()) {}
[email protected]709a847e2010-11-10 01:16:1129
Cliff Smolinskyf395bef2019-04-12 23:45:4430void* ScopedNativeLibrary::GetFunctionPointer(const char* function_name) const {
Peter Kasting134ef9af2024-12-28 02:30:0931 if (!is_valid()) {
Ivan Kotenkova16212a52017-11-08 12:37:3332 return nullptr;
Peter Kasting134ef9af2024-12-28 02:30:0933 }
Cliff Smolinskyf395bef2019-04-12 23:45:4434 return GetFunctionPointerFromNativeLibrary(get(), function_name);
[email protected]709a847e2010-11-10 01:16:1135}
36
Cliff Smolinskyf395bef2019-04-12 23:45:4437const NativeLibraryLoadError* ScopedNativeLibrary::GetError() const {
38 return &error_;
[email protected]709a847e2010-11-10 01:16:1139}
40
41} // namespace base