[Chromoting] Break up JS event handler registration into related groups.
[chromium-blink-merge.git] / base / native_library.h
blob9353b1ff95ac0bd65bab111307c20211aae5bd8f
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
3 // found in the LICENSE file.
5 #ifndef BASE_NATIVE_LIBRARY_H_
6 #define BASE_NATIVE_LIBRARY_H_
8 // This file defines a cross-platform "NativeLibrary" type which represents
9 // a loadable module.
11 #include "base/base_export.h"
12 #include "base/compiler_specific.h"
13 #include "build/build_config.h"
15 #if defined(OS_WIN)
16 #include <windows.h>
17 #elif defined(OS_MACOSX)
18 #import <CoreFoundation/CoreFoundation.h>
19 #endif // OS_*
21 #include "base/strings/string16.h"
23 namespace base {
25 class FilePath;
27 #if defined(OS_WIN)
28 typedef HMODULE NativeLibrary;
29 #elif defined(OS_MACOSX)
30 enum NativeLibraryType {
31 BUNDLE,
32 DYNAMIC_LIB
34 enum NativeLibraryObjCStatus {
35 OBJC_UNKNOWN,
36 OBJC_PRESENT,
37 OBJC_NOT_PRESENT,
39 struct NativeLibraryStruct {
40 NativeLibraryType type;
41 CFBundleRefNum bundle_resource_ref;
42 NativeLibraryObjCStatus objc_status;
43 union {
44 CFBundleRef bundle;
45 void* dylib;
48 typedef NativeLibraryStruct* NativeLibrary;
49 #elif defined(OS_POSIX)
50 typedef void* NativeLibrary;
51 #endif // OS_*
53 // Loads a native library from disk. Release it with UnloadNativeLibrary when
54 // you're done. Returns NULL on failure.
55 // If |err| is not NULL, it may be filled in with an error message on
56 // error.
57 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path,
58 std::string* error);
60 #if defined(OS_WIN)
61 // Loads a native library from disk. Release it with UnloadNativeLibrary when
62 // you're done.
63 // This function retrieves the LoadLibrary function exported from kernel32.dll
64 // and calls it instead of directly calling the LoadLibrary function via the
65 // import table.
66 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically(
67 const FilePath& library_path);
68 #endif // OS_WIN
70 // Unloads a native library.
71 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library);
73 // Gets a function pointer from a native library.
74 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
75 const char* name);
77 // Returns the full platform specific name for a native library.
78 // For example:
79 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux,
80 // "mylib.dylib" on Mac.
81 BASE_EXPORT string16 GetNativeLibraryName(const string16& name);
83 } // namespace base
85 #endif // BASE_NATIVE_LIBRARY_H_