Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: base/native_library.h

Issue 206713004: Report PPAPI plugin load error code to UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/native_library_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <iosfwd>
12
11 #include "base/base_export.h" 13 #include "base/base_export.h"
12 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
13 #include "build/build_config.h" 15 #include "build/build_config.h"
14 16
15 #if defined(OS_WIN) 17 #if defined(OS_WIN)
16 #include <windows.h> 18 #include <windows.h>
17 #elif defined(OS_MACOSX) 19 #elif defined(OS_MACOSX)
18 #import <CoreFoundation/CoreFoundation.h> 20 #import <CoreFoundation/CoreFoundation.h>
19 #endif // OS_* 21 #endif // OS_*
20 22
(...skipping 22 matching lines...) Expand all
43 union { 45 union {
44 CFBundleRef bundle; 46 CFBundleRef bundle;
45 void* dylib; 47 void* dylib;
46 }; 48 };
47 }; 49 };
48 typedef NativeLibraryStruct* NativeLibrary; 50 typedef NativeLibraryStruct* NativeLibrary;
49 #elif defined(OS_POSIX) 51 #elif defined(OS_POSIX)
50 typedef void* NativeLibrary; 52 typedef void* NativeLibrary;
51 #endif // OS_* 53 #endif // OS_*
52 54
55 struct NativeLibraryLoadError {
56 #if defined(OS_WIN)
57 NativeLibraryLoadError() : code(0) {}
58 DWORD code;
59 #else
60 std::string message;
61 #endif // OS_WIN
62 };
63
53 // Loads a native library from disk. Release it with UnloadNativeLibrary when 64 // Loads a native library from disk. Release it with UnloadNativeLibrary when
54 // you're done. Returns NULL on failure. 65 // you're done. Returns NULL on failure.
55 // If |error| is not NULL, it may be filled in with an error message on error. 66 // If |error| is not NULL, it may be filled in on load error.
56 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path, 67 BASE_EXPORT NativeLibrary LoadNativeLibrary(const FilePath& library_path,
57 std::string* error); 68 NativeLibraryLoadError* error);
58 69
59 #if defined(OS_WIN) 70 #if defined(OS_WIN)
60 // Loads a native library from disk. Release it with UnloadNativeLibrary when 71 // Loads a native library from disk. Release it with UnloadNativeLibrary when
61 // you're done. 72 // you're done.
62 // This function retrieves the LoadLibrary function exported from kernel32.dll 73 // This function retrieves the LoadLibrary function exported from kernel32.dll
63 // and calls it instead of directly calling the LoadLibrary function via the 74 // and calls it instead of directly calling the LoadLibrary function via the
64 // import table. 75 // import table.
65 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically( 76 BASE_EXPORT NativeLibrary LoadNativeLibraryDynamically(
66 const FilePath& library_path); 77 const FilePath& library_path);
67 #endif // OS_WIN 78 #endif // OS_WIN
68 79
69 // Unloads a native library. 80 // Unloads a native library.
70 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library); 81 BASE_EXPORT void UnloadNativeLibrary(NativeLibrary library);
71 82
72 // Gets a function pointer from a native library. 83 // Gets a function pointer from a native library.
73 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, 84 BASE_EXPORT void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
74 const char* name); 85 const char* name);
75 86
76 // Returns the full platform specific name for a native library. 87 // Returns the full platform specific name for a native library.
77 // For example: 88 // For example:
78 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux, 89 // "mylib" returns "mylib.dll" on Windows, "libmylib.so" on Linux,
79 // "mylib.dylib" on Mac. 90 // "mylib.dylib" on Mac.
80 BASE_EXPORT string16 GetNativeLibraryName(const string16& name); 91 BASE_EXPORT string16 GetNativeLibraryName(const string16& name);
81 92
93 // Stream operator so NativeLibraryLoadError can be used in log statements.
94 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
brettw 2014/03/24 17:21:25 The style guide permits operator<< for logging but
xhwang 2014/03/24 17:53:21 Done.
95 const NativeLibraryLoadError& error);
96
82 } // namespace base 97 } // namespace base
83 98
84 #endif // BASE_NATIVE_LIBRARY_H_ 99 #endif // BASE_NATIVE_LIBRARY_H_
OLDNEW
« no previous file with comments | « no previous file | base/native_library_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698