Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 void* dylib; | 45 void* dylib; |
| 46 }; | 46 }; |
| 47 }; | 47 }; |
| 48 typedef NativeLibraryStruct* NativeLibrary; | 48 typedef NativeLibraryStruct* NativeLibrary; |
| 49 #elif defined(OS_POSIX) | 49 #elif defined(OS_POSIX) |
| 50 typedef void* NativeLibrary; | 50 typedef void* NativeLibrary; |
| 51 #endif // OS_* | 51 #endif // OS_* |
| 52 | 52 |
| 53 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 53 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 54 // you're done. Returns NULL on failure. | 54 // you're done. Returns NULL on failure. |
| 55 // If |error| is not NULL, it may be filled in with an error message on error. | 55 // If |error| is not NULL, it may be filled in with an error message on error. |
|
ddorwin
2014/03/20 22:01:12
Similar comment for error_code. We might specifica
xhwang
2014/03/21 01:42:58
Done.
| |
| 56 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 56 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
| 57 std::string* error); | 57 std::string* error_message, |
| 58 uint32* error_code = NULL); | |
|
xhwang
2014/03/20 21:40:03
This optional parameter is just trying to avoid up
| |
| 58 | 59 |
| 59 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
| 60 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 61 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 61 // you're done. | 62 // you're done. |
| 62 // This function retrieves the LoadLibrary function exported from kernel32.dll | 63 // This function retrieves the LoadLibrary function exported from kernel32.dll |
| 63 // and calls it instead of directly calling the LoadLibrary function via the | 64 // and calls it instead of directly calling the LoadLibrary function via the |
| 64 // import table. | 65 // import table. |
| 65 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( | 66 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( |
| 66 const FilePath& library_path); | 67 const FilePath& library_path); |
| 67 #endif // OS_WIN | 68 #endif // OS_WIN |
| 68 | 69 |
| 69 // Unloads a native library. | 70 // Unloads a native library. |
| 70 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); | 71 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); |
| 71 | 72 |
| 72 // Gets a function pointer from a native library. | 73 // Gets a function pointer from a native library. |
| 73 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 74 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| 74 const char* name); | 75 const char* name); |
| 75 | 76 |
| 76 // Returns the full platform specific name for a native library. | 77 // Returns the full platform specific name for a native library. |
| 77 // For example: | 78 // For example: |
| 78 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 79 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
| 79 // "mylib.dylib" on Mac. | 80 // "mylib.dylib" on Mac. |
| 80 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); | 81 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); |
| 81 | 82 |
| 82 } // namespace base | 83 } // namespace base |
| 83 | 84 |
| 84 #endif // BASE_NATIVE_LIBRARY_H_ | 85 #endif // BASE_NATIVE_LIBRARY_H_ |
| OLD | NEW |