summaryrefslogtreecommitdiff
path: root/chromium/base/native_library.h
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
commit679147eead574d186ebf3069647b4c23e8ccace6 (patch)
treefc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/base/native_library.h
downloadqtwebengine-chromium-679147eead574d186ebf3069647b4c23e8ccace6.tar.gz
Initial import.
Diffstat (limited to 'chromium/base/native_library.h')
-rw-r--r--chromium/base/native_library.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/chromium/base/native_library.h b/chromium/base/native_library.h
new file mode 100644
index 00000000000..891f35bd540
--- /dev/null
+++ b/chromium/base/native_library.h
@@ -0,0 +1,91 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_NATIVE_LIBRARY_H_
+#define BASE_NATIVE_LIBRARY_H_
+
+// This file defines a cross-platform "NativeLibrary" type which represents
+// a loadable module.
+
+#include "base/base_export.h"
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#elif defined(OS_MACOSX)
+#import <CoreFoundation/CoreFoundation.h>
+#endif // OS_*
+
+#include "base/strings/string16.h"
+
+// Macro useful for writing cross-platform function pointers.
+#if defined(OS_WIN) && !defined(CDECL)
+#define CDECL __cdecl
+#else
+#define CDECL
+#endif
+
+namespace base {
+
+class FilePath;
+
+#if defined(OS_WIN)
+typedef HMODULE NativeLibrary;
+#elif defined(OS_MACOSX)
+enum NativeLibraryType {
+ BUNDLE,
+ DYNAMIC_LIB
+};
+enum NativeLibraryObjCStatus {
+ OBJC_UNKNOWN,
+ OBJC_PRESENT,
+ OBJC_NOT_PRESENT,
+};
+struct NativeLibraryStruct {
+ NativeLibraryType type;
+ CFBundleRefNum bundle_resource_ref;
+ NativeLibraryObjCStatus objc_status;
+ union {
+ CFBundleRef bundle;
+ void* dylib;
+ };
+};
+typedef NativeLibraryStruct* NativeLibrary;
+#elif defined(OS_POSIX)
+typedef void* NativeLibrary;
+#endif // OS_*
+
+// Loads a native library from disk. Release it with UnloadNativeLibrary when
+// you're done. Returns NULL on failure.
+// If |err| is not NULL, it may be filled in with an error message on
+// error.
+BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path,
+ std::string* error);
+
+#if defined(OS_WIN)
+// Loads a native library from disk. Release it with UnloadNativeLibrary when
+// you're done.
+// This function retrieves the LoadLibrary function exported from kernel32.dll
+// and calls it instead of directly calling the LoadLibrary function via the
+// import table.
+BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically(
+ const FilePath& library_path);
+#endif // OS_WIN
+
+// Unloads a native library.
+BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library);
+
+// Gets a function pointer from a native library.
+BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
+ const char* name);
+
+// Returns the full platform specific name for a native library.
+// For example:
+// "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux,
+// "mylib.dylib" on Mac.
+BASE_EXPORT string16 GetNativeLibraryName(const string16& name);
+
+} // namespace base
+
+#endif // BASE_NATIVE_LIBRARY_H_