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. |
11 | 11 |
12 #include "base/base_api.h" | 12 #include "base/base_export.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 #include <windows.h> | 16 #include <windows.h> |
17 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) |
18 #import <CoreFoundation/CoreFoundation.h> | 18 #import <CoreFoundation/CoreFoundation.h> |
19 #endif // OS_* | 19 #endif // OS_* |
20 | 20 |
21 #include "base/string16.h" | 21 #include "base/string16.h" |
22 | 22 |
(...skipping 25 matching lines...) Expand all Loading... |
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. Returns NULL on failure. | 55 // you're done. Returns NULL on failure. |
56 // If |err| is not NULL, it may be filled in with an error message on | 56 // If |err| is not NULL, it may be filled in with an error message on |
57 // error. | 57 // error. |
58 BASE_API NativeLibrary LoadNativeLibrary(const FilePath& library_path, | 58 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, |
59 std::string* error); | 59 std::string* error); |
60 | 60 |
61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
62 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 62 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
63 // you're done. | 63 // you're done. |
64 // This function retrieves the LoadLibrary function exported from kernel32.dll | 64 // This function retrieves the LoadLibrary function exported from kernel32.dll |
65 // 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 |
66 // import table. | 66 // import table. |
67 BASE_API NativeLibrary LoadNativeLibraryDynamically( | 67 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( |
68 const FilePath& library_path); | 68 const FilePath& library_path); |
69 #endif // OS_WIN | 69 #endif // OS_WIN |
70 | 70 |
71 // Unloads a native library. | 71 // Unloads a native library. |
72 BASE_API void UnloadNativeLibrary(NativeLibrary library); | 72 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); |
73 | 73 |
74 // Gets a function pointer from a native library. | 74 // Gets a function pointer from a native library. |
75 BASE_API void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 75 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
76 const char* name); | 76 const char* name); |
77 | 77 |
78 // Returns the full platform specific name for a native library. | 78 // Returns the full platform specific name for a native library. |
79 // For example: | 79 // For example: |
80 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 80 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
81 // "mylib.dylib" on Mac. | 81 // "mylib.dylib" on Mac. |
82 BASE_API string16 GetNativeLibraryName(const string16& name); | 82 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); |
83 | 83 |
84 } // namespace base | 84 } // namespace base |
85 | 85 |
86 #endif // BASE_NATIVE_LIBRARY_H_ | 86 #endif // BASE_NATIVE_LIBRARY_H_ |
OLD | NEW |