| 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() = default; |
| 70 NativeLibraryOptions(const NativeLibraryOptions& options) = default; |
| 71 |
| 72 // If |true|, a loaded library is required to prefer local symbol resolution |
| 73 // before considering global symbols. Note that this is already the default |
| 74 // behavior on most systems. Setting this to |false| does not guarantee the |
| 75 // inverse, i.e., it does not force a preference for global symbols over local |
| 76 // ones. |
| 77 bool prefer_own_symbols = false; |
| 78 }; |
| 79 |
| 68 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 80 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 69 // you're done. Returns NULL on failure. | 81 // you're done. Returns NULL on failure. |
| 70 // If |error| is not NULL, it may be filled in on load error. | 82 // If |error| is not NULL, it may be filled in on load error. |
| 71 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 83 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
| 72 NativeLibraryLoadError* error); | 84 NativeLibraryLoadError* error); |
| 73 | 85 |
| 86 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 87 // you're done. Returns NULL on failure. |
| 88 // If |error| is not NULL, it may be filled in on load error. |
| 89 BASE_EXPORT NativeLibrary LoadNativeLibraryWithOptions( |
| 90 const FilePath& library_path, |
| 91 const NativeLibraryOptions& options, |
| 92 NativeLibraryLoadError* error); |
| 93 |
| 74 #if defined(OS_WIN) | 94 #if defined(OS_WIN) |
| 75 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 95 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 76 // you're done. | 96 // you're done. |
| 77 // This function retrieves the LoadLibrary function exported from kernel32.dll | 97 // This function retrieves the LoadLibrary function exported from kernel32.dll |
| 78 // and calls it instead of directly calling the LoadLibrary function via the | 98 // and calls it instead of directly calling the LoadLibrary function via the |
| 79 // import table. | 99 // import table. |
| 80 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( | 100 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( |
| 81 const FilePath& library_path); | 101 const FilePath& library_path); |
| 82 #endif // OS_WIN | 102 #endif // OS_WIN |
| 83 | 103 |
| 84 // Unloads a native library. | 104 // Unloads a native library. |
| 85 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); | 105 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); |
| 86 | 106 |
| 87 // Gets a function pointer from a native library. | 107 // Gets a function pointer from a native library. |
| 88 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 108 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| 89 StringPiece name); | 109 StringPiece name); |
| 90 | 110 |
| 91 // Returns the full platform specific name for a native library. | 111 // Returns the full platform specific name for a native library. |
| 92 // |name| must be ASCII. | 112 // |name| must be ASCII. |
| 93 // For example: | 113 // For example: |
| 94 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 114 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
| 95 // "libmylib.dylib" on Mac. | 115 // "libmylib.dylib" on Mac. |
| 96 BASE_EXPORT std::string GetNativeLibraryName(StringPiece name); | 116 BASE_EXPORT std::string GetNativeLibraryName(StringPiece name); |
| 97 | 117 |
| 98 } // namespace base | 118 } // namespace base |
| 99 | 119 |
| 100 #endif // BASE_NATIVE_LIBRARY_H_ | 120 #endif // BASE_NATIVE_LIBRARY_H_ |
| OLD | NEW |