⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185839 in webkit


Ignore:
Timestamp:
Jun 22, 2015, 12:52:51 PM (11 years ago)
Author:
andersca@apple.com
Message:

Remove m_clientRunLoop from IPC::Connection
https://bugs.webkit.org/show_bug.cgi?id=146212

Reviewed by Sam Weinig.

We only ever create connections whose messages are dispatched to the main run loop, so we can
vastly simplify the code by only allowing messages to be dispatched there.

  • DatabaseProcess/DatabaseToWebProcessConnection.cpp:

(WebKit::DatabaseToWebProcessConnection::DatabaseToWebProcessConnection):

  • NetworkProcess/NetworkConnectionToWebProcess.cpp:

(WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess):

  • Platform/IPC/Connection.cpp:

(IPC::Connection::createServerConnection):
(IPC::Connection::createClientConnection):
(IPC::Connection::Connection):
(IPC::Connection::addWorkQueueMessageReceiver):
(IPC::Connection::removeWorkQueueMessageReceiver):
(IPC::Connection::waitForMessage):
(IPC::Connection::sendSyncMessage):
(IPC::Connection::sendSyncMessageFromSecondaryThread):
(IPC::Connection::processIncomingMessage):
(IPC::Connection::connectionDidClose):
(IPC::Connection::dispatchDidReceiveInvalidMessage):
(IPC::Connection::enqueueIncomingMessage):
(IPC::Connection::wakeUpRunLoop):

  • Platform/IPC/Connection.h:
  • Platform/IPC/mac/ConnectionMac.mm:

(IPC::Connection::receiveSourceEventHandler):

  • PluginProcess/WebProcessConnection.cpp:

(WebKit::WebProcessConnection::WebProcessConnection):

  • Shared/ChildProcess.cpp:

(WebKit::ChildProcess::initialize):

  • Shared/ChildProcessProxy.cpp:

(WebKit::ChildProcessProxy::didFinishLaunching):

  • UIProcess/Plugins/PluginProcessProxy.cpp:

(WebKit::PluginProcessProxy::didFinishLaunching):

  • WebProcess/Databases/WebToDatabaseProcessConnection.cpp:

(WebKit::WebToDatabaseProcessConnection::WebToDatabaseProcessConnection):

  • WebProcess/Network/NetworkProcessConnection.cpp:

(WebKit::NetworkProcessConnection::NetworkProcessConnection):

  • WebProcess/Plugins/PluginProcessConnection.cpp:

(WebKit::PluginProcessConnection::PluginProcessConnection):

  • WebProcess/WebPage/WebInspector.cpp:

(WebKit::WebInspector::createInspectorPage):

  • WebProcess/WebPage/WebInspectorUI.cpp:

(WebKit::WebInspectorUI::establishConnection):

