diff options
-rw-r--r-- | app/win/shell.cc | 2 | ||||
-rw-r--r-- | base/memory/scoped_native_library.cc | 2 | ||||
-rw-r--r-- | base/native_library.h | 7 | ||||
-rw-r--r-- | base/native_library_linux.cc | 17 | ||||
-rw-r--r-- | base/native_library_mac.mm | 5 | ||||
-rw-r--r-- | base/native_library_win.cc | 5 | ||||
-rw-r--r-- | chrome/nacl/nacl_main_platform_delegate_mac.mm | 4 | ||||
-rw-r--r-- | chrome/nacl/nacl_main_platform_delegate_win.cc | 4 | ||||
-rw-r--r-- | content/common/pepper_plugin_registry.cc | 7 | ||||
-rw-r--r-- | content/plugin/plugin_thread.cc | 4 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 2 | ||||
-rw-r--r-- | crypto/nss_util.cc | 2 | ||||
-rw-r--r-- | net/http/http_auth_gssapi_posix.cc | 4 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation_linux.cc | 42 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation_mac.cc | 4 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation_win.cc | 8 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_lib.cc | 17 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_lib_posix.cc | 13 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.cc | 2 |
19 files changed, 78 insertions, 73 deletions
diff --git a/app/win/shell.cc b/app/win/shell.cc index a951315..cf47387 100644 --- a/app/win/shell.cc +++ b/app/win/shell.cc @@ -81,7 +81,7 @@ void SetAppIdForWindow(const string16& app_id, HWND hwnd) { std::wstring shell32_filename(kShell32); FilePath shell32_filepath(shell32_filename); base::NativeLibrary shell32_library = base::LoadNativeLibrary( - shell32_filepath); + shell32_filepath, NULL); if (!shell32_library) return; 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); } diff --git a/chrome/nacl/nacl_main_platform_delegate_mac.mm b/chrome/nacl/nacl_main_platform_delegate_mac.mm index 19e7df7..006ee25 100644 --- a/chrome/nacl/nacl_main_platform_delegate_mac.mm +++ b/chrome/nacl/nacl_main_platform_delegate_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. @@ -47,7 +47,7 @@ void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { FilePath test_dll_name = command_line.GetSwitchValuePath(switches::kTestNaClSandbox); if (!test_dll_name.empty()) { - sandbox_test_module_ = base::LoadNativeLibrary(test_dll_name); + sandbox_test_module_ = base::LoadNativeLibrary(test_dll_name, NULL); CHECK(sandbox_test_module_); } } diff --git a/chrome/nacl/nacl_main_platform_delegate_win.cc b/chrome/nacl/nacl_main_platform_delegate_win.cc index cfe38ff..02feff0 100644 --- a/chrome/nacl/nacl_main_platform_delegate_win.cc +++ b/chrome/nacl/nacl_main_platform_delegate_win.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. @@ -51,7 +51,7 @@ void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { test_dll_name = test_dll_name.ReplaceExtension(L"dll"); #endif DVLOG(1) << "Loading test lib " << test_dll_name.value() << "\n"; - sandbox_test_module_ = base::LoadNativeLibrary(test_dll_name); + sandbox_test_module_ = base::LoadNativeLibrary(test_dll_name, NULL); CHECK(sandbox_test_module_); VLOG(1) << "Testing NaCl sandbox\n"; } diff --git a/content/common/pepper_plugin_registry.cc b/content/common/pepper_plugin_registry.cc index 2da9a0f..b91e701 100644 --- a/content/common/pepper_plugin_registry.cc +++ b/content/common/pepper_plugin_registry.cc @@ -129,9 +129,12 @@ void PepperPluginRegistry::PreloadModules() { ComputeList(&plugins); for (size_t i = 0; i < plugins.size(); ++i) { if (!plugins[i].is_internal) { - base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path); + std::string error; + base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path, + &error); LOG_IF(WARNING, !library) << "Unable to load plugin " - << plugins[i].path.value(); + << plugins[i].path.value() << " " + << error; } } } diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc index 1d14c22..e0ce6d1 100644 --- a/content/plugin/plugin_thread.cc +++ b/content/plugin/plugin_thread.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. @@ -74,7 +74,7 @@ PluginThread::PluginThread() PatchNPNFunctions(); // Preload the library to avoid loading, unloading then reloading - preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); + preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_, NULL); scoped_refptr<webkit::npapi::PluginLib> plugin( webkit::npapi::PluginLib::CreatePluginLib(plugin_path_)); diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index 54215a2..70bf573f 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -71,7 +71,7 @@ std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { } void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { - base::ScopedNativeLibrary library(base::LoadNativeLibrary(path)); + base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, NULL)); if (!library.is_valid()) return; diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index 976a5e3..198a692 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -611,7 +611,7 @@ void LoadNSSLibraries() { for (size_t i = 0; i < libs.size(); ++i) { for (size_t j = 0; j < paths.size(); ++j) { FilePath path = paths[j].Append(libs[i]); - base::NativeLibrary lib = base::LoadNativeLibrary(path); + base::NativeLibrary lib = base::LoadNativeLibrary(path, NULL); if (lib) { ++loaded; break; diff --git a/net/http/http_auth_gssapi_posix.cc b/net/http/http_auth_gssapi_posix.cc index d4581b9..8a39688 100644 --- a/net/http/http_auth_gssapi_posix.cc +++ b/net/http/http_auth_gssapi_posix.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. @@ -452,7 +452,7 @@ base::NativeLibrary GSSAPISharedLibrary::LoadSharedLibrary() { // TODO(asanka): Move library loading to a separate thread. // http://crbug.com/66702 base::ThreadRestrictions::ScopedAllowIO allow_io_temporarily; - base::NativeLibrary lib = base::LoadNativeLibrary(file_path); + base::NativeLibrary lib = base::LoadNativeLibrary(file_path, NULL); if (lib) { // Only return this library if we can bind the functions we need. if (BindMethods(lib)) diff --git a/ui/gfx/gl/gl_implementation_linux.cc b/ui/gfx/gl/gl_implementation_linux.cc index 34069cf..834bb31 100644 --- a/ui/gfx/gl/gl_implementation_linux.cc +++ b/ui/gfx/gl/gl_implementation_linux.cc @@ -27,6 +27,18 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); } +// Load a library, printing an error message on failure. +base::NativeLibrary LoadLibrary(const char* filename) { + std::string error; + base::NativeLibrary library = base::LoadNativeLibrary(FilePath(filename), + &error); + if (!library) { + VLOG(1) << "Failed to load " << filename << ": " << error; + return NULL; + } + return library; +} + } // namespace anonymous bool InitializeGLBindings(GLImplementation implementation) { @@ -44,12 +56,9 @@ bool InitializeGLBindings(GLImplementation implementation) { return false; } - base::NativeLibrary library = base::LoadNativeLibrary( - module_path.Append("libosmesa.so")); - if (!library) { - VLOG(1) << "libosmesa.so not found"; + base::NativeLibrary library = LoadLibrary("libosmesa.so"); + if (!library) return false; - } GLGetProcAddressProc get_proc_address = reinterpret_cast<GLGetProcAddressProc>( @@ -70,12 +79,9 @@ bool InitializeGLBindings(GLImplementation implementation) { break; } case kGLImplementationDesktopGL: { - base::NativeLibrary library = base::LoadNativeLibrary( - FilePath("libGL.so.1")); - if (!library) { - VLOG(1) << "libGL.so.1 not found."; + base::NativeLibrary library = LoadLibrary("libGL.so.1"); + if (!library) return false; - } GLGetProcAddressProc get_proc_address = reinterpret_cast<GLGetProcAddressProc>( @@ -96,20 +102,12 @@ bool InitializeGLBindings(GLImplementation implementation) { break; } case kGLImplementationEGLGLES2: { - base::NativeLibrary gles_library = base::LoadNativeLibrary( - FilePath("libGLESv2.so")); - if (!gles_library) { - VLOG(1) << "libGLESv2.so not found"; + base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so"); + if (!gles_library) return false; - } - - base::NativeLibrary egl_library = base::LoadNativeLibrary( - FilePath("libEGL.so")); - if (!egl_library) { - VLOG(1) << "libEGL.so not found"; - base::UnloadNativeLibrary(gles_library); + base::NativeLibrary egl_library = LoadLibrary("libEGL.so"); + if (!egl_library) return false; - } GLGetProcAddressProc get_proc_address = reinterpret_cast<GLGetProcAddressProc>( diff --git a/ui/gfx/gl/gl_implementation_mac.cc b/ui/gfx/gl/gl_implementation_mac.cc index 00ed6bb..a8b3ddd 100644 --- a/ui/gfx/gl/gl_implementation_mac.cc +++ b/ui/gfx/gl/gl_implementation_mac.cc @@ -33,7 +33,7 @@ bool InitializeGLBindings(GLImplementation implementation) { // When using OSMesa, just use OSMesaGetProcAddress to find entry points. base::NativeLibrary library = base::LoadNativeLibrary( - module_path.Append("osmesa.so")); + module_path.Append("osmesa.so"), NULL); if (!library) { VLOG(1) << "osmesa.so not found"; return false; @@ -59,7 +59,7 @@ bool InitializeGLBindings(GLImplementation implementation) { } case kGLImplementationDesktopGL: { base::NativeLibrary library = base::LoadNativeLibrary( - FilePath(kOpenGLFrameworkPath)); + FilePath(kOpenGLFrameworkPath), NULL); if (!library) { LOG(ERROR) << "OpenGL framework not found"; return false; diff --git a/ui/gfx/gl/gl_implementation_win.cc b/ui/gfx/gl/gl_implementation_win.cc index ee07cfc..9061bb3 100644 --- a/ui/gfx/gl/gl_implementation_win.cc +++ b/ui/gfx/gl/gl_implementation_win.cc @@ -43,7 +43,7 @@ bool InitializeGLBindings(GLImplementation implementation) { } base::NativeLibrary library = base::LoadNativeLibrary( - module_path.Append(L"osmesa.dll")); + module_path.Append(L"osmesa.dll"), NULL); if (!library) { VLOG(1) << "osmesa.dll not found"; return false; @@ -76,7 +76,7 @@ bool InitializeGLBindings(GLImplementation implementation) { // the former and if there is another version of libglesv2.dll in the dll // search path, it will get loaded. base::NativeLibrary gles_library = base::LoadNativeLibrary( - module_path.Append(L"libglesv2.dll")); + module_path.Append(L"libglesv2.dll"), NULL); if (!gles_library) { VLOG(1) << "libglesv2.dll not found"; return false; @@ -85,7 +85,7 @@ bool InitializeGLBindings(GLImplementation implementation) { // When using EGL, first try eglGetProcAddress and then Windows // GetProcAddress on both the EGL and GLES2 DLLs. base::NativeLibrary egl_library = base::LoadNativeLibrary( - module_path.Append(L"libegl.dll")); + module_path.Append(L"libegl.dll"), NULL); if (!egl_library) { VLOG(1) << "libegl.dll not found."; base::UnloadNativeLibrary(gles_library); @@ -121,7 +121,7 @@ bool InitializeGLBindings(GLImplementation implementation) { // When using Windows OpenGL, first try wglGetProcAddress and then // Windows GetProcAddress. base::NativeLibrary library = base::LoadNativeLibrary( - FilePath(L"opengl32.dll")); + FilePath(L"opengl32.dll"), NULL); if (!library) { VLOG(1) << "opengl32.dll not found"; return false; diff --git a/webkit/plugins/npapi/plugin_lib.cc b/webkit/plugins/npapi/plugin_lib.cc index f0793c5..2db2a52 100644 --- a/webkit/plugins/npapi/plugin_lib.cc +++ b/webkit/plugins/npapi/plugin_lib.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. @@ -180,6 +180,7 @@ bool PluginLib::Load() { bool rv = false; base::NativeLibrary library = 0; + std::string error; if (!internal_) { #if defined(OS_WIN) @@ -193,14 +194,16 @@ bool PluginLib::Load() { std::wstring::npos) { library = base::LoadNativeLibraryDynamically(web_plugin_info_.path); } else { - library = base::LoadNativeLibrary(web_plugin_info_.path); + library = base::LoadNativeLibrary(web_plugin_info_.path, &error); } -#else // OS_WIN - library = base::LoadNativeLibrary(web_plugin_info_.path); -#endif // OS_WIN - if (library == 0) { +#else + library = base::LoadNativeLibrary(web_plugin_info_.path, &error); +#endif + + if (!library) { LOG_IF(ERROR, PluginList::DebugPluginLoading()) - << "Couldn't load plugin " << web_plugin_info_.path.value(); + << "Couldn't load plugin " << web_plugin_info_.path.value() << " " + << error; return rv; } diff --git a/webkit/plugins/npapi/plugin_lib_posix.cc b/webkit/plugins/npapi/plugin_lib_posix.cc index debd457..641b6cd 100644 --- a/webkit/plugins/npapi/plugin_lib_posix.cc +++ b/webkit/plugins/npapi/plugin_lib_posix.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. @@ -116,13 +116,15 @@ void UnwrapNSPluginWrapper(void **dl, FilePath* unwrapped_path) { return; } - void* newdl = base::LoadNativeLibrary(path); + std::string error; + void* newdl = base::LoadNativeLibrary(path, &error); if (!newdl) { // We couldn't load the unwrapped plugin for some reason, despite // being able to load the wrapped one. Just use the wrapped one. LOG_IF(ERROR, PluginList::DebugPluginLoading()) << "Could not use unwrapped nspluginwrapper plugin " - << unwrapped_path->value() << ", using the wrapped one."; + << unwrapped_path->value() << " (" << error << "), " + << "using the wrapped one."; return; } @@ -150,11 +152,12 @@ bool PluginLib::ReadWebPluginInfo(const FilePath& filename, return false; } - void* dl = base::LoadNativeLibrary(filename); + std::string error; + void* dl = base::LoadNativeLibrary(filename, &error); if (!dl) { LOG_IF(ERROR, PluginList::DebugPluginLoading()) << "While reading plugin info, unable to load library " - << filename.value() << ", skipping."; + << filename.value() << " (" << error << "), skipping."; return false; } diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 5ad10db..7e8dc4a 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -431,7 +431,7 @@ bool PluginModule::InitAsInternalPlugin(const EntryPoints& entry_points) { } bool PluginModule::InitAsLibrary(const FilePath& path) { - base::NativeLibrary library = base::LoadNativeLibrary(path); + base::NativeLibrary library = base::LoadNativeLibrary(path, NULL); if (!library) return false; |