Changeset 191881 in webkit
- Timestamp:
- Nov 2, 2015 1:33:28 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r191880 r191881 1 2015-11-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GLIB] Remove support for GSocket main loop sources from GMainLoopSource 4 https://bugs.webkit.org/show_bug.cgi?id=150772 5 6 Reviewed by Žan Doberšek. 7 8 It complicated the code just to make generic what is only used in 9 one place. 10 11 * wtf/glib/GMainLoopSource.cpp: 12 (WTF::GMainLoopSource::cancel): Deleted. 13 (WTF::GMainLoopSource::schedule): Deleted. 14 (WTF::GMainLoopSource::scheduleTimeoutSource): Deleted. 15 (WTF::GMainLoopSource::scheduleAfterDelay): Deleted. 16 (WTF::GMainLoopSource::finishVoidCallback): Deleted. 17 (WTF::GMainLoopSource::voidCallback): Deleted. 18 (WTF::GMainLoopSource::prepareBoolCallback): Deleted. 19 * wtf/glib/GMainLoopSource.h: 20 (WTF::GMainLoopSource::Context::operator=): Deleted. 21 1 22 2015-11-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 23 -
trunk/Source/WTF/wtf/glib/GMainLoopSource.cpp
r191880 r191881 55 55 m_status = Ready; 56 56 57 g_cancellable_cancel(m_context.socketCancellable.get());58 59 57 if (!m_context.source) 60 58 return; … … 85 83 adoptGRef(g_idle_source_new()), 86 84 nullptr, // cancellable 87 nullptr, // socketCancellable88 85 WTF::move(function), 89 86 nullptr, // boolCallback 90 nullptr, // socketCallback91 87 WTF::move(destroyFunction) 92 88 }; … … 102 98 adoptGRef(g_idle_source_new()), 103 99 nullptr, // cancellable 104 nullptr, // socketCancellable105 100 nullptr, // voidCallback 106 101 WTF::move(function), 107 nullptr, // socketCallback108 102 WTF::move(destroyFunction) 109 103 }; 110 104 scheduleIdleSource(name, reinterpret_cast<GSourceFunc>(boolSourceCallback), priority, context); 111 }112 113 void GMainLoopSource::schedule(const char* name, std::function<bool (GIOCondition)>&& function, GSocket* socket, GIOCondition condition, std::function<void ()>&& destroyFunction, GMainContext* context)114 {115 cancel();116 117 ASSERT(!m_context.source);118 GCancellable* socketCancellable = g_cancellable_new();119 m_context = {120 adoptGRef(g_socket_create_source(socket, condition, socketCancellable)),121 nullptr, // cancellable122 adoptGRef(socketCancellable),123 nullptr, // voidCallback124 nullptr, // boolCallback125 WTF::move(function),126 WTF::move(destroyFunction)127 };128 129 ASSERT(m_status == Ready);130 m_status = Scheduled;131 g_source_set_name(m_context.source.get(), name);132 g_source_set_callback(m_context.source.get(), reinterpret_cast<GSourceFunc>(socketSourceCallback), this, nullptr);133 g_source_attach(m_context.source.get(), context);134 105 } 135 106 … … 154 125 adoptGRef(g_timeout_source_new(delay.count())), 155 126 nullptr, // cancellable 156 nullptr, // socketCancellable157 127 WTF::move(function), 158 128 nullptr, // boolCallback 159 nullptr, // socketCallback160 129 WTF::move(destroyFunction) 161 130 }; … … 171 140 adoptGRef(g_timeout_source_new(delay.count())), 172 141 nullptr, // cancellable 173 nullptr, // socketCancellable174 142 nullptr, // voidCallback 175 143 WTF::move(function), 176 nullptr, // socketCallback177 144 WTF::move(destroyFunction) 178 145 }; … … 188 155 adoptGRef(g_timeout_source_new_seconds(delay.count())), 189 156 nullptr, // cancellable 190 nullptr, // socketCancellable191 157 WTF::move(function), 192 158 nullptr, // boolCallback 193 nullptr, // socketCallback194 159 WTF::move(destroyFunction) 195 160 }; … … 205 170 adoptGRef(g_timeout_source_new_seconds(delay.count())), 206 171 nullptr, // cancellable 207 nullptr, // socketCancellable208 172 nullptr, // voidCallback 209 173 WTF::move(function), 210 nullptr, // socketCallback211 174 WTF::move(destroyFunction) 212 175 }; … … 251 214 adoptGRef(createMicrosecondsTimeoutSource(delay.count())), 252 215 nullptr, // cancellable 253 nullptr, // socketCancellable254 216 WTF::move(function), 255 217 nullptr, // boolCallback 256 nullptr, // socketCallback257 218 WTF::move(destroyFunction) 258 219 }; … … 268 229 adoptGRef(createMicrosecondsTimeoutSource(delay.count())), 269 230 nullptr, // cancellable 270 nullptr, // socketCancellable271 231 nullptr, // voidCallback 272 232 WTF::move(function), 273 nullptr, // socketCallback274 233 WTF::move(destroyFunction) 275 234 }; … … 352 311 } 353 312 354 bool GMainLoopSource::socketCallback(GIOCondition condition)355 {356 if (!m_context.source)357 return Stop;358 359 Context context;360 context = WTF::move(m_context);361 362 ASSERT(context.socketCallback);363 ASSERT(m_status == Scheduled || m_status == Dispatching);364 m_status = Dispatching;365 366 if (g_cancellable_is_cancelled(context.socketCancellable.get())) {367 context.destroySource();368 return Stop;369 }370 371 bool retval = context.socketCallback(condition);372 373 if (m_status != Ready && !m_context.source) {374 // m_status should reflect whether the GMainLoopSource has been rescheduled during dispatch.375 ASSERT((!m_context.source && m_status == Dispatching) || m_status == Scheduled);376 if (retval && !m_context.source)377 m_context = WTF::move(context);378 else if (!retval)379 m_status = Ready;380 }381 382 if (context.source)383 context.destroySource();384 385 return retval;386 }387 388 313 gboolean GMainLoopSource::voidSourceCallback(GMainLoopSource* source) 389 314 { … … 395 320 { 396 321 return source->boolCallback() == Continue; 397 }398 399 gboolean GMainLoopSource::socketSourceCallback(GSocket*, GIOCondition condition, GMainLoopSource* source)400 {401 return source->socketCallback(condition) == Continue;402 322 } 403 323 -
trunk/Source/WTF/wtf/glib/GMainLoopSource.h
r191880 r191881 34 34 #include <wtf/glib/GRefPtr.h> 35 35 36 typedef struct _GSocket GSocket;37 38 36 namespace WTF { 39 37 … … 61 59 WTF_EXPORT_PRIVATE virtual void cancel(); 62 60 63 WTF_EXPORT_PRIVATE void schedule(const char* name, std::function<bool(GIOCondition)>&&, GSocket*, GIOCondition, std::function<void()>&& destroyFunction = nullptr, GMainContext* = nullptr);64 65 61 protected: 66 62 enum Status { Ready, Scheduled, Dispatching }; … … 72 68 source = WTF::move(c.source); 73 69 cancellable = WTF::move(c.cancellable); 74 socketCancellable = WTF::move(c.socketCancellable);75 70 voidCallback = WTF::move(c.voidCallback); 76 71 boolCallback = WTF::move(c.boolCallback); 77 socketCallback = WTF::move(c.socketCallback);78 72 destroyCallback = WTF::move(c.destroyCallback); 79 73 return *this; … … 84 78 GRefPtr<GSource> source; 85 79 GRefPtr<GCancellable> cancellable; 86 GRefPtr<GCancellable> socketCancellable;87 80 std::function<void ()> voidCallback; 88 81 std::function<bool ()> boolCallback; 89 std::function<bool (GIOCondition)> socketCallback;90 82 std::function<void ()> destroyCallback; 91 83 }; … … 102 94 void scheduleIdleSource(const char* name, GSourceFunc, int priority, GMainContext*); 103 95 void scheduleTimeoutSource(const char* name, GSourceFunc, int priority, GMainContext*); 104 bool socketCallback(GIOCondition);105 96 106 97 static gboolean voidSourceCallback(GMainLoopSource*); 107 98 static gboolean boolSourceCallback(GMainLoopSource*); 108 static gboolean socketSourceCallback(GSocket*, GIOCondition, GMainLoopSource*);109 99 110 100 protected: -
trunk/Source/WebKit2/ChangeLog
r191878 r191881 1 2015-11-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GLIB] Remove support for GSocket main loop sources from GMainLoopSource 4 https://bugs.webkit.org/show_bug.cgi?id=150772 5 6 Reviewed by Žan Doberšek. 7 8 Add GSocketMonitor class to be used by Connection to monitor the 9 availability of the socket file descriptor instead of using a 10 GMainLoopSource. 11 12 * Platform/IPC/Connection.h: 13 * Platform/IPC/glib/GSocketMonitor.cpp: Added. 14 (IPC::GSocketMonitor::~GSocketMonitor): 15 (IPC::GSocketMonitor::socketSourceCallback): 16 (IPC::GSocketMonitor::start): 17 (IPC::GSocketMonitor::stop): 18 * Platform/IPC/glib/GSocketMonitor.h: Added. 19 * Platform/IPC/unix/ConnectionUnix.cpp: 20 (IPC::Connection::platformInvalidate): 21 (IPC::Connection::open): 22 * PlatformGTK.cmake: 23 1 24 2015-11-01 Carlos Garcia Campos <cgarcia@igalia.com> 2 25 -
trunk/Source/WebKit2/Platform/IPC/Connection.h
r191856 r191881 54 54 55 55 #if PLATFORM(GTK) 56 #include <wtf/glib/GMainLoopSource.h>56 #include "GSocketMonitor.h" 57 57 #endif 58 58 … … 338 338 int m_socketDescriptor; 339 339 #if PLATFORM(GTK) 340 G MainLoopSource m_socketEventSource;340 GSocketMonitor m_socketMonitor; 341 341 #endif 342 342 #elif OS(DARWIN) -
trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
r191878 r191881 149 149 150 150 #if PLATFORM(GTK) 151 m_socket EventSource.cancel();151 m_socketMonitor.stop(); 152 152 #elif PLATFORM(EFL) 153 153 m_connectionQueue->unregisterSocketEventHandler(m_socketDescriptor); … … 378 378 #if PLATFORM(GTK) 379 379 GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(m_socketDescriptor, nullptr)); 380 m_socket EventSource.schedule("[WebKit] Connection::SocketEventHandler", [protectedThis] (GIOCondition condition){380 m_socketMonitor.start(socket.get(), G_IO_IN, m_connectionQueue->runLoop(), [protectedThis] (GIOCondition condition) -> gboolean { 381 381 if (condition & G_IO_HUP || condition & G_IO_ERR || condition & G_IO_NVAL) { 382 382 protectedThis->connectionDidClose(); 383 return G MainLoopSource::Stop;383 return G_SOURCE_REMOVE; 384 384 } 385 385 386 386 if (condition & G_IO_IN) { 387 387 protectedThis->readyReadHandler(); 388 return G MainLoopSource::Continue;388 return G_SOURCE_CONTINUE; 389 389 } 390 390 391 391 ASSERT_NOT_REACHED(); 392 return G MainLoopSource::Stop;393 } , socket.get(), G_IO_IN, nullptr, m_connectionQueue->runLoop().mainContext());392 return G_SOURCE_REMOVE; 393 }); 394 394 #elif PLATFORM(EFL) 395 395 m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, -
trunk/Source/WebKit2/PlatformGTK.cmake
r191686 r191881 36 36 NetworkProcess/soup/RemoteNetworkingContextSoup.cpp 37 37 38 Platform/IPC/glib/GSocketMonitor.cpp 38 39 Platform/IPC/unix/AttachmentUnix.cpp 39 40 Platform/IPC/unix/ConnectionUnix.cpp … … 493 494 "${WEBKIT2_DIR}/NetworkProcess/gtk" 494 495 "${WEBKIT2_DIR}/NetworkProcess/unix" 496 "${WEBKIT2_DIR}/Platform/IPC/glib" 495 497 "${WEBKIT2_DIR}/Shared/API/c/gtk" 496 498 "${WEBKIT2_DIR}/Shared/Network/CustomProtocols/soup" … … 711 713 Platform/IPC/StringReference.cpp 712 714 715 Platform/IPC/glib/GSocketMonitor.cpp 713 716 Platform/IPC/unix/AttachmentUnix.cpp 714 717 Platform/IPC/unix/ConnectionUnix.cpp -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r191453 r191881 66 66 #include <memory> 67 67 #include <wtf/HashMap.h> 68 #include <wtf/glib/GMainLoopSource.h> 68 69 #include <wtf/glib/GRefPtr.h> 69 70 #include <wtf/text/CString.h>
Note: See TracChangeset
for help on using the changeset viewer.