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

Side by Side Diff: base/native_library_linux.cc

Issue 173550: linux: scan more plugin directories, fix bugs (Closed)
Patch Set: fixes Created 11 years, 3 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
« no previous file with comments | « no previous file | webkit/glue/plugins/plugin_list_linux.cc » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "base/native_library.h" 5 #include "base/native_library.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 // static 15 // static
16 NativeLibrary LoadNativeLibrary(const FilePath& library_path) { 16 NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
17 void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY); 17 void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY);
18 if (!dl) { 18 if (!dl) {
19 LOG(ERROR) << "dlopen failed when trying to open " << library_path.value() 19 std::string error_message = dlerror();
20 << ": " << dlerror(); 20 // Some obsolete plugins depend on libxul or libxpcom.
21 // Ignore the error messages when failing to load these.
22 if (error_message.find("libxul.so") == std::string::npos &&
23 error_message.find("libxpcom.so") == std::string::npos) {
24 LOG(ERROR) << "dlopen failed when trying to open " << library_path.value()
25 << ": " << error_message;
26 }
21 } 27 }
22 28
23 return dl; 29 return dl;
24 } 30 }
25 31
26 // static 32 // static
27 void UnloadNativeLibrary(NativeLibrary library) { 33 void UnloadNativeLibrary(NativeLibrary library) {
28 int ret = dlclose(library); 34 int ret = dlclose(library);
29 if (ret < 0) { 35 if (ret < 0) {
30 LOG(ERROR) << "dlclose failed: " << dlerror(); 36 LOG(ERROR) << "dlclose failed: " << dlerror();
31 NOTREACHED(); 37 NOTREACHED();
32 } 38 }
33 } 39 }
34 40
35 // static 41 // static
36 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, 42 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library,
37 const char* name) { 43 const char* name) {
38 return dlsym(library, name); 44 return dlsym(library, name);
39 } 45 }
40 46
41 // static 47 // static
42 string16 GetNativeLibraryName(const string16& name) { 48 string16 GetNativeLibraryName(const string16& name) {
43 return ASCIIToUTF16("lib") + name + ASCIIToUTF16(".so"); 49 return ASCIIToUTF16("lib") + name + ASCIIToUTF16(".so");
44 } 50 }
45 51
46 } // namespace base 52 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/plugins/plugin_list_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698