| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // This file defines a cross-platform "NativeLibrary" type which represents | 9 // This file defines a cross-platform "NativeLibrary" type which represents |
| 10 // a loadable module. | 10 // a loadable module. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 CFBundleRef bundle; | 45 CFBundleRef bundle; |
| 46 void* dylib; | 46 void* dylib; |
| 47 }; | 47 }; |
| 48 }; | 48 }; |
| 49 typedef NativeLibraryStruct* NativeLibrary; | 49 typedef NativeLibraryStruct* NativeLibrary; |
| 50 #elif defined(OS_POSIX) | 50 #elif defined(OS_POSIX) |
| 51 typedef void* NativeLibrary; | 51 typedef void* NativeLibrary; |
| 52 #endif // OS_* | 52 #endif // OS_* |
| 53 | 53 |
| 54 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 54 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 55 // you're done. | 55 // you're done. Returns NULL on failure. |
| 56 BASE_API NativeLibrary LoadNativeLibrary(const FilePath& library_path); | 56 // If |err| is not NULL, it may be filled in with an error message on |
| 57 // error. |
| 58 BASE_API NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
| 59 std::string* error); |
| 57 | 60 |
| 58 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 59 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 62 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 60 // you're done. | 63 // you're done. |
| 61 // This function retrieves the LoadLibrary function exported from kernel32.dll | 64 // This function retrieves the LoadLibrary function exported from kernel32.dll |
| 62 // and calls it instead of directly calling the LoadLibrary function via the | 65 // and calls it instead of directly calling the LoadLibrary function via the |
| 63 // import table. | 66 // import table. |
| 64 BASE_API NativeLibrary LoadNativeLibraryDynamically( | 67 BASE_API NativeLibrary LoadNativeLibraryDynamically( |
| 65 const FilePath& library_path); | 68 const FilePath& library_path); |
| 66 #endif // OS_WIN | 69 #endif // OS_WIN |
| 67 | 70 |
| 68 // Unloads a native library. | 71 // Unloads a native library. |
| 69 BASE_API void UnloadNativeLibrary(NativeLibrary library); | 72 BASE_API void UnloadNativeLibrary(NativeLibrary library); |
| 70 | 73 |
| 71 // Gets a function pointer from a native library. | 74 // Gets a function pointer from a native library. |
| 72 BASE_API void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 75 BASE_API void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| 73 const char* name); | 76 const char* name); |
| 74 | 77 |
| 75 // Returns the full platform specific name for a native library. | 78 // Returns the full platform specific name for a native library. |
| 76 // For example: | 79 // For example: |
| 77 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 80 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
| 78 // "mylib.dylib" on Mac. | 81 // "mylib.dylib" on Mac. |
| 79 BASE_API string16 GetNativeLibraryName(const string16& name); | 82 BASE_API string16 GetNativeLibraryName(const string16& name); |
| 80 | 83 |
| 81 } // namespace base | 84 } // namespace base |
| 82 | 85 |
| 83 #endif // BASE_NATIVE_LIBRARY_H_ | 86 #endif // BASE_NATIVE_LIBRARY_H_ |
| OLD | NEW |