Upload upstream chromium 69.0.3497
[platform/framework/web/chromium-efl.git] / base / scoped_native_library.cc
1 // Copyright (c) 2011 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 #include "base/scoped_native_library.h"
6
7 namespace base {
8
9 ScopedNativeLibrary::ScopedNativeLibrary() : library_(nullptr) {}
10
11 ScopedNativeLibrary::ScopedNativeLibrary(NativeLibrary library)
12     : library_(library) {
13 }
14
15 ScopedNativeLibrary::ScopedNativeLibrary(const FilePath& library_path) {
16   library_ = base::LoadNativeLibrary(library_path, nullptr);
17 }
18
19 ScopedNativeLibrary::~ScopedNativeLibrary() {
20   if (library_)
21     base::UnloadNativeLibrary(library_);
22 }
23
24 void* ScopedNativeLibrary::GetFunctionPointer(
25     const char* function_name) const {
26   if (!library_)
27     return nullptr;
28   return base::GetFunctionPointerFromNativeLibrary(library_, function_name);
29 }
30
31 void ScopedNativeLibrary::Reset(NativeLibrary library) {
32   if (library_)
33     base::UnloadNativeLibrary(library_);
34   library_ = library;
35 }
36
37 NativeLibrary ScopedNativeLibrary::Release() {
38   NativeLibrary result = library_;
39   library_ = nullptr;
40   return result;
41 }
42
43 }  // namespace base