Title: [109764] releases/WebKitGTK/webkit-1.8/Source

Diff

Modified: releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/ChangeLog (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/ChangeLog	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/ChangeLog	2012-03-05 18:25:47 UTC (rev 109764)
@@ -1,3 +1,22 @@
+2012-03-05  Mario Sanchez Prada  <msanc...@igalia.com>
+
+        [GTK] Add GMainLoop and GMainContext to be handled by GRefPtr
+        https://bugs.webkit.org/show_bug.cgi?id=79496
+
+        Reviewed by Martin Robinson.
+
+        Handle GMainLoop and GMainContext in GRefPtr, by calling
+        g_main_loop_(un)ref and g_main_context_(un)ref in the
+        implementation of the refGPtr and derefGPtr template functions.
+
+        * wtf/gobject/GRefPtr.cpp:
+        (WTF::refGPtr):
+        (WTF):
+        (WTF::derefGPtr):
+        * wtf/gobject/GRefPtr.h:
+        (WTF):
+        * wtf/gobject/GTypedefs.h:
+
 2012-03-04  Jurij Smakov  <ju...@wooyd.org>
 
         SPARC also needs aligned accesses.

Modified: releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GRefPtr.cpp (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GRefPtr.cpp	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GRefPtr.cpp	2012-03-05 18:25:47 UTC (rev 109764)
@@ -37,6 +37,32 @@
     g_hash_table_unref(ptr);
 }
 
+template <> GMainContext* refGPtr(GMainContext* ptr)
+{
+    if (ptr)
+        g_main_context_ref(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr(GMainContext* ptr)
+{
+    if (ptr)
+        g_main_context_unref(ptr);
+}
+
+template <> GMainLoop* refGPtr(GMainLoop* ptr)
+{
+    if (ptr)
+        g_main_loop_ref(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr(GMainLoop* ptr)
+{
+    if (ptr)
+        g_main_loop_unref(ptr);
+}
+
 #if GLIB_CHECK_VERSION(2, 24, 0)
 template <> GVariant* refGPtr(GVariant* ptr)
 {

Modified: releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GRefPtr.h (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GRefPtr.h	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GRefPtr.h	2012-03-05 18:25:47 UTC (rev 109764)
@@ -201,6 +201,10 @@
 
 template <> GHashTable* refGPtr(GHashTable* ptr);
 template <> void derefGPtr(GHashTable* ptr);
+template <> GMainContext* refGPtr(GMainContext* ptr);
+template <> void derefGPtr(GMainContext* ptr);
+template <> GMainLoop* refGPtr(GMainLoop* ptr);
+template <> void derefGPtr(GMainLoop* ptr);
 template <> GVariant* refGPtr(GVariant* ptr);
 template <> void derefGPtr(GVariant* ptr);
 template <> GSource* refGPtr(GSource* ptr);

Modified: releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GTypedefs.h (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GTypedefs.h	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/_javascript_Core/wtf/gobject/GTypedefs.h	2012-03-05 18:25:47 UTC (rev 109764)
@@ -51,6 +51,8 @@
 typedef struct _GHashTable GHashTable;
 typedef struct _GInputStream GInputStream;
 typedef struct _GList GList;
+typedef struct _GMainContext GMainContext;
+typedef struct _GMainLoop GMainLoop;
 typedef struct _GPatternSpec GPatternSpec;
 typedef struct _GPollableOutputStream GPollableOutputStream;
 typedef struct _GSList GSList;

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog	2012-03-05 18:25:47 UTC (rev 109764)
@@ -1,3 +1,29 @@
+2012-03-05  Mario Sanchez Prada  <msanc...@igalia.com>
+
+        [GTK] Add GMainLoop and GMainContext to be handled by GRefPtr
+        https://bugs.webkit.org/show_bug.cgi?id=79496
+
+        Reviewed by Martin Robinson.
+
+        Updated places where raw pointers to GMainLoop and GMainContext
+        were being used, replacing them with GRefPtr-based code.
+
+        * platform/RunLoop.h:
+        (RunLoop):
+        * platform/gtk/RunLoopGtk.cpp:
+        (WebCore::RunLoop::RunLoop):
+        (WebCore::RunLoop::~RunLoop):
+        (WebCore::RunLoop::mainLoop):
+        (WebCore::RunLoop::stop):
+        (WebCore::RunLoop::wakeUp):
+        (WebCore::RunLoop::TimerBase::start):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCoreSynchronousLoader):
+        (WebCore::WebCoreSynchronousLoader::WebCoreSynchronousLoader):
+        (WebCore::WebCoreSynchronousLoader::~WebCoreSynchronousLoader):
+        (WebCore::WebCoreSynchronousLoader::didFinishLoading):
+        (WebCore::WebCoreSynchronousLoader::run):
+
 2012-03-05  Philippe Normand  <pnorm...@igalia.com>
 
         [GStreamer] media/media-can-play-flac-audio.html fails

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/RunLoop.h (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/RunLoop.h	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/RunLoop.h	2012-03-05 18:25:47 UTC (rev 109764)
@@ -37,10 +37,6 @@
 
 #if PLATFORM(GTK)
 #include <wtf/gobject/GRefPtr.h>
-typedef struct _GSource GSource;
-typedef struct _GMainLoop GMainLoop;
-typedef struct _GMainContext GMainContext;
-typedef int gboolean;
 #endif
 
 namespace WebCore {
@@ -157,8 +153,8 @@
     static gboolean queueWork(RunLoop*);
     GMainLoop* mainLoop();
 private:
-    GMainContext* m_runLoopContext;
-    GMainLoop* m_runLoopMain;
+    GRefPtr<GMainContext> m_runLoopContext;
+    GRefPtr<GMainLoop> m_runLoopMain;
 #endif
 };
 

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/gtk/RunLoopGtk.cpp (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/gtk/RunLoopGtk.cpp	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/gtk/RunLoopGtk.cpp	2012-03-05 18:25:47 UTC (rev 109764)
@@ -33,22 +33,17 @@
 
 RunLoop::RunLoop()
 {
+    // g_main_context_default() doesn't add an extra reference.
     m_runLoopContext = g_main_context_default();
     ASSERT(m_runLoopContext);
-    m_runLoopMain = g_main_loop_new(m_runLoopContext, FALSE);
+    m_runLoopMain = adoptGRef(g_main_loop_new(m_runLoopContext.get(), FALSE));
     ASSERT(m_runLoopMain);
 }
 
 RunLoop::~RunLoop()
 {
-    if (m_runLoopMain) {
-        if (g_main_loop_is_running(m_runLoopMain))
-            g_main_loop_quit(m_runLoopMain);
-        g_main_loop_unref(m_runLoopMain);
-    }
-
-    if (m_runLoopContext)
-        g_main_context_unref(m_runLoopContext);
+    if (m_runLoopMain && g_main_loop_is_running(m_runLoopMain.get()))
+        g_main_loop_quit(m_runLoopMain.get());
 }
 
 void RunLoop::run()
@@ -58,12 +53,12 @@
 
 GMainLoop* RunLoop::mainLoop()
 {
-    return m_runLoopMain;
+    return m_runLoopMain.get();
 }
 
 void RunLoop::stop()
 {
-    g_main_loop_quit(m_runLoopMain);
+    g_main_loop_quit(m_runLoopMain.get());
 }
 
 gboolean RunLoop::queueWork(RunLoop* runLoop)
@@ -77,9 +72,9 @@
     GRefPtr<GSource> source = adoptGRef(g_idle_source_new());
     g_source_set_priority(source.get(), G_PRIORITY_DEFAULT);
     g_source_set_callback(source.get(), reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0);
-    g_source_attach(source.get(), m_runLoopContext);
+    g_source_attach(source.get(), m_runLoopContext.get());
 
-    g_main_context_wakeup(m_runLoopContext);
+    g_main_context_wakeup(m_runLoopContext.get());
 }
 
 RunLoop::TimerBase::TimerBase(RunLoop* runLoop)
@@ -117,7 +112,7 @@
     m_timerSource = adoptGRef(g_timeout_source_new(static_cast<guint>(fireInterval * 1000)));
     m_isRepeating = repeat;
     g_source_set_callback(m_timerSource.get(), reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::timerFiredCallback), this, 0);
-    g_source_attach(m_timerSource.get(), m_runLoop->m_runLoopContext);
+    g_source_attach(m_timerSource.get(), m_runLoop->m_runLoopContext.get());
 }
 
 void RunLoop::TimerBase::stop()

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2012-03-05 18:25:47 UTC (rev 109764)
@@ -56,6 +56,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
 
 #if ENABLE(BLOB)
@@ -86,7 +87,7 @@
     ResourceResponse& m_response;
     Vector<char>& m_data;
     bool m_finished;
-    GMainLoop* m_mainLoop;
+    GRefPtr<GMainLoop> m_mainLoop;
 };
 
 WebCoreSynchronousLoader::WebCoreSynchronousLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data)
@@ -95,12 +96,11 @@
     , m_data(data)
     , m_finished(false)
 {
-    m_mainLoop = g_main_loop_new(0, false);
+    m_mainLoop = adoptGRef(g_main_loop_new(0, false));
 }
 
 WebCoreSynchronousLoader::~WebCoreSynchronousLoader()
 {
-    g_main_loop_unref(m_mainLoop);
 }
 
 void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
@@ -115,7 +115,7 @@
 
 void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*, double)
 {
-    g_main_loop_quit(m_mainLoop);
+    g_main_loop_quit(m_mainLoop.get());
     m_finished = true;
 }
 
@@ -128,7 +128,7 @@
 void WebCoreSynchronousLoader::run()
 {
     if (!m_finished)
-        g_main_loop_run(m_mainLoop);
+        g_main_loop_run(m_mainLoop.get());
 }
 
 static void cleanupSoupRequestOperation(ResourceHandle*, bool isDestroying);

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit2/ChangeLog (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit2/ChangeLog	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit2/ChangeLog	2012-03-05 18:25:47 UTC (rev 109764)
@@ -1,3 +1,28 @@
+2012-03-05  Mario Sanchez Prada  <msanc...@igalia.com>
+
+        [GTK] Add GMainLoop and GMainContext to be handled by GRefPtr
+        https://bugs.webkit.org/show_bug.cgi?id=79496
+
+        Reviewed by Martin Robinson.
+
+        Updated places where raw pointers to GMainLoop and GMainContext
+        were being used, replacing them with GRefPtr-based code.
+
+        * Platform/WorkQueue.h:
+        (WorkQueue):
+        * Platform/gtk/WorkQueueGtk.cpp:
+        (WorkQueue::platformInitialize):
+        (WorkQueue::platformInvalidate):
+        (WorkQueue::workQueueThreadBody):
+        (WorkQueue::registerEventSourceHandler):
+        (WorkQueue::dispatchOnSource):
+        * UIProcess/gtk/WebPopupMenuProxyGtk.cpp:
+        (WebKit::WebPopupMenuProxyGtk::WebPopupMenuProxyGtk):
+        (WebKit::WebPopupMenuProxyGtk::showPopupMenu):
+        (WebKit::WebPopupMenuProxyGtk::shutdownRunLoop):
+        * UIProcess/gtk/WebPopupMenuProxyGtk.h:
+        (WebPopupMenuProxyGtk):
+
 2012-03-05  Joone Hur  <joone....@collabora.co.uk>
 
         [GTK] zlib link error with --enable-webkit2

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit2/Platform/WorkQueue.h (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit2/Platform/WorkQueue.h	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit2/Platform/WorkQueue.h	2012-03-05 18:25:47 UTC (rev 109764)
@@ -48,8 +48,7 @@
 class QThread;
 #elif PLATFORM(GTK)
 #include "PlatformProcessIdentifier.h"
-typedef struct _GMainContext GMainContext;
-typedef struct _GMainLoop GMainLoop;
+#include <wtf/gobject/GRefPtr.h>
 typedef gboolean (*GSourceFunc) (gpointer data);
 #endif
 
@@ -171,9 +170,9 @@
     void dispatchOnSource(GSource*, const Function<void()>&, GSourceFunc);
 
     ThreadIdentifier m_workQueueThread;
-    GMainContext* m_eventContext;
+    GRefPtr<GMainContext> m_eventContext;
     Mutex m_eventLoopLock;
-    GMainLoop* m_eventLoop;
+    GRefPtr<GMainLoop> m_eventLoop;
     Mutex m_eventSourcesLock;
     class EventSource;
     HashMap<int, Vector<EventSource*> > m_eventSources;

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp	2012-03-05 18:25:47 UTC (rev 109764)
@@ -103,9 +103,9 @@
 
 void WorkQueue::platformInitialize(const char* name)
 {
-    m_eventContext = g_main_context_new();
+    m_eventContext = adoptGRef(g_main_context_new());
     ASSERT(m_eventContext);
-    m_eventLoop = g_main_loop_new(m_eventContext, FALSE);
+    m_eventLoop = adoptGRef(g_main_loop_new(m_eventContext.get(), FALSE));
     ASSERT(m_eventLoop);
 
     // This name can be com.apple.WebKit.ProcessLauncher or com.apple.CoreIPC.ReceiveQueue.
@@ -129,17 +129,12 @@
     MutexLocker locker(m_eventLoopLock);
 
     if (m_eventLoop) {
-        if (g_main_loop_is_running(m_eventLoop))
-            g_main_loop_quit(m_eventLoop);
-
-        g_main_loop_unref(m_eventLoop);
-        m_eventLoop = 0;
+        if (g_main_loop_is_running(m_eventLoop.get()))
+            g_main_loop_quit(m_eventLoop.get());
+        m_eventLoop.clear();
     }
 
-    if (m_eventContext) {
-        g_main_context_unref(m_eventContext);
-        m_eventContext = 0;
-    }
+    m_eventContext.clear();
 }
 
 void WorkQueue::startWorkQueueThread(WorkQueue* workQueue)
@@ -149,7 +144,7 @@
 
 void WorkQueue::workQueueThreadBody()
 {
-    g_main_loop_run(m_eventLoop);
+    g_main_loop_run(m_eventLoop.get());
 }
 
 void WorkQueue::registerEventSourceHandler(int fileDescriptor, int condition, const Function<void()>& function)
@@ -177,7 +172,7 @@
         m_eventSources.set(fileDescriptor, sources);
     }
 
-    g_source_attach(dispatchSource.get(), m_eventContext);
+    g_source_attach(dispatchSource.get(), m_eventContext.get());
 }
 
 void WorkQueue::unregisterEventSourceHandler(int fileDescriptor)
@@ -206,7 +201,7 @@
     g_source_set_callback(dispatchSource, sourceCallback, eventSource,
                           reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource));
 
-    g_source_attach(dispatchSource, m_eventContext);
+    g_source_attach(dispatchSource, m_eventContext.get());
 }
 
 void WorkQueue::dispatch(const Function<void()>& function)

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp	2012-03-05 18:25:47 UTC (rev 109764)
@@ -41,7 +41,6 @@
     : WebPopupMenuProxy(client)
     , m_webView(webView)
     , m_activeItem(-1)
-    , m_runLoop(0)
 {
 }
 
@@ -96,14 +95,13 @@
 
     // WebPageProxy expects the menu to run in a nested run loop, since it invalidates the
     // menu right after calling WebPopupMenuProxy::showPopupMenu().
-    m_runLoop = g_main_loop_new(0, FALSE);
+    m_runLoop = adoptGRef(g_main_loop_new(0, FALSE));
 
     GDK_THREADS_LEAVE();
-    g_main_loop_run(m_runLoop);
+    g_main_loop_run(m_runLoop.get());
     GDK_THREADS_ENTER();
 
-    g_main_loop_unref(m_runLoop);
-    m_runLoop = 0;
+    m_runLoop.clear();
 
     g_signal_handler_disconnect(m_popup->platformMenu(), unmapHandler);
 
@@ -120,8 +118,8 @@
 
 void WebPopupMenuProxyGtk::shutdownRunLoop()
 {
-    if (g_main_loop_is_running(m_runLoop))
-        g_main_loop_quit(m_runLoop);
+    if (g_main_loop_is_running(m_runLoop.get()))
+        g_main_loop_quit(m_runLoop.get());
 }
 
 void WebPopupMenuProxyGtk::menuItemActivated(GtkAction* action, WebPopupMenuProxyGtk* popupMenu)

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h (109763 => 109764)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h	2012-03-05 18:23:26 UTC (rev 109763)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h	2012-03-05 18:25:47 UTC (rev 109764)
@@ -23,6 +23,7 @@
 #include "WebPopupMenuProxy.h"
 #include <WebCore/GtkPopupMenu.h>
 #include <WebCore/IntRect.h>
+#include <wtf/gobject/GRefPtr.h>
 
 typedef struct _GMainLoop GMainLoop;
 
@@ -53,7 +54,7 @@
     GtkWidget* m_webView;
     OwnPtr<WebCore::GtkPopupMenu> m_popup;
     int m_activeItem;
-    GMainLoop* m_runLoop;
+    GRefPtr<GMainLoop> m_runLoop;
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to