Changeset 109129 in webkit
- Timestamp:
- Feb 28, 2012 11:35:15 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r109105 r109129 1 2012-02-28 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [GTK] Add GMainLoop and GMainContext to be handled by GRefPtr 4 https://bugs.webkit.org/show_bug.cgi?id=79496 5 6 Reviewed by Martin Robinson. 7 8 Handle GMainLoop and GMainContext in GRefPtr, by calling 9 g_main_loop_(un)ref and g_main_context_(un)ref in the 10 implementation of the refGPtr and derefGPtr template functions. 11 12 * wtf/gobject/GRefPtr.cpp: 13 (WTF::refGPtr): 14 (WTF): 15 (WTF::derefGPtr): 16 * wtf/gobject/GRefPtr.h: 17 (WTF): 18 * wtf/gobject/GTypedefs.h: 19 1 20 2012-02-28 Yong Li <yoli@rim.com> 2 21 -
trunk/Source/JavaScriptCore/wtf/gobject/GRefPtr.cpp
r95901 r109129 36 36 { 37 37 g_hash_table_unref(ptr); 38 } 39 40 template <> GMainContext* refGPtr(GMainContext* ptr) 41 { 42 if (ptr) 43 g_main_context_ref(ptr); 44 return ptr; 45 } 46 47 template <> void derefGPtr(GMainContext* ptr) 48 { 49 if (ptr) 50 g_main_context_unref(ptr); 51 } 52 53 template <> GMainLoop* refGPtr(GMainLoop* ptr) 54 { 55 if (ptr) 56 g_main_loop_ref(ptr); 57 return ptr; 58 } 59 60 template <> void derefGPtr(GMainLoop* ptr) 61 { 62 if (ptr) 63 g_main_loop_unref(ptr); 38 64 } 39 65 -
trunk/Source/JavaScriptCore/wtf/gobject/GRefPtr.h
r95901 r109129 202 202 template <> GHashTable* refGPtr(GHashTable* ptr); 203 203 template <> void derefGPtr(GHashTable* ptr); 204 template <> GMainContext* refGPtr(GMainContext* ptr); 205 template <> void derefGPtr(GMainContext* ptr); 206 template <> GMainLoop* refGPtr(GMainLoop* ptr); 207 template <> void derefGPtr(GMainLoop* ptr); 204 208 template <> GVariant* refGPtr(GVariant* ptr); 205 209 template <> void derefGPtr(GVariant* ptr); -
trunk/Source/JavaScriptCore/wtf/gobject/GTypedefs.h
r107566 r109129 52 52 typedef struct _GInputStream GInputStream; 53 53 typedef struct _GList GList; 54 typedef struct _GMainContext GMainContext; 55 typedef struct _GMainLoop GMainLoop; 54 56 typedef struct _GPatternSpec GPatternSpec; 55 57 typedef struct _GPollableOutputStream GPollableOutputStream; -
trunk/Source/WebCore/ChangeLog
r109125 r109129 1 2012-02-28 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [GTK] Add GMainLoop and GMainContext to be handled by GRefPtr 4 https://bugs.webkit.org/show_bug.cgi?id=79496 5 6 Reviewed by Martin Robinson. 7 8 Updated places where raw pointers to GMainLoop and GMainContext 9 were being used, replacing them with GRefPtr-based code. 10 11 * platform/RunLoop.h: 12 (RunLoop): 13 * platform/gtk/RunLoopGtk.cpp: 14 (WebCore::RunLoop::RunLoop): 15 (WebCore::RunLoop::~RunLoop): 16 (WebCore::RunLoop::mainLoop): 17 (WebCore::RunLoop::stop): 18 (WebCore::RunLoop::wakeUp): 19 (WebCore::RunLoop::TimerBase::start): 20 * platform/network/soup/ResourceHandleSoup.cpp: 21 (WebCoreSynchronousLoader): 22 (WebCore::WebCoreSynchronousLoader::WebCoreSynchronousLoader): 23 (WebCore::WebCoreSynchronousLoader::~WebCoreSynchronousLoader): 24 (WebCore::WebCoreSynchronousLoader::didFinishLoading): 25 (WebCore::WebCoreSynchronousLoader::run): 26 1 27 2012-02-28 Alok Priyadarshi <alokp@chromium.org> 2 28 -
trunk/Source/WebCore/platform/RunLoop.h
r105552 r109129 38 38 #if PLATFORM(GTK) 39 39 #include <wtf/gobject/GRefPtr.h> 40 typedef struct _GSource GSource;41 typedef struct _GMainLoop GMainLoop;42 typedef struct _GMainContext GMainContext;43 typedef int gboolean;44 40 #endif 45 41 … … 158 154 GMainLoop* mainLoop(); 159 155 private: 160 G MainContext*m_runLoopContext;161 G MainLoop*m_runLoopMain;156 GRefPtr<GMainContext> m_runLoopContext; 157 GRefPtr<GMainLoop> m_runLoopMain; 162 158 #endif 163 159 }; -
trunk/Source/WebCore/platform/gtk/RunLoopGtk.cpp
r105475 r109129 34 34 RunLoop::RunLoop() 35 35 { 36 // g_main_context_default() doesn't add an extra reference. 36 37 m_runLoopContext = g_main_context_default(); 37 38 ASSERT(m_runLoopContext); 38 m_runLoopMain = g_main_loop_new(m_runLoopContext, FALSE);39 m_runLoopMain = adoptGRef(g_main_loop_new(m_runLoopContext.get(), FALSE)); 39 40 ASSERT(m_runLoopMain); 40 41 } … … 42 43 RunLoop::~RunLoop() 43 44 { 44 if (m_runLoopMain) { 45 if (g_main_loop_is_running(m_runLoopMain)) 46 g_main_loop_quit(m_runLoopMain); 47 g_main_loop_unref(m_runLoopMain); 48 } 49 50 if (m_runLoopContext) 51 g_main_context_unref(m_runLoopContext); 45 if (m_runLoopMain && g_main_loop_is_running(m_runLoopMain.get())) 46 g_main_loop_quit(m_runLoopMain.get()); 52 47 } 53 48 … … 59 54 GMainLoop* RunLoop::mainLoop() 60 55 { 61 return m_runLoopMain ;56 return m_runLoopMain.get(); 62 57 } 63 58 64 59 void RunLoop::stop() 65 60 { 66 g_main_loop_quit(m_runLoopMain );61 g_main_loop_quit(m_runLoopMain.get()); 67 62 } 68 63 … … 78 73 g_source_set_priority(source.get(), G_PRIORITY_DEFAULT); 79 74 g_source_set_callback(source.get(), reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0); 80 g_source_attach(source.get(), m_runLoopContext );75 g_source_attach(source.get(), m_runLoopContext.get()); 81 76 82 g_main_context_wakeup(m_runLoopContext );77 g_main_context_wakeup(m_runLoopContext.get()); 83 78 } 84 79 … … 118 113 m_isRepeating = repeat; 119 114 g_source_set_callback(m_timerSource.get(), reinterpret_cast<GSourceFunc>(&RunLoop::TimerBase::timerFiredCallback), this, 0); 120 g_source_attach(m_timerSource.get(), m_runLoop->m_runLoopContext );115 g_source_attach(m_timerSource.get(), m_runLoop->m_runLoopContext.get()); 121 116 } 122 117 -
trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r107973 r109129 57 57 #include <sys/types.h> 58 58 #include <unistd.h> 59 #include <wtf/gobject/GRefPtr.h> 59 60 #include <wtf/text/CString.h> 60 61 … … 87 88 Vector<char>& m_data; 88 89 bool m_finished; 89 G MainLoop*m_mainLoop;90 GRefPtr<GMainLoop> m_mainLoop; 90 91 }; 91 92 … … 96 97 , m_finished(false) 97 98 { 98 m_mainLoop = g_main_loop_new(0, false);99 m_mainLoop = adoptGRef(g_main_loop_new(0, false)); 99 100 } 100 101 101 102 WebCoreSynchronousLoader::~WebCoreSynchronousLoader() 102 103 { 103 g_main_loop_unref(m_mainLoop);104 104 } 105 105 … … 116 116 void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*, double) 117 117 { 118 g_main_loop_quit(m_mainLoop );118 g_main_loop_quit(m_mainLoop.get()); 119 119 m_finished = true; 120 120 } … … 129 129 { 130 130 if (!m_finished) 131 g_main_loop_run(m_mainLoop );131 g_main_loop_run(m_mainLoop.get()); 132 132 } 133 133 -
trunk/Source/WebKit2/ChangeLog
r109121 r109129 1 2012-02-28 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [GTK] Add GMainLoop and GMainContext to be handled by GRefPtr 4 https://bugs.webkit.org/show_bug.cgi?id=79496 5 6 Reviewed by Martin Robinson. 7 8 Updated places where raw pointers to GMainLoop and GMainContext 9 were being used, replacing them with GRefPtr-based code. 10 11 * Platform/WorkQueue.h: 12 (WorkQueue): 13 * Platform/gtk/WorkQueueGtk.cpp: 14 (WorkQueue::platformInitialize): 15 (WorkQueue::platformInvalidate): 16 (WorkQueue::workQueueThreadBody): 17 (WorkQueue::registerEventSourceHandler): 18 (WorkQueue::dispatchOnSource): 19 * UIProcess/gtk/WebPopupMenuProxyGtk.cpp: 20 (WebKit::WebPopupMenuProxyGtk::WebPopupMenuProxyGtk): 21 (WebKit::WebPopupMenuProxyGtk::showPopupMenu): 22 (WebKit::WebPopupMenuProxyGtk::shutdownRunLoop): 23 * UIProcess/gtk/WebPopupMenuProxyGtk.h: 24 (WebPopupMenuProxyGtk): 25 1 26 2012-02-28 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 27 -
trunk/Source/WebKit2/Platform/WorkQueue.h
r108119 r109129 49 49 #elif PLATFORM(GTK) 50 50 #include "PlatformProcessIdentifier.h" 51 typedef struct _GMainContext GMainContext; 52 typedef struct _GMainLoop GMainLoop; 51 #include <wtf/gobject/GRefPtr.h> 53 52 typedef gboolean (*GSourceFunc) (gpointer data); 54 53 #endif … … 172 171 173 172 ThreadIdentifier m_workQueueThread; 174 G MainContext*m_eventContext;173 GRefPtr<GMainContext> m_eventContext; 175 174 Mutex m_eventLoopLock; 176 G MainLoop*m_eventLoop;175 GRefPtr<GMainLoop> m_eventLoop; 177 176 Mutex m_eventSourcesLock; 178 177 class EventSource; -
trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp
r108119 r109129 104 104 void WorkQueue::platformInitialize(const char* name) 105 105 { 106 m_eventContext = g_main_context_new();106 m_eventContext = adoptGRef(g_main_context_new()); 107 107 ASSERT(m_eventContext); 108 m_eventLoop = g_main_loop_new(m_eventContext, FALSE);108 m_eventLoop = adoptGRef(g_main_loop_new(m_eventContext.get(), FALSE)); 109 109 ASSERT(m_eventLoop); 110 110 … … 130 130 131 131 if (m_eventLoop) { 132 if (g_main_loop_is_running(m_eventLoop)) 133 g_main_loop_quit(m_eventLoop); 134 135 g_main_loop_unref(m_eventLoop); 136 m_eventLoop = 0; 137 } 138 139 if (m_eventContext) { 140 g_main_context_unref(m_eventContext); 141 m_eventContext = 0; 142 } 132 if (g_main_loop_is_running(m_eventLoop.get())) 133 g_main_loop_quit(m_eventLoop.get()); 134 m_eventLoop.clear(); 135 } 136 137 m_eventContext.clear(); 143 138 } 144 139 … … 150 145 void WorkQueue::workQueueThreadBody() 151 146 { 152 g_main_loop_run(m_eventLoop );147 g_main_loop_run(m_eventLoop.get()); 153 148 } 154 149 … … 178 173 } 179 174 180 g_source_attach(dispatchSource.get(), m_eventContext );175 g_source_attach(dispatchSource.get(), m_eventContext.get()); 181 176 } 182 177 … … 207 202 reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); 208 203 209 g_source_attach(dispatchSource, m_eventContext );204 g_source_attach(dispatchSource, m_eventContext.get()); 210 205 } 211 206 -
trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp
r101678 r109129 42 42 , m_webView(webView) 43 43 , m_activeItem(-1) 44 , m_runLoop(0)45 44 { 46 45 } … … 97 96 // WebPageProxy expects the menu to run in a nested run loop, since it invalidates the 98 97 // menu right after calling WebPopupMenuProxy::showPopupMenu(). 99 m_runLoop = g_main_loop_new(0, FALSE);98 m_runLoop = adoptGRef(g_main_loop_new(0, FALSE)); 100 99 101 100 GDK_THREADS_LEAVE(); 102 g_main_loop_run(m_runLoop );101 g_main_loop_run(m_runLoop.get()); 103 102 GDK_THREADS_ENTER(); 104 103 105 g_main_loop_unref(m_runLoop); 106 m_runLoop = 0; 104 m_runLoop.clear(); 107 105 108 106 g_signal_handler_disconnect(m_popup->platformMenu(), unmapHandler); … … 121 119 void WebPopupMenuProxyGtk::shutdownRunLoop() 122 120 { 123 if (g_main_loop_is_running(m_runLoop ))124 g_main_loop_quit(m_runLoop );121 if (g_main_loop_is_running(m_runLoop.get())) 122 g_main_loop_quit(m_runLoop.get()); 125 123 } 126 124 -
trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h
r95901 r109129 24 24 #include <WebCore/GtkPopupMenu.h> 25 25 #include <WebCore/IntRect.h> 26 #include <wtf/gobject/GRefPtr.h> 26 27 27 28 typedef struct _GMainLoop GMainLoop; … … 54 55 OwnPtr<WebCore::GtkPopupMenu> m_popup; 55 56 int m_activeItem; 56 G MainLoop*m_runLoop;57 GRefPtr<GMainLoop> m_runLoop; 57 58 }; 58 59
Note: See TracChangeset
for help on using the changeset viewer.