| OLD | NEW |
| 1 // Copyright (c) 2009 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 "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 | 14 |
| 14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 15 #include <windows.h> | 16 #include <windows.h> |
| 16 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) |
| 17 #import <CoreFoundation/CoreFoundation.h> | 18 #import <CoreFoundation/CoreFoundation.h> |
| 18 #endif // OS_* | 19 #endif // OS_* |
| 19 | 20 |
| 20 #include "base/string16.h" | 21 #include "base/string16.h" |
| 21 | 22 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 void* dylib; | 46 void* dylib; |
| 46 }; | 47 }; |
| 47 }; | 48 }; |
| 48 typedef NativeLibraryStruct* NativeLibrary; | 49 typedef NativeLibraryStruct* NativeLibrary; |
| 49 #elif defined(OS_POSIX) | 50 #elif defined(OS_POSIX) |
| 50 typedef void* NativeLibrary; | 51 typedef void* NativeLibrary; |
| 51 #endif // OS_* | 52 #endif // OS_* |
| 52 | 53 |
| 53 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 54 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 54 // you're done. | 55 // you're done. |
| 55 NativeLibrary LoadNativeLibrary(const FilePath& library_path); | 56 BASE_API NativeLibrary LoadNativeLibrary(const FilePath& library_path); |
| 56 | 57 |
| 57 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 58 // Loads a native library from disk. Release it with UnloadNativeLibrary when | 59 // Loads a native library from disk. Release it with UnloadNativeLibrary when |
| 59 // you're done. | 60 // you're done. |
| 60 // This function retrieves the LoadLibrary function exported from kernel32.dll | 61 // This function retrieves the LoadLibrary function exported from kernel32.dll |
| 61 // and calls it instead of directly calling the LoadLibrary function via the | 62 // and calls it instead of directly calling the LoadLibrary function via the |
| 62 // import table. | 63 // import table. |
| 63 NativeLibrary LoadNativeLibraryDynamically(const FilePath& library_path); | 64 BASE_API NativeLibrary LoadNativeLibraryDynamically( |
| 65 const FilePath& library_path); |
| 64 #endif // OS_WIN | 66 #endif // OS_WIN |
| 65 | 67 |
| 66 // Unloads a native library. | 68 // Unloads a native library. |
| 67 void UnloadNativeLibrary(NativeLibrary library); | 69 BASE_API void UnloadNativeLibrary(NativeLibrary library); |
| 68 | 70 |
| 69 // Gets a function pointer from a native library. | 71 // Gets a function pointer from a native library. |
| 70 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 72 BASE_API void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
| 71 const char* name); | 73 const char* name); |
| 72 | 74 |
| 73 // Returns the full platform specific name for a native library. | 75 // Returns the full platform specific name for a native library. |
| 74 // For example: | 76 // For example: |
| 75 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, | 77 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, |
| 76 // "mylib.dylib" on Mac. | 78 // "mylib.dylib" on Mac. |
| 77 string16 GetNativeLibraryName(const string16& name); | 79 BASE_API string16 GetNativeLibraryName(const string16& name); |
| 78 | 80 |
| 79 } // namespace base | 81 } // namespace base |
| 80 | 82 |
| 81 #endif // BASE_NATIVE_LIBRARY_H_ | 83 #endif // BASE_NATIVE_LIBRARY_H_ |
| OLD | NEW |