From: carlosgc@webkit.org Date: Tue, 12 Aug 2014 10:55:46 +0000 (+0000) Subject: [GTK] The plugins metadata cache doesn't work if the user cache directory doesn't... X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=62db2d9290e39cfec11fdb857610141b0d4767fa [GTK] The plugins metadata cache doesn't work if the user cache directory doesn't exist https://bugs.webkit.org/show_bug.cgi?id=135834 Reviewed by Philippe Normand. Make sure the user cache directory exists. If creating the directory fails for whatever reason, do not try to save the cache to disk. * UIProcess/Plugins/gtk/PluginInfoCache.cpp: (WebKit::PluginInfoCache::PluginInfoCache): (WebKit::PluginInfoCache::updatePluginInfo): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172442 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 67b3dfab7ee9..1762f43a44a9 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,18 @@ +2014-08-12 Carlos Garcia Campos + + [GTK] The plugins metadata cache doesn't work if the user cache directory doesn't exist + https://bugs.webkit.org/show_bug.cgi?id=135834 + + Reviewed by Philippe Normand. + + Make sure the user cache directory exists. If creating the + directory fails for whatever reason, do not try to save the cache + to disk. + + * UIProcess/Plugins/gtk/PluginInfoCache.cpp: + (WebKit::PluginInfoCache::PluginInfoCache): + (WebKit::PluginInfoCache::updatePluginInfo): + 2014-08-12 Alexey Proskuryakov [Mac] Allow reading CoreGraphics debugging preferences diff --git a/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp b/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp index 2340c4533d53..d39cd4cdc6d9 100644 --- a/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp +++ b/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp @@ -44,9 +44,12 @@ PluginInfoCache& PluginInfoCache::shared() PluginInfoCache::PluginInfoCache() : m_cacheFile(g_key_file_new()) - , m_cachePath(g_build_filename(g_get_user_cache_dir(), "webkitgtk", "plugins", nullptr)) { - g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr); + GUniquePtr cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", nullptr)); + if (WebCore::makeAllDirectories(cacheDirectory.get())) { + m_cachePath.reset(g_build_filename(cacheDirectory.get(), "plugins", nullptr)); + g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr); + } if (g_key_file_has_group(m_cacheFile.get(), "schema")) { unsigned schemaVersion = static_cast(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr)); @@ -130,13 +133,15 @@ void PluginInfoCache::updatePluginInfo(const String& pluginPath, const PluginMod g_key_file_set_boolean(m_cacheFile.get(), pluginGroup.data(), "requires-gtk2", plugin.requiresGtk2); - // Save the cache file in an idle to make sure it happens in the main thread and - // it's done only once when this is called multiple times in a very short time. - std::lock_guard lock(m_mutex); - if (m_saveToFileIdle.isScheduled()) - return; + if (m_cachePath) { + // Save the cache file in an idle to make sure it happens in the main thread and + // it's done only once when this is called multiple times in a very short time. + std::lock_guard lock(m_mutex); + if (m_saveToFileIdle.isScheduled()) + return; - m_saveToFileIdle.schedule("[WebKit] PluginInfoCache::saveToFile", std::bind(&PluginInfoCache::saveToFile, this), G_PRIORITY_DEFAULT_IDLE); + m_saveToFileIdle.schedule("[WebKit] PluginInfoCache::saveToFile", std::bind(&PluginInfoCache::saveToFile, this), G_PRIORITY_DEFAULT_IDLE); + } } } // namespace WebKit