Changeset 160162 in webkit
- Timestamp:
- Dec 5, 2013 12:47:45 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r160161 r160162 1 2013-12-05 Zan Dobersek <zdobersek@igalia.com> 2 3 [GTK][WK2] Clean up WorkQueueGtk 4 https://bugs.webkit.org/show_bug.cgi?id=125177 5 6 Reviewed by Carlos Garcia Campos. 7 8 Clean up the GTK implementation of the WorkQueue class a bit. 9 - registerSocketEventHandler doesn't take a condition argument anymore -- G_IO_IN was the only condition ever passed into 10 that method so that is now the hard-coded default. 11 - Clean up the declarations of GTK-specific bits in the WorkQueue header file. SocketEventSourceIterator typedef is removed 12 and auto will be used instead. 13 - WorkQueue::dispatchOnTermination and WorkQueue::SocketEventSource::performWorkOnTermination methods were unused and now removed. 14 - WorkQueue::SocketEventSource doesn't expect a GIO condition anymore, and WorkQueue::SocketEventSource::checkCondition is removed. 15 G_IO_IN condition was the only one used is now hard-coded into the check in WorkQueue::SocketEventSource::eventCallback. 16 - Removed an unnecessary non-null assertion for the heap-allocated SocketEventSource. 17 - Removed a technically duplicated assertion that a file descriptor is already present in the event sources map. Moved the 18 assertion before the HashMap::find() call. 19 - Removed two unnecessary assertions that non-null values are being returned by g_idle_source_new() and g_timeout_source_new(). 20 Both functions are guaranteed to return non-null values. 21 22 * Platform/CoreIPC/unix/ConnectionUnix.cpp: 23 (CoreIPC::Connection::open): 24 * Platform/WorkQueue.h: 25 * Platform/gtk/WorkQueueGtk.cpp: 26 (WorkQueue::SocketEventSource::SocketEventSource): 27 (WorkQueue::SocketEventSource::eventCallback): 28 (WorkQueue::registerSocketEventHandler): 29 (WorkQueue::unregisterSocketEventHandler): 30 (WorkQueue::dispatch): 31 (WorkQueue::dispatchAfterDelay): 32 1 33 2013-12-04 Gergo Balogh <geryxyz@inf.u-szeged.hu> 2 34 -
trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp
r156887 r160162 379 379 m_isConnected = true; 380 380 #if PLATFORM(GTK) 381 m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, G_IO_IN,WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));381 m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this)); 382 382 #elif PLATFORM(EFL) 383 383 m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this)); -
trunk/Source/WebKit2/Platform/WorkQueue.h
r157894 r160162 65 65 dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; } 66 66 #elif PLATFORM(GTK) 67 void registerSocketEventHandler(int, int, const Function<void()>& function, const Function<void()>& closeFunction);67 void registerSocketEventHandler(int, const Function<void()>&, const Function<void()>&); 68 68 void unregisterSocketEventHandler(int); 69 void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);70 69 #elif PLATFORM(EFL) 71 70 void registerSocketEventHandler(int, const Function<void()>&); … … 83 82 dispatch_queue_t m_dispatchQueue; 84 83 #elif PLATFORM(GTK) 84 class EventSource; 85 class SocketEventSource; 86 85 87 static void startWorkQueueThread(WorkQueue*); 86 88 void workQueueThreadBody(); … … 92 94 GRefPtr<GMainLoop> m_eventLoop; 93 95 Mutex m_eventSourcesLock; 94 class EventSource;95 class SocketEventSource;96 96 HashMap<int, Vector<SocketEventSource*>> m_eventSources; 97 typedef HashMap<int, Vector<SocketEventSource*>>::iterator SocketEventSourceIterator;98 97 #elif PLATFORM(EFL) 99 98 RefPtr<DispatchQueue> m_dispatchQueue; -
trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp
r159882 r160162 57 57 } 58 58 59 static gboolean performWorkOnTermination(GPid, gint, EventSource* eventSource)60 {61 ASSERT(eventSource);62 eventSource->performWork();63 return FALSE;64 }65 66 59 static void deleteEventSource(EventSource* eventSource) 67 60 { … … 77 70 class WorkQueue::SocketEventSource : public WorkQueue::EventSource { 78 71 public: 79 SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, int condition,GCancellable* cancellable, const Function<void()>& closeFunction)72 SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, GCancellable* cancellable, const Function<void()>& closeFunction) 80 73 : EventSource(function, workQueue) 81 , m_condition(condition)82 74 , m_cancellable(cancellable) 83 75 , m_closeFunction(closeFunction) … … 96 88 } 97 89 98 bool checkCondition(GIOCondition condition) const 99 { 100 return condition & m_condition; 101 } 102 103 static gboolean eventCallback(GSocket*, GIOCondition condition, SocketEventSource* eventSource) 90 static gboolean eventCallback(GSocket* socket, GIOCondition condition, SocketEventSource* eventSource) 104 91 { 105 92 ASSERT(eventSource); … … 110 97 } 111 98 112 if ( eventSource->checkCondition(condition)) {99 if (condition & G_IO_IN) { 113 100 eventSource->performWork(); 114 101 return TRUE; … … 120 107 121 108 private: 122 int m_condition;123 109 GCancellable* m_cancellable; 124 110 Function<void()> m_closeFunction; … … 174 160 } 175 161 176 void WorkQueue::registerSocketEventHandler(int fileDescriptor, int condition,const Function<void()>& function, const Function<void()>& closeFunction)162 void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function, const Function<void()>& closeFunction) 177 163 { 178 164 GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0)); 179 165 ASSERT(socket); 180 166 GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new()); 181 GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get()));167 GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), G_IO_IN, cancellable.get())); 182 168 ASSERT(dispatchSource); 183 SocketEventSource* eventSource = new SocketEventSource(function, this, condition, cancellable.get(), closeFunction); 184 ASSERT(eventSource); 169 SocketEventSource* eventSource = new SocketEventSource(function, this, cancellable.get(), closeFunction); 185 170 186 171 g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::SocketEventSource::eventCallback), … … 191 176 MutexLocker locker(m_eventSourcesLock); 192 177 Vector<SocketEventSource*> sources; 193 SocketEventSourceIteratorit = m_eventSources.find(fileDescriptor);178 auto it = m_eventSources.find(fileDescriptor); 194 179 if (it != m_eventSources.end()) 195 180 sources = it->value; … … 208 193 MutexLocker locker(m_eventSourcesLock); 209 194 210 SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);211 ASSERT(it != m_eventSources.end());212 195 ASSERT(m_eventSources.contains(fileDescriptor)); 196 auto it = m_eventSources.find(fileDescriptor); 213 197 214 198 if (it != m_eventSources.end()) { … … 232 216 { 233 217 GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new()); 234 ASSERT(dispatchSource);235 218 g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT); 236 237 219 dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); 238 220 } … … 241 223 { 242 224 GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(static_cast<guint>(delay * 1000))); 243 ASSERT(dispatchSource);244 245 225 dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); 246 226 } 247 248 void WorkQueue::dispatchOnTermination(WebKit::PlatformProcessIdentifier process, const Function<void()>& function)249 {250 GRefPtr<GSource> dispatchSource = adoptGRef(g_child_watch_source_new(process));251 ASSERT(dispatchSource);252 253 dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination));254 }
Note: See TracChangeset
for help on using the changeset viewer.