Skip to content

Commit

Permalink
Merge r172442 - [GTK] The plugins metadata cache doesn't work if the …
Browse files Browse the repository at this point in the history
…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):
  • Loading branch information
carlosgcampos committed Aug 25, 2014
1 parent 8c3cb20 commit 7e1d01a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
15 changes: 15 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,18 @@
2014-08-12 Carlos Garcia Campos <cgarcia@igalia.com>

[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-07-02 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] WebKitVersion.h should be shared between UI and Web Process APIs
Expand Down
21 changes: 13 additions & 8 deletions Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp
Expand Up @@ -44,10 +44,13 @@ PluginInfoCache& PluginInfoCache::shared()

PluginInfoCache::PluginInfoCache()
: m_cacheFile(g_key_file_new())
, m_cachePath(g_build_filename(g_get_user_cache_dir(), "webkitgtk", "plugins", nullptr))
, m_saveToFileIdleId(0)
{
g_key_file_load_from_file(m_cacheFile.get(), m_cachePath.get(), G_KEY_FILE_NONE, nullptr);
GUniquePtr<char> 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<unsigned>(g_key_file_get_integer(m_cacheFile.get(), "schema", "version", nullptr));
Expand Down Expand Up @@ -134,13 +137,15 @@ void PluginInfoCache::updatePluginInfo(const String& pluginPath, const PluginMod
g_key_file_set_string(m_cacheFile.get(), pluginGroup.data(), "mime-description", mimeDescription.utf8().data());
#endif

// 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<std::mutex> lock(m_mutex);
if (m_saveToFileIdleId)
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<std::mutex> lock(m_mutex);
if (m_saveToFileIdleId)
return;

m_saveToFileIdleId = g_idle_add(reinterpret_cast<GSourceFunc>(PluginInfoCache::saveToFileIdleCallback), this);
m_saveToFileIdleId = g_idle_add(reinterpret_cast<GSourceFunc>(PluginInfoCache::saveToFileIdleCallback), this);
}
}

} // namespace WebKit
Expand Down

0 comments on commit 7e1d01a

Please sign in to comment.