Location:
trunk/Source/WebKit2
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r185837 r185839  
     12015-06-22  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove m_clientRunLoop from IPC::Connection
     4        https://bugs.webkit.org/show_bug.cgi?id=146212
     5
     6        Reviewed by Sam Weinig.
     7
     8        We only ever create connections whose messages are dispatched to the main run loop, so we can
     9        vastly simplify the code by only allowing messages to be dispatched there.
     10
     11        * DatabaseProcess/DatabaseToWebProcessConnection.cpp:
     12        (WebKit::DatabaseToWebProcessConnection::DatabaseToWebProcessConnection):
     13        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     14        (WebKit::NetworkConnectionToWebProcess::NetworkConnectionToWebProcess):
     15        * Platform/IPC/Connection.cpp:
     16        (IPC::Connection::createServerConnection):
     17        (IPC::Connection::createClientConnection):
     18        (IPC::Connection::Connection):
     19        (IPC::Connection::addWorkQueueMessageReceiver):
     20        (IPC::Connection::removeWorkQueueMessageReceiver):
     21        (IPC::Connection::waitForMessage):
     22        (IPC::Connection::sendSyncMessage):
     23        (IPC::Connection::sendSyncMessageFromSecondaryThread):
     24        (IPC::Connection::processIncomingMessage):
     25        (IPC::Connection::connectionDidClose):
     26        (IPC::Connection::dispatchDidReceiveInvalidMessage):
     27        (IPC::Connection::enqueueIncomingMessage):
     28        (IPC::Connection::wakeUpRunLoop):
     29        * Platform/IPC/Connection.h:
     30        * Platform/IPC/mac/ConnectionMac.mm:
     31        (IPC::Connection::receiveSourceEventHandler):
     32        * PluginProcess/WebProcessConnection.cpp:
     33        (WebKit::WebProcessConnection::WebProcessConnection):
     34        * Shared/ChildProcess.cpp:
     35        (WebKit::ChildProcess::initialize):
     36        * Shared/ChildProcessProxy.cpp:
     37        (WebKit::ChildProcessProxy::didFinishLaunching):
     38        * UIProcess/Plugins/PluginProcessProxy.cpp:
     39        (WebKit::PluginProcessProxy::didFinishLaunching):
     40        * WebProcess/Databases/WebToDatabaseProcessConnection.cpp:
     41        (WebKit::WebToDatabaseProcessConnection::WebToDatabaseProcessConnection):
     42        * WebProcess/Network/NetworkProcessConnection.cpp:
     43        (WebKit::NetworkProcessConnection::NetworkProcessConnection):
     44        * WebProcess/Plugins/PluginProcessConnection.cpp:
     45        (WebKit::PluginProcessConnection::PluginProcessConnection):
     46        * WebProcess/WebPage/WebInspector.cpp:
     47        (WebKit::WebInspector::createInspectorPage):
     48        * WebProcess/WebPage/WebInspectorUI.cpp:
     49        (WebKit::WebInspectorUI::establishConnection):
     50
    1512015-06-22  Anders Carlsson  <andersca@apple.com>
    252
  • trunk/Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.cpp

    r185637 r185839  
    4343DatabaseToWebProcessConnection::DatabaseToWebProcessConnection(IPC::Connection::Identifier connectionIdentifier)
    4444{
    45     m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this, RunLoop::main());
     45    m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    4646    m_connection->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true);
    4747    m_connection->open();
  • trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r185637 r185839  
    5555NetworkConnectionToWebProcess::NetworkConnectionToWebProcess(IPC::Connection::Identifier connectionIdentifier)
    5656{
    57     m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this, RunLoop::main());
     57    m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    5858    m_connection->open();
    5959}
  • trunk/Source/WebKit2/Platform/IPC/Connection.cpp

    r182980 r185839  
    226226}
    227227
    228 Ref<Connection> Connection::createServerConnection(Identifier identifier, Client& client, RunLoop& clientRunLoop)
    229 {
    230     return adoptRef(*new Connection(identifier, true, client, clientRunLoop));
    231 }
    232 
    233 Ref<Connection> Connection::createClientConnection(Identifier identifier, Client& client, RunLoop& clientRunLoop)
    234 {
    235     return adoptRef(*new Connection(identifier, false, client, clientRunLoop));
    236 }
    237 
    238 Connection::Connection(Identifier identifier, bool isServer, Client& client, RunLoop& clientRunLoop)
     228Ref<Connection> Connection::createServerConnection(Identifier identifier, Client& client)
     229{
     230    return adoptRef(*new Connection(identifier, true, client));
     231}
     232
     233Ref<Connection> Connection::createClientConnection(Identifier identifier, Client& client)
     234{
     235    return adoptRef(*new Connection(identifier, false, client));
     236}
     237
     238Connection::Connection(Identifier identifier, bool isServer, Client& client)
    239239    : m_client(&client)
    240240    , m_isServer(isServer)
     
    245245    , m_isConnected(false)
    246246    , m_connectionQueue(WorkQueue::create("com.apple.IPC.ReceiveQueue"))
    247     , m_clientRunLoop(clientRunLoop)
    248247    , m_inSendSyncCount(0)
    249248    , m_inDispatchMessageCount(0)
     
    251250    , m_didReceiveInvalidMessage(false)
    252251    , m_waitingForMessage(nullptr)
    253     , m_syncMessageState(SyncMessageState::getOrCreate(clientRunLoop))
     252    , m_syncMessageState(SyncMessageState::getOrCreate(RunLoop::main()))
    254253    , m_shouldWaitForSyncReplies(true)
    255254{
    256     ASSERT(m_client);
     255    ASSERT(RunLoop::isMain());
    257256
    258257    platformInitialize(identifier);
     
    285284void Connection::addWorkQueueMessageReceiver(StringReference messageReceiverName, WorkQueue* workQueue, WorkQueueMessageReceiver* workQueueMessageReceiver)
    286285{
    287     ASSERT(&RunLoop::current() == &m_clientRunLoop);
     286    ASSERT(RunLoop::isMain());
    288287
    289288    RefPtr<Connection> connection(this);
     
    297296void Connection::removeWorkQueueMessageReceiver(StringReference messageReceiverName)
    298297{
    299     ASSERT(&RunLoop::current() == &m_clientRunLoop);
     298    ASSERT(RunLoop::isMain());
    300299
    301300    RefPtr<Connection> connection(this);
     
    417416std::unique_ptr<MessageDecoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout, unsigned waitForMessageFlags)
    418417{
    419     ASSERT(&m_clientRunLoop == &RunLoop::current());
     418    ASSERT(RunLoop::isMain());
    420419
    421420    bool hasIncomingSynchronousMessage = false;
     
    481480std::unique_ptr<MessageDecoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, std::chrono::milliseconds timeout, unsigned syncSendFlags)
    482481{
    483     if (&RunLoop::current() != &m_clientRunLoop) {
     482    if (!RunLoop::isMain()) {
    484483        // No flags are supported for synchronous messages sent from secondary threads.
    485484        ASSERT(!syncSendFlags);
     
    534533std::unique_ptr<MessageDecoder> Connection::sendSyncMessageFromSecondaryThread(uint64_t syncRequestID, std::unique_ptr<MessageEncoder> encoder, std::chrono::milliseconds timeout)
    535534{
    536     ASSERT(&RunLoop::current() != &m_clientRunLoop);
     535    ASSERT(!RunLoop::isMain());
    537536
    538537    if (!isValid())
     
    679678        StringCapture capturedMessageName(messageName.isEmpty() ? "<unknown message>" : String(messageName.data(), messageName.size()));
    680679
    681         m_clientRunLoop.dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] {
     680        RunLoop::main().dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] {
    682681            protectedThis->dispatchDidReceiveInvalidMessage(capturedMessageReceiverName.string().utf8(), capturedMessageName.string().utf8());
    683682        });
     
    767766
    768767    RefPtr<Connection> connection(this);
    769     m_clientRunLoop.dispatch([connection] {
     768    RunLoop::main().dispatch([connection] {
    770769        // If the connection has been explicitly invalidated before dispatchConnectionDidClose was called,
    771770        // then the client will be null here.
     
    837836void Connection::dispatchDidReceiveInvalidMessage(const CString& messageReceiverNameString, const CString& messageNameString)
    838837{
    839     ASSERT(&RunLoop::current() == &m_clientRunLoop);
     838    ASSERT(RunLoop::isMain());
    840839
    841840    if (!m_client)
     
    861860
    862861    RefPtr<Connection> protectedThis(this);
    863     m_clientRunLoop.dispatch([protectedThis] {
     862    RunLoop::main().dispatch([protectedThis] {
    864863        protectedThis->dispatchOneMessage();
    865864    });
     
    924923void Connection::wakeUpRunLoop()
    925924{
    926     m_clientRunLoop.wakeUp();
     925    RunLoop::main().wakeUp();
    927926}
    928927
  • trunk/Source/WebKit2/Platform/IPC/Connection.h

    r183176 r185839  
    5252#endif
    5353
    54 namespace WTF {
    55 class RunLoop;
    56 }
    57 
    5854namespace IPC {
    5955
     
    145141#endif
    146142
    147     static Ref<Connection> createServerConnection(Identifier, Client&, WTF::RunLoop& clientRunLoop);
    148     static Ref<Connection> createClientConnection(Identifier, Client&, WTF::RunLoop& clientRunLoop);
     143    static Ref<Connection> createServerConnection(Identifier, Client&);
     144    static Ref<Connection> createClientConnection(Identifier, Client&);
    149145    ~Connection();
    150146
     
    206202
    207203private:
    208     Connection(Identifier, bool isServer, Client&, WTF::RunLoop& clientRunLoop);
     204    Connection(Identifier, bool isServer, Client&);
    209205    void platformInitialize(Identifier);
    210206    void platformInvalidate();
     
    250246    bool m_isConnected;
    251247    Ref<WorkQueue> m_connectionQueue;
    252     WTF::RunLoop& m_clientRunLoop;
    253248
    254249    HashMap<StringReference, std::pair<RefPtr<WorkQueue>, RefPtr<WorkQueueMessageReceiver>>> m_workQueueMessageReceivers;
  • trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm

    r182086 r185839  
    515515            StringReference messageName = decoder->messageName();
    516516            StringCapture capturedMessageName(String(messageName.data(), messageName.size()));
    517             m_clientRunLoop.dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] {
     517            RunLoop::main().dispatch([protectedThis, capturedMessageReceiverName, capturedMessageName] {
    518518                protectedThis->dispatchDidReceiveInvalidMessage(capturedMessageReceiverName.string().utf8(), capturedMessageName.string().utf8());
    519519            });
  • trunk/Source/WebKit2/PluginProcess/WebProcessConnection.cpp

    r185637 r185839  
    6161WebProcessConnection::WebProcessConnection(IPC::Connection::Identifier connectionIdentifier)
    6262{
    63     m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this, RunLoop::main());
     63    m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    6464    m_npRemoteObjectMap = NPRemoteObjectMap::create(m_connection.get());
    6565
  • trunk/Source/WebKit2/Shared/ChildProcess.cpp

    r184503 r185839  
    6868    initializeSandbox(parameters, sandboxParameters);
    6969   
    70     m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, *this, RunLoop::main());
     70    m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, *this);
    7171    m_connection->setDidCloseOnConnectionWorkQueueCallback(didCloseOnConnectionWorkQueue);
    7272    initializeConnection(m_connection.get());
  • trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp

    r184514 r185839  
    135135    ASSERT(!m_connection);
    136136
    137     m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this, RunLoop::main());
     137    m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    138138#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
    139139    m_connection->setShouldCloseConnectionOnMachExceptions();
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp

    r185463 r185839  
    214214    }
    215215
    216     m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this, RunLoop::main());
     216    m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    217217#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
    218218    m_connection->setShouldCloseConnectionOnMachExceptions();
  • trunk/Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp

    r179409 r185839  
    4242WebToDatabaseProcessConnection::WebToDatabaseProcessConnection(IPC::Connection::Identifier connectionIdentifier)
    4343{
    44     m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this, RunLoop::main());
     44    m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this);
    4545    m_connection->open();
    4646}
  • trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp

    r179489 r185839  
    4646NetworkProcessConnection::NetworkProcessConnection(IPC::Connection::Identifier connectionIdentifier)
    4747{
    48     m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this, RunLoop::main());
     48    m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this);
    4949    m_connection->open();
    5050}
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp

    r177924 r185839  
    4949    , m_audioHardwareActivity(WebCore::AudioHardwareActivityType::Unknown)
    5050{
    51     m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this, RunLoop::main());
     51    m_connection = IPC::Connection::createClientConnection(connectionIdentifier, *this);
    5252
    5353    m_npRemoteObjectMap = NPRemoteObjectMap::create(m_connection.get());
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r185111 r185839  
    9393#endif
    9494
    95     m_frontendConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this, RunLoop::main());
     95    m_frontendConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
    9696    m_frontendConnection->open();
    9797
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.cpp

    r184291 r185839  
    8282    m_page->corePage()->inspectorController().setInspectorFrontendClient(this);
    8383
    84     m_backendConnection = IPC::Connection::createClientConnection(connectionIdentifier, *this, RunLoop::main());
     84    m_backendConnection = IPC::Connection::createClientConnection(connectionIdentifier, *this);
    8585    m_backendConnection->open();
    8686}
Note: See TracChangeset for help on using the changeset viewer.