From 1b3b2cd40272771e2d02d0b18194d2f612fd208a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 8 Apr 2015 19:15:48 +0800 Subject: [PATCH] linux: Don't dynamically load libgio It conflicts with statically linked libgio. --- atom/browser/atom_browser_main_parts_linux.cc | 29 +-- chromium_src/library_loaders/libgio.h | 48 ----- chromium_src/library_loaders/libgio_loader.cc | 174 ------------------ filenames.gypi | 2 - 4 files changed, 10 insertions(+), 243 deletions(-) delete mode 100644 chromium_src/library_loaders/libgio.h delete mode 100644 chromium_src/library_loaders/libgio_loader.cc diff --git a/atom/browser/atom_browser_main_parts_linux.cc b/atom/browser/atom_browser_main_parts_linux.cc index e205d98307b1..278e49ac1f1e 100644 --- a/atom/browser/atom_browser_main_parts_linux.cc +++ b/atom/browser/atom_browser_main_parts_linux.cc @@ -4,9 +4,10 @@ #include "atom/browser/atom_browser_main_parts.h" +#include + #include "base/command_line.h" #include "base/strings/string_number_conversions.h" -#include "library_loaders/libgio.h" #include "ui/gfx/switches.h" namespace atom { @@ -16,8 +17,8 @@ namespace { const char* kInterfaceSchema = "org.gnome.desktop.interface"; const char* kScaleFactor = "scaling-factor"; -bool SchemaExists(const LibGioLoader& libgio_loader, const char* schema_name) { - const gchar* const* schemas = libgio_loader.g_settings_list_schemas(); +bool SchemaExists(const char* schema_name) { + const gchar* const* schemas = g_settings_list_schemas(); while (*schemas) { if (strcmp(schema_name, static_cast(*schemas)) == 0) return true; @@ -26,9 +27,8 @@ bool SchemaExists(const LibGioLoader& libgio_loader, const char* schema_name) { return false; } -bool KeyExists(const LibGioLoader& libgio_loader, GSettings* client, - const char* key) { - gchar** keys = libgio_loader.g_settings_list_keys(client); +bool KeyExists(GSettings* client, const char* key) { + gchar** keys = g_settings_list_keys(client); if (!keys) return false; @@ -45,24 +45,15 @@ bool KeyExists(const LibGioLoader& libgio_loader, GSettings* client, } void GetDPIFromGSettings(guint* scale_factor) { - LibGioLoader libgio_loader; - - // Try also without .0 at the end; on some systems this may be required. - if (!libgio_loader.Load("libgio-2.0.so.0") && - !libgio_loader.Load("libgio-2.0.so")) { - VLOG(1) << "Cannot load gio library. Will fall back to gconf."; - return; - } - GSettings* client = nullptr; - if (!SchemaExists(libgio_loader, kInterfaceSchema) || - !(client = libgio_loader.g_settings_new(kInterfaceSchema))) { + if (!SchemaExists(kInterfaceSchema) || + !(client = g_settings_new(kInterfaceSchema))) { VLOG(1) << "Cannot create gsettings client."; return; } - if (KeyExists(libgio_loader, client, kScaleFactor)) - *scale_factor = libgio_loader.g_settings_get_uint(client, kScaleFactor); + if (KeyExists(client, kScaleFactor)) + *scale_factor = g_settings_get_uint(client, kScaleFactor); g_object_unref(client); } diff --git a/chromium_src/library_loaders/libgio.h b/chromium_src/library_loaders/libgio.h deleted file mode 100644 index 0e9708c406a3..000000000000 --- a/chromium_src/library_loaders/libgio.h +++ /dev/null @@ -1,48 +0,0 @@ -// This is generated file. Do not modify directly. -// Path to the code generator: tools/generate_library_loader/generate_library_loader.py . - -#ifndef LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H -#define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H - -#include -#define LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN - - -#include - -class LibGioLoader { - public: - LibGioLoader(); - ~LibGioLoader(); - - bool Load(const std::string& library_name) - __attribute__((warn_unused_result)); - - bool loaded() const { return loaded_; } - - typeof(&::g_settings_new) g_settings_new; - typeof(&::g_settings_get_child) g_settings_get_child; - typeof(&::g_settings_get_string) g_settings_get_string; - typeof(&::g_settings_get_boolean) g_settings_get_boolean; - typeof(&::g_settings_get_uint) g_settings_get_uint; - typeof(&::g_settings_get_strv) g_settings_get_strv; - typeof(&::g_settings_is_writable) g_settings_is_writable; - typeof(&::g_settings_list_schemas) g_settings_list_schemas; - typeof(&::g_settings_list_keys) g_settings_list_keys; - - - private: - void CleanUp(bool unload); - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - void* library_; -#endif - - bool loaded_; - - // Disallow copy constructor and assignment operator. - LibGioLoader(const LibGioLoader&); - void operator=(const LibGioLoader&); -}; - -#endif // LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H diff --git a/chromium_src/library_loaders/libgio_loader.cc b/chromium_src/library_loaders/libgio_loader.cc deleted file mode 100644 index 268f190dcfd6..000000000000 --- a/chromium_src/library_loaders/libgio_loader.cc +++ /dev/null @@ -1,174 +0,0 @@ -// This is generated file. Do not modify directly. -// Path to the code generator: tools/generate_library_loader/generate_library_loader.py . - -#include "library_loaders/libgio.h" - -#include - -// Put these sanity checks here so that they fire at most once -// (to avoid cluttering the build output). -#if !defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) && !defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) -#error neither LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN nor LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED defined -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) && defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) -#error both LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN and LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED defined -#endif - -LibGioLoader::LibGioLoader() : loaded_(false) { -} - -LibGioLoader::~LibGioLoader() { - CleanUp(loaded_); -} - -bool LibGioLoader::Load(const std::string& library_name) { - if (loaded_) - return false; - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - library_ = dlopen(library_name.c_str(), RTLD_LAZY); - if (!library_) - return false; -#endif - - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_new = - reinterpret_castg_settings_new)>( - dlsym(library_, "g_settings_new")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_new = &::g_settings_new; -#endif - if (!g_settings_new) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_get_child = - reinterpret_castg_settings_get_child)>( - dlsym(library_, "g_settings_get_child")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_get_child = &::g_settings_get_child; -#endif - if (!g_settings_get_child) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_get_string = - reinterpret_castg_settings_get_string)>( - dlsym(library_, "g_settings_get_string")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_get_string = &::g_settings_get_string; -#endif - if (!g_settings_get_string) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_get_boolean = - reinterpret_castg_settings_get_boolean)>( - dlsym(library_, "g_settings_get_boolean")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_get_boolean = &::g_settings_get_boolean; -#endif - if (!g_settings_get_boolean) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_get_uint = - reinterpret_castg_settings_get_uint)>( - dlsym(library_, "g_settings_get_uint")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_get_uint = &::g_settings_get_uint; -#endif - if (!g_settings_get_uint) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_get_strv = - reinterpret_castg_settings_get_strv)>( - dlsym(library_, "g_settings_get_strv")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_get_strv = &::g_settings_get_strv; -#endif - if (!g_settings_get_strv) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_is_writable = - reinterpret_castg_settings_is_writable)>( - dlsym(library_, "g_settings_is_writable")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_is_writable = &::g_settings_is_writable; -#endif - if (!g_settings_is_writable) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_list_schemas = - reinterpret_castg_settings_list_schemas)>( - dlsym(library_, "g_settings_list_schemas")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_list_schemas = &::g_settings_list_schemas; -#endif - if (!g_settings_list_schemas) { - CleanUp(true); - return false; - } - -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - g_settings_list_keys = - reinterpret_castg_settings_list_keys)>( - dlsym(library_, "g_settings_list_keys")); -#endif -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DT_NEEDED) - g_settings_list_keys = &::g_settings_list_keys; -#endif - if (!g_settings_list_keys) { - CleanUp(true); - return false; - } - - loaded_ = true; - return true; -} - -void LibGioLoader::CleanUp(bool unload) { -#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBGIO_H_DLOPEN) - if (unload) { - dlclose(library_); - library_ = NULL; - } -#endif - loaded_ = false; - g_settings_new = NULL; - g_settings_get_child = NULL; - g_settings_get_string = NULL; - g_settings_get_boolean = NULL; - g_settings_get_uint = NULL; - g_settings_get_strv = NULL; - g_settings_is_writable = NULL; - g_settings_list_schemas = NULL; - g_settings_list_keys = NULL; - -} diff --git a/filenames.gypi b/filenames.gypi index 5866511faa7e..d14c935ab728 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -340,8 +340,6 @@ 'chromium_src/chrome/renderer/spellchecker/spellcheck_worditerator.h', 'chromium_src/chrome/renderer/tts_dispatcher.cc', 'chromium_src/chrome/renderer/tts_dispatcher.h', - 'chromium_src/library_loaders/libgio_loader.cc', - 'chromium_src/library_loaders/libgio.h', 'chromium_src/library_loaders/libspeechd_loader.cc', 'chromium_src/library_loaders/libspeechd.h', '<@(native_mate_files)',