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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 union { | 43 union { |
44 CFBundleRef bundle; | 44 CFBundleRef bundle; |
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. Releases it with UnloadNativeLibrary when |
ddorwin
2014/03/21 04:20:06
"Release" was correct. Maybe "The caller must rele
xhwang
2014/03/21 17:09:18
Done.
| |
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_message| or |error_code| is not NULL, they may be filled in with |
56 // an error message or an error code respectively on load error if the platform | |
ddorwin
2014/03/21 04:20:06
nit:
, respectively,
xhwang
2014/03/21 17:09:18
Done.
| |
57 // supports it. | |
56 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 58 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
57 std::string* error); | 59 std::string* error_message, |
60 uint32* error_code = NULL); | |
58 | 61 |
59 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
60 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 63 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
61 // you're done. | 64 // you're done. |
62 // This function retrieves the LoadLibrary function exported from kernel32.dll | 65 // This function retrieves the LoadLibrary function exported from kernel32.dll |
63 // and calls it instead of directly calling the LoadLibrary function via the | 66 // and calls it instead of directly calling the LoadLibrary function via the |
64 // import table. | 67 // import table. |
65 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( | 68 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( |
66 const FilePath& library_path); | 69 const FilePath& library_path); |
67 #endif // OS_WIN | 70 #endif // OS_WIN |
68 | 71 |
69 // Unloads a native library. | 72 // Unloads a native library. |
70 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); | 73 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); |
71 | 74 |
72 // Gets a function pointer from a native library. | 75 // Gets a function pointer from a native library. |
73 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 76 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
74 const char* name); | 77 const char* name); |
75 | 78 |
76 // Returns the full platform specific name for a native library. | 79 // Returns the full platform specific name for a native library. |
77 // For example: | 80 // For example: |
78 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 81 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
79 // "mylib.dylib" on Mac. | 82 // "mylib.dylib" on Mac. |
80 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); | 83 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); |
81 | 84 |
82 } // namespace base | 85 } // namespace base |
83 | 86 |
84 #endif // BASE_NATIVE_LIBRARY_H_ | 87 #endif // BASE_NATIVE_LIBRARY_H_ |
OLD | NEW |