summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 22:06:22 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 22:06:22 +0000
commit84479325c4ccdecd2bddc2f257d436b66595aa10 (patch)
treecd91804f50e952a09f84c6bdf7f68bdb3dab4bc4 /base
parente51eeb7307ea00ec6ef593d938a60f356e3a0882 (diff)
downloadchromium_src-84479325c4ccdecd2bddc2f257d436b66595aa10.zip
chromium_src-84479325c4ccdecd2bddc2f257d436b66595aa10.tar.gz
chromium_src-84479325c4ccdecd2bddc2f257d436b66595aa10.tar.bz2
linux: don't always print dlopen errors from LoadNativeLibrary
Instead, return them to the caller and let the caller decide whether the error is worth notifying the user about. BUG=79068 Review URL: http://codereview.chromium.org/6864020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/memory/scoped_native_library.cc2
-rw-r--r--base/native_library.h7
-rw-r--r--base/native_library_linux.cc17
-rw-r--r--base/native_library_mac.mm5
-rw-r--r--base/native_library_win.cc5
5 files changed, 17 insertions, 19 deletions
diff --git a/base/memory/scoped_native_library.cc b/base/memory/scoped_native_library.cc
index c9aef45..c1e6afc 100644
--- a/base/memory/scoped_native_library.cc
+++ b/base/memory/scoped_native_library.cc
@@ -14,7 +14,7 @@ ScopedNativeLibrary::ScopedNativeLibrary(NativeLibrary library)
}
ScopedNativeLibrary::ScopedNativeLibrary(const FilePath& library_path) {
- library_ = base::LoadNativeLibrary(library_path);
+ library_ = base::LoadNativeLibrary(library_path, NULL);
}
ScopedNativeLibrary::~ScopedNativeLibrary() {
diff --git a/base/native_library.h b/base/native_library.h
index 9809c98..2896163 100644
--- a/base/native_library.h
+++ b/base/native_library.h
@@ -52,8 +52,11 @@ typedef void* NativeLibrary;
#endif // OS_*
// Loads a native library from disk. Release it with UnloadNativeLibrary when
-// you're done.
-BASE_API NativeLibrary LoadNativeLibrary(const FilePath& library_path);
+// you're done. Returns NULL on failure.
+// If |err| is not NULL, it may be filled in with an error message on
+// error.
+BASE_API NativeLibrary LoadNativeLibrary(const FilePath& library_path,
+ std::string* error);
#if defined(OS_WIN)
// Loads a native library from disk. Release it with UnloadNativeLibrary when
diff --git a/base/native_library_linux.cc b/base/native_library_linux.cc
index e282bce..bcc4ffb 100644
--- a/base/native_library_linux.cc
+++ b/base/native_library_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -14,7 +14,8 @@
namespace base {
// static
-NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
+NativeLibrary LoadNativeLibrary(const FilePath& library_path,
+ std::string* error) {
// dlopen() opens the file off disk.
base::ThreadRestrictions::AssertIOAllowed();
@@ -23,16 +24,8 @@ NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
// http://crbug.com/17943, http://crbug.com/17557, http://crbug.com/36892,
// and http://crbug.com/40794.
void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY);
- if (!dl) {
- std::string error_message = dlerror();
- // Some obsolete plugins depend on libxul or libxpcom.
- // Ignore the error messages when failing to load these.
- if (error_message.find("libxul.so") == std::string::npos &&
- error_message.find("libxpcom.so") == std::string::npos) {
- LOG(ERROR) << "dlopen failed when trying to open " << library_path.value()
- << ": " << error_message;
- }
- }
+ if (!dl && error)
+ *error = dlerror();
return dl;
}
diff --git a/base/native_library_mac.mm b/base/native_library_mac.mm
index 742d92a..9f7a967 100644
--- a/base/native_library_mac.mm
+++ b/base/native_library_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -16,7 +16,8 @@
namespace base {
// static
-NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
+NativeLibrary LoadNativeLibrary(const FilePath& library_path,
+ std::string* error) {
// dlopen() etc. open the file off disk.
if (library_path.Extension() == "dylib" ||
!file_util::DirectoryExists(library_path)) {
diff --git a/base/native_library_win.cc b/base/native_library_win.cc
index b77fbe1..af00cd1 100644
--- a/base/native_library_win.cc
+++ b/base/native_library_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -39,7 +39,8 @@ NativeLibrary LoadNativeLibraryHelper(const FilePath& library_path,
}
// static
-NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
+NativeLibrary LoadNativeLibrary(const FilePath& library_path,
+ std::string* error) {
return LoadNativeLibraryHelper(library_path, LoadLibraryW);
}