OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_NATIVE_LIBRARY_H_ | 5 #ifndef BASE_NATIVE_LIBRARY_H_ |
6 #define BASE_NATIVE_LIBRARY_H_ | 6 #define BASE_NATIVE_LIBRARY_H_ |
7 | 7 |
8 // This file defines a cross-platform "NativeLibrary" type which represents | 8 // This file defines a cross-platform "NativeLibrary" type which represents |
9 // a loadable module. | 9 // a loadable module. |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 // Returns a string representation of the load error. | 58 // Returns a string representation of the load error. |
59 std::string ToString() const; | 59 std::string ToString() const; |
60 | 60 |
61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
62 DWORD code; | 62 DWORD code; |
63 #else | 63 #else |
64 std::string message; | 64 std::string message; |
65 #endif // OS_WIN | 65 #endif // OS_WIN |
66 }; | 66 }; |
67 | 67 |
68 struct BASE_EXPORT NativeLibraryOptions { | |
69 NativeLibraryOptions() {} | |
Primiano Tucci (use gerrit)
2016/08/25 21:10:53
didn't catchup with C++11 too much. Is the copy ct
Ken Rockot(use gerrit already)
2016/08/25 21:25:01
It's not necessary, but given the confusion I adde
| |
70 | |
71 // If |true|, a loaded library is required to prefer local symbol resolution | |
72 // before considering global symbols. Note that this is already the default | |
73 // behavior on most systems. Setting this to |false| does not guarantee the | |
74 // inverse, i.e., it does not force a preference for global symbols over local | |
75 // ones. | |
76 bool prefer_own_symbols = false; | |
77 }; | |
78 | |
68 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 79 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
69 // you're done. Returns NULL on failure. | 80 // you're done. Returns NULL on failure. |
70 // If |error| is not NULL, it may be filled in on load error. | 81 // If |error| is not NULL, it may be filled in on load error. |
71 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 82 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
72 NativeLibraryLoadError* error); | 83 NativeLibraryLoadError* error); |
73 | 84 |
85 // Loads a native library from disk. Release it with UnloadNativeLibrary when | |
86 // you're done. Returns NULL on failure. | |
87 // If |error| is not NULL, it may be filled in on load error. | |
88 BASE_EXPORT NativeLibrary LoadNativeLibraryWithOptions( | |
89 const FilePath& library_path, | |
90 const NativeLibraryOptions& options, | |
91 NativeLibraryLoadError* error); | |
92 | |
74 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
75 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 94 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
76 // you're done. | 95 // you're done. |
77 // This function retrieves the LoadLibrary function exported from kernel32.dll | 96 // This function retrieves the LoadLibrary function exported from kernel32.dll |
78 // and calls it instead of directly calling the LoadLibrary function via the | 97 // and calls it instead of directly calling the LoadLibrary function via the |
79 // import table. | 98 // import table. |
80 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( | 99 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( |
81 const FilePath& library_path); | 100 const FilePath& library_path); |
82 #endif // OS_WIN | 101 #endif // OS_WIN |
83 | 102 |
84 // Unloads a native library. | 103 // Unloads a native library. |
85 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); | 104 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); |
86 | 105 |
87 // Gets a function pointer from a native library. | 106 // Gets a function pointer from a native library. |
88 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 107 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
89 StringPiece name); | 108 StringPiece name); |
90 | 109 |
91 // Returns the full platform specific name for a native library. | 110 // Returns the full platform specific name for a native library. |
92 // |name| must be ASCII. | 111 // |name| must be ASCII. |
93 // For example: | 112 // For example: |
94 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 113 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
95 // "libmylib.dylib" on Mac. | 114 // "libmylib.dylib" on Mac. |
96 BASE_EXPORT std::string GetNativeLibraryName(StringPiece name); | 115 BASE_EXPORT std::string GetNativeLibraryName(StringPiece name); |
97 | 116 |
98 } // namespace base | 117 } // namespace base |
99 | 118 |
100 #endif // BASE_NATIVE_LIBRARY_H_ | 119 #endif // BASE_NATIVE_LIBRARY_H_ |
OLD | NEW |