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

Unified Diff: base/native_library_linux.cc

Issue 155558: linux: add flash workarounds (Closed)
Patch Set: Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: base/native_library_linux.cc
diff --git a/base/native_library_linux.cc b/base/native_library_linux.cc
index d14941332f0fab69a5b305af9ff03b154e58a1d7..b8e51733c6c83252315bf854b75072930430e3b4 100644
--- a/base/native_library_linux.cc
+++ b/base/native_library_linux.cc
@@ -5,16 +5,37 @@
#include "base/native_library.h"
#include <dlfcn.h>
+#include <set>
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/singleton.h"
#include "base/string_util.h"
namespace base {
+typedef std::set<FilePath> FilePathSet;
+struct ShallowBindPathDifferentiatingType { };
+typedef Singleton<FilePathSet,
+ DefaultSingletonTraits<FilePathSet>,
+ ShallowBindPathDifferentiatingType> ShallowBindPathSingleton;
+
+void AddShallowBindPath(const FilePath& library_path) {
+ FilePathSet *file_path_set = ShallowBindPathSingleton::get();
+ file_path_set->insert(library_path);
+}
+
+bool IsShallowBindPath(const FilePath& library_path) {
+ FilePathSet *file_path_set = ShallowBindPathSingleton::get();
+ return file_path_set->find(library_path) != file_path_set->end();
+}
+
// static
NativeLibrary LoadNativeLibrary(const FilePath& library_path) {
- void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY|RTLD_DEEPBIND);
+ int flags = RTLD_LAZY;
+ if (!IsShallowBindPath(library_path))
+ flags |= RTLD_DEEPBIND;
+ void* dl = dlopen(library_path.value().c_str(), flags);
if (!dl) {
LOG(ERROR) << "dlopen failed when trying to open " << library_path.value()
<< ": " << dlerror();

Powered by Google App Engine
This is Rietveld 408576698