Title: [191855] trunk/Source/WebKit2
- Revision
- 191855
- Author
- carlo...@webkit.org
- Date
- 2015-11-01 01:33:38 -0700 (Sun, 01 Nov 2015)
Log Message
[GTK] Use RunLoop::Timer in PluginInfoCache
https://bugs.webkit.org/show_bug.cgi?id=150757
Reviewed by Darin Adler.
Use RunLoop::Timer instead of GMainLoopSource to save the cache
contents in an idle. Also remove the mutex, since RunLoop::Timer
is thread safe and saveToFile() is private and only called by the
main thread loop. Also removed the code to save the file in the
destructor since PluginInfoCache is a singleton and never
destroyed. It's very unlikely that the program finished before the
cache is saved, but even if that happens it would be harmless, the
cache will be saved at some point the next time.
* UIProcess/Plugins/gtk/PluginInfoCache.cpp:
(WebKit::PluginInfoCache::PluginInfoCache):
(WebKit::PluginInfoCache::updatePluginInfo):
(WebKit::PluginInfoCache::~PluginInfoCache):
(WebKit::PluginInfoCache::saveToFile):
* UIProcess/Plugins/gtk/PluginInfoCache.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (191854 => 191855)
--- trunk/Source/WebKit2/ChangeLog 2015-11-01 08:31:16 UTC (rev 191854)
+++ trunk/Source/WebKit2/ChangeLog 2015-11-01 08:33:38 UTC (rev 191855)
@@ -1,5 +1,28 @@
2015-11-01 Carlos Garcia Campos <cgar...@igalia.com>
+ [GTK] Use RunLoop::Timer in PluginInfoCache
+ https://bugs.webkit.org/show_bug.cgi?id=150757
+
+ Reviewed by Darin Adler.
+
+ Use RunLoop::Timer instead of GMainLoopSource to save the cache
+ contents in an idle. Also remove the mutex, since RunLoop::Timer
+ is thread safe and saveToFile() is private and only called by the
+ main thread loop. Also removed the code to save the file in the
+ destructor since PluginInfoCache is a singleton and never
+ destroyed. It's very unlikely that the program finished before the
+ cache is saved, but even if that happens it would be harmless, the
+ cache will be saved at some point the next time.
+
+ * UIProcess/Plugins/gtk/PluginInfoCache.cpp:
+ (WebKit::PluginInfoCache::PluginInfoCache):
+ (WebKit::PluginInfoCache::updatePluginInfo):
+ (WebKit::PluginInfoCache::~PluginInfoCache):
+ (WebKit::PluginInfoCache::saveToFile):
+ * UIProcess/Plugins/gtk/PluginInfoCache.h:
+
+2015-11-01 Carlos Garcia Campos <cgar...@igalia.com>
+
[GTK] Use a RunLoop::Timer to schedule rendering frames in accelerated compositing mode
https://bugs.webkit.org/show_bug.cgi?id=150756
Modified: trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp (191854 => 191855)
--- trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp 2015-11-01 08:31:16 UTC (rev 191854)
+++ trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp 2015-11-01 08:33:38 UTC (rev 191855)
@@ -44,8 +44,11 @@
PluginInfoCache::PluginInfoCache()
: m_cacheFile(g_key_file_new())
+ , m_saveToFileIdle(RunLoop::main(), this, &PluginInfoCache::saveToFile)
, m_readOnlyMode(false)
{
+ m_saveToFileIdle.setPriority(G_PRIORITY_DEFAULT_IDLE);
+
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));
@@ -71,16 +74,10 @@
PluginInfoCache::~PluginInfoCache()
{
- if (m_saveToFileIdle.isScheduled()) {
- m_saveToFileIdle.cancel();
- saveToFile();
- }
}
void PluginInfoCache::saveToFile()
{
- std::lock_guard<Lock> lock(m_mutex);
-
gsize dataLength;
GUniquePtr<char> data(g_key_file_to_data(m_cacheFile.get(), &dataLength, nullptr));
if (!data)
@@ -142,11 +139,10 @@
if (m_cachePath && !m_readOnlyMode) {
// 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> lock(m_mutex);
- if (m_saveToFileIdle.isScheduled())
+ if (m_saveToFileIdle.isActive())
return;
- m_saveToFileIdle.schedule("[WebKit] PluginInfoCache::saveToFile", std::bind(&PluginInfoCache::saveToFile, this), G_PRIORITY_DEFAULT_IDLE);
+ m_saveToFileIdle.startOneShot(0);
}
}
Modified: trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h (191854 => 191855)
--- trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h 2015-11-01 08:31:16 UTC (rev 191854)
+++ trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h 2015-11-01 08:33:38 UTC (rev 191855)
@@ -29,10 +29,8 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
#include "PluginModuleInfo.h"
-#include <mutex>
-#include <wtf/Lock.h>
#include <wtf/NeverDestroyed.h>
-#include <wtf/glib/GMainLoopSource.h>
+#include <wtf/RunLoop.h>
#include <wtf/glib/GUniquePtr.h>
namespace WebKit {
@@ -54,9 +52,8 @@
GUniquePtr<GKeyFile> m_cacheFile;
GUniquePtr<char> m_cachePath;
- GMainLoopSource m_saveToFileIdle;
+ RunLoop::Timer<PluginInfoCache> m_saveToFileIdle;
bool m_readOnlyMode;
- Lock m_mutex;
};
} // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes