Changeset 83281 in webkit
- Timestamp:
- Apr 8, 2011 3:35:28 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r83280 r83281 1 2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Reviewed by Martin Robinson. 4 5 [GTK] Do not destroy WorkQueue event sources unless they have been cancelled 6 https://bugs.webkit.org/show_bug.cgi?id=57611 7 8 * Platform/WorkQueue.h: 9 * Platform/gtk/WorkQueueGtk.cpp: 10 (WorkQueue::EventSource::EventSource): Remove unused member 11 m_dispatchSource. 12 (WorkQueue::EventSource::executeEventSource): Make it return void 13 instead of boolean since we are always ignoring the return value. 14 (WorkQueue::EventSource::performWork): Return FALSE from the 15 callback only when the source has been cancelled (condition = 0) 16 to make sure it's destroyed when the even source handler is 17 unregistered. 18 (WorkQueue::registerEventSourceHandler): Use GRefPtr for the 19 source, to avoid leaking it. 20 (WorkQueue::scheduleWorkOnSource): Receive the source callback as 21 parameter so that it can be used by scheduleWorkOnTermination() too. 22 (WorkQueue::scheduleWork): 23 (WorkQueue::scheduleWorkAfterDelay): 24 (WorkQueue::scheduleWorkOnTermination): Use 25 scheduleWorkOnSource(). 26 1 27 2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 28 -
trunk/Source/WebKit2/Platform/WorkQueue.h
r83280 r83281 50 50 typedef struct _GMainContext GMainContext; 51 51 typedef struct _GMainLoop GMainLoop; 52 typedef gboolean (*GSourceFunc) (gpointer data); 52 53 #endif 53 54 … … 168 169 static void* startWorkQueueThread(WorkQueue*); 169 170 void workQueueThreadBody(); 170 void scheduleWorkOnSource(GSource*, PassOwnPtr<WorkItem> );171 void scheduleWorkOnSource(GSource*, PassOwnPtr<WorkItem>, GSourceFunc); 171 172 172 173 ThreadIdentifier m_workQueueThread; -
trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp
r83280 r83281 1 1 /* 2 * Copyright (C) 2011 Igalia S.L. 2 3 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 4 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. … … 37 38 class WorkQueue::EventSource { 38 39 public: 39 EventSource(GSource* dispatchSource, PassOwnPtr<WorkItem> workItem, WorkQueue* workQueue, GCancellable* cancellable) 40 : m_dispatchSource(dispatchSource) 41 , m_workItem(workItem) 40 EventSource(PassOwnPtr<WorkItem> workItem, WorkQueue* workQueue, GCancellable* cancellable) 41 : m_workItem(workItem) 42 42 , m_workQueue(workQueue) 43 43 , m_cancellable(cancellable) … … 52 52 } 53 53 54 static gbooleanexecuteEventSource(EventSource* eventSource)54 static void executeEventSource(EventSource* eventSource) 55 55 { 56 56 ASSERT(eventSource); … … 59 59 MutexLocker locker(queue->m_isValidMutex); 60 60 if (!queue->m_isValid) 61 return FALSE;61 return; 62 62 } 63 63 64 64 eventSource->m_workItem->execute(); 65 66 return TRUE;67 65 } 68 66 … … 75 73 static gboolean performWork(GSocket* socket, GIOCondition condition, EventSource* eventSource) 76 74 { 77 if (!(condition & G_IO_IN) && !(condition & G_IO_HUP) && !(condition & G_IO_ERR)) 75 if (!(condition & G_IO_IN) && !(condition & G_IO_HUP) && !(condition & G_IO_ERR)) { 76 // EventSource has been cancelled, return FALSE to destroy the source. 78 77 return FALSE; 79 80 81 if (!executeEventSource(eventSource)) 82 return FALSE; 83 84 if ((condition & G_IO_HUP) || (condition & G_IO_ERR)) 85 return FALSE; 86 78 } 79 80 executeEventSource(eventSource); 87 81 return TRUE; 88 82 } … … 101 95 102 96 public: 103 GSource* m_dispatchSource;104 97 PassOwnPtr<WorkItem> m_workItem; 105 98 WorkQueue* m_workQueue; … … 151 144 ASSERT(socket); 152 145 GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new()); 153 G Source* dispatchSource = g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get());154 ASSERT(dispatchSource); 155 EventSource* eventSource = new EventSource( dispatchSource,item, this, cancellable.get());146 GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get())); 147 ASSERT(dispatchSource); 148 EventSource* eventSource = new EventSource(item, this, cancellable.get()); 156 149 ASSERT(eventSource); 157 150 158 g_source_set_callback(dispatchSource , reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWork),151 g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWork), 159 152 eventSource, reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); 160 153 … … 171 164 } 172 165 173 g_source_attach(dispatchSource , m_eventContext);166 g_source_attach(dispatchSource.get(), m_eventContext); 174 167 } 175 168 … … 193 186 } 194 187 195 void WorkQueue::scheduleWorkOnSource(GSource* dispatchSource, PassOwnPtr<WorkItem> item) 196 { 197 EventSource* eventSource = new EventSource(dispatchSource, item, this, 0); 198 199 g_source_set_callback(dispatchSource, 200 reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce), 201 eventSource, 188 void WorkQueue::scheduleWorkOnSource(GSource* dispatchSource, PassOwnPtr<WorkItem> item, GSourceFunc sourceCallback) 189 { 190 EventSource* eventSource = new EventSource(item, this, 0); 191 192 g_source_set_callback(dispatchSource, sourceCallback, eventSource, 202 193 reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); 203 194 … … 211 202 g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT); 212 203 213 scheduleWorkOnSource(dispatchSource.get(), item );204 scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); 214 205 } 215 206 … … 219 210 ASSERT(dispatchSource); 220 211 221 scheduleWorkOnSource(dispatchSource.get(), item );212 scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); 222 213 } 223 214 … … 227 218 ASSERT(dispatchSource); 228 219 229 EventSource* eventSource = new EventSource(dispatchSource.get(), item, this, 0); 230 231 g_source_set_callback(dispatchSource.get(), 232 reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination), 233 eventSource, 234 reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); 235 236 g_source_attach(dispatchSource.get(), m_eventContext); 237 } 220 scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination)); 221 }
Note: See TracChangeset
for help on using the changeset viewer.