Title: [139516] trunk/Source/WebKit2
Revision
139516
Author
[email protected]
Date
2013-01-11 16:08:30 -0800 (Fri, 11 Jan 2013)

Log Message

        [WK2] Network process unblocks all waiting threads when any sync reply arrives
        https://bugs.webkit.org/show_bug.cgi?id=106713

        Reviewed by Brady Eidson.

        Switch to sending sync CoreIPC messages, which is now possible.

        * NetworkProcess/NetworkConnectionToWebProcess.h:
        * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::didClose):
        We no longer have response maps.

        * NetworkProcess/NetworkResourceLoader.cpp:
        (WebKit::NetworkResourceLoader::willSendRequest): Just send a sync message.
        (WebKit::NetworkResourceLoader::canAuthenticateAgainstProtectionSpace): Ditto.
        (WebKit::NetworkResourceLoader::didReceiveDataArray): Added an unrelated assertion.

        * NetworkProcess/NetworkResourceLoader.h:
        * NetworkProcess/NetworkResourceLoader.messages.in:
        Removed no longer used reply messages and their handlers.

        * Shared/BlockingResponseMap.h: Removed a bool version, which was not perfectly
        safe, and only used in NetworkProcess.
        (BlockingResponseMap::didReceiveResponse): Updated a still valid FIXME to not refer
        to network process.
        (BlockingResponseMap::cancel): Ditto.

        * WebProcess/Network/NetworkProcessConnection.h:
        * WebProcess/Network/NetworkProcessConnection.cpp:
        (WebKit::NetworkProcessConnection::didReceiveSyncMessage):
        Plumbing to handle sync messages.

        * WebProcess/Network/WebResourceLoader.cpp:
        (WebKit::WebResourceLoader::willSendRequest):
        (WebKit::WebResourceLoader::canAuthenticateAgainstProtectionSpace):
        * WebProcess/Network/WebResourceLoader.h:
        * WebProcess/Network/WebResourceLoader.messages.in:
        Updated (simplified) sync messages and their handlers.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (139515 => 139516)


--- trunk/Source/WebKit2/ChangeLog	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-12 00:08:30 UTC (rev 139516)
@@ -1,5 +1,45 @@
 2013-01-11  Alexey Proskuryakov  <[email protected]>
 
+        [WK2] Network process unblocks all waiting threads when any sync reply arrives
+        https://bugs.webkit.org/show_bug.cgi?id=106713
+
+        Reviewed by Brady Eidson.
+
+        Switch to sending sync CoreIPC messages, which is now possible.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::didClose):
+        We no longer have response maps.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::willSendRequest): Just send a sync message.
+        (WebKit::NetworkResourceLoader::canAuthenticateAgainstProtectionSpace): Ditto.
+        (WebKit::NetworkResourceLoader::didReceiveDataArray): Added an unrelated assertion.
+
+        * NetworkProcess/NetworkResourceLoader.h:
+        * NetworkProcess/NetworkResourceLoader.messages.in:
+        Removed no longer used reply messages and their handlers.
+
+        * Shared/BlockingResponseMap.h: Removed a bool version, which was not perfectly
+        safe, and only used in NetworkProcess.
+        (BlockingResponseMap::didReceiveResponse): Updated a still valid FIXME to not refer
+        to network process.
+        (BlockingResponseMap::cancel): Ditto.
+
+        * WebProcess/Network/NetworkProcessConnection.h:
+        * WebProcess/Network/NetworkProcessConnection.cpp:
+        (WebKit::NetworkProcessConnection::didReceiveSyncMessage):
+        Plumbing to handle sync messages.
+
+        * WebProcess/Network/WebResourceLoader.cpp:
+        (WebKit::WebResourceLoader::willSendRequest):
+        (WebKit::WebResourceLoader::canAuthenticateAgainstProtectionSpace):
+        * WebProcess/Network/WebResourceLoader.h:
+        * WebProcess/Network/WebResourceLoader.messages.in:
+        Updated (simplified) sync messages and their handlers.
+
+2013-01-11  Alexey Proskuryakov  <[email protected]>
+
         [WK2] Make it possible to send sync messages from secondary threads
         https://bugs.webkit.org/show_bug.cgi?id=106708
 

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (139515 => 139516)


--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp	2013-01-12 00:08:30 UTC (rev 139516)
@@ -103,10 +103,6 @@
     
     NetworkProcess::shared().removeNetworkConnectionToWebProcess(this);
 
-    // Unblock waiting threads.
-    m_willSendRequestResponseMap.cancel();
-    m_canAuthenticateAgainstProtectionSpaceResponseMap.cancel();
-
     Vector<NetworkConnectionToWebProcessObserver*> observers;
     copyToVector(m_observers, observers);
     for (size_t i = 0; i < observers.size(); ++i)

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (139515 => 139516)


--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h	2013-01-12 00:08:30 UTC (rev 139516)
@@ -62,9 +62,6 @@
 
     bool isSerialLoadingEnabled() const { return m_serialLoadingEnabled; }
 
-    BlockingResponseMap<WebCore::ResourceRequest*>& willSendRequestResponseMap() { return m_willSendRequestResponseMap; }
-    BlockingBoolResponseMap& canAuthenticateAgainstProtectionSpaceResponseMap() { return m_canAuthenticateAgainstProtectionSpaceResponseMap; }
-
 private:
     NetworkConnectionToWebProcess(CoreIPC::Connection::Identifier);
 
@@ -96,9 +93,6 @@
     
     HashSet<NetworkConnectionToWebProcessObserver*> m_observers;
 
-    BlockingResponseMap<WebCore::ResourceRequest*> m_willSendRequestResponseMap;
-    BlockingBoolResponseMap m_canAuthenticateAgainstProtectionSpaceResponseMap;
-
     bool m_serialLoadingEnabled;
 };
 

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (139515 => 139516)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp	2013-01-12 00:08:30 UTC (rev 139516)
@@ -182,35 +182,16 @@
     scheduleStopOnMainThread();
 }
 
-static uint64_t generateWillSendRequestID()
-{
-    static int64_t uniqueWillSendRequestID;
-    return atomicIncrement(&uniqueWillSendRequestID);
-}
-
 void NetworkResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
 {
     // We only expect to get the willSendRequest callback from ResourceHandle as the result of a redirect.
     ASSERT(!redirectResponse.isNull());
+    ASSERT(!isMainThread());
 
-    uint64_t requestID = generateWillSendRequestID();
-
-    if (!send(Messages::WebResourceLoader::WillSendRequest(requestID, request, redirectResponse))) {
+    if (!sendSync(Messages::WebResourceLoader::WillSendRequest(request, redirectResponse), Messages::WebResourceLoader::WillSendRequest::Reply(request)))
         request = ResourceRequest();
-        return;
-    }
-
-    OwnPtr<ResourceRequest> newRequest = m_connection->willSendRequestResponseMap().waitForResponse(requestID);
-    request = newRequest ? *newRequest : ResourceRequest();
-
-    RunLoop::main()->dispatch(WTF::bind(&NetworkResourceLoadScheduler::receivedRedirect, &NetworkProcess::shared().networkResourceLoadScheduler(), m_identifier, request.url()));
 }
 
-void NetworkResourceLoader::willSendRequestHandled(uint64_t requestID, const WebCore::ResourceRequest& newRequest)
-{
-    m_connection->willSendRequestResponseMap().didReceiveResponse(requestID, adoptPtr(new ResourceRequest(newRequest)));
-}
-
 // FIXME (NetworkProcess): Many of the following ResourceHandleClient methods definitely need implementations. A few will not.
 // Once we know what they are they can be removed.
 
@@ -302,26 +283,16 @@
 }
 
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-static uint64_t generateCanAuthenticateAgainstProtectionSpaceID()
-{
-    static int64_t uniqueCanAuthenticateAgainstProtectionSpaceID;
-    return atomicIncrement(&uniqueCanAuthenticateAgainstProtectionSpaceID);
-}
-
 bool NetworkResourceLoader::canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace& protectionSpace)
 {
-    uint64_t requestID = generateCanAuthenticateAgainstProtectionSpaceID();
+    ASSERT(!isMainThread());
 
-    if (!send(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(requestID, protectionSpace)))
+    bool result;
+    if (!sendSync(Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace(protectionSpace), Messages::WebResourceLoader::CanAuthenticateAgainstProtectionSpace::Reply(result)))
         return false;
 
-    return m_connection->canAuthenticateAgainstProtectionSpaceResponseMap().waitForResponse(requestID);
+    return result;
 }
-
-void NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceHandled(uint64_t requestID, bool canAuthenticate)
-{
-    m_connection->canAuthenticateAgainstProtectionSpaceResponseMap().didReceiveResponse(requestID, canAuthenticate);
-}
 #endif
 
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
@@ -333,6 +304,7 @@
 
 void NetworkResourceLoader::didReceiveDataArray(WebCore::ResourceHandle*, CFArrayRef)
 {
+    ASSERT_NOT_REACHED();
     notImplemented();
 }
 #endif

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (139515 => 139516)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h	2013-01-12 00:08:30 UTC (rev 139516)
@@ -110,8 +110,6 @@
 private:
     NetworkResourceLoader(const NetworkResourceLoadParameters&, ResourceLoadIdentifier, NetworkConnectionToWebProcess*);
 
-    void willSendRequestHandled(uint64_t requestID, const WebCore::ResourceRequest&);
-    void canAuthenticateAgainstProtectionSpaceHandled(uint64_t requestID, bool canAuthenticate);
     void receivedAuthenticationCredential(const WebCore::AuthenticationChallenge&, const WebCore::Credential&);
     void receivedRequestToContinueWithoutAuthenticationCredential(const WebCore::AuthenticationChallenge&);
     void receivedAuthenticationCancellation(const WebCore::AuthenticationChallenge&);

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.messages.in (139515 => 139516)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.messages.in	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.messages.in	2013-01-12 00:08:30 UTC (rev 139516)
@@ -23,9 +23,6 @@
 #if ENABLE(NETWORK_PROCESS)
 
 messages -> NetworkResourceLoader {
-    WillSendRequestHandled(uint64_t requestID, WebCore::ResourceRequest newRequest)
-    CanAuthenticateAgainstProtectionSpaceHandled(uint64_t requestID, bool canAuthenticate)
-    
     ReceivedAuthenticationCredential(WebCore::AuthenticationChallenge challenge, WebCore::Credential credential)
     ReceivedRequestToContinueWithoutAuthenticationCredential(WebCore::AuthenticationChallenge challenge)
     ReceivedAuthenticationCancellation(WebCore::AuthenticationChallenge challenge)

Modified: trunk/Source/WebKit2/Shared/BlockingResponseMap.h (139515 => 139516)


--- trunk/Source/WebKit2/Shared/BlockingResponseMap.h	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/Shared/BlockingResponseMap.h	2013-01-12 00:08:30 UTC (rev 139516)
@@ -61,7 +61,7 @@
         ASSERT(!m_responses.contains(requestID));
 
         m_responses.set(requestID, response);
-        // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.
+        // FIXME: Waking up all threads is quite inefficient.
         m_condition.broadcast();
     }
 
@@ -69,7 +69,7 @@
     {
         m_canceled = true;
 
-        // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.
+        // FIXME: Waking up all threads is quite inefficient.
         m_condition.broadcast();
     }
 
@@ -81,58 +81,4 @@
     bool m_canceled;
 };
 
-class BlockingBoolResponseMap {
-WTF_MAKE_NONCOPYABLE(BlockingBoolResponseMap);
-public:
-    BlockingBoolResponseMap() : m_canceled(false) { }
-    ~BlockingBoolResponseMap() { ASSERT(m_responses.isEmpty()); }
-
-    bool waitForResponse(uint64_t requestID)
-    {
-        while (true) {
-            MutexLocker locker(m_mutex);
-
-            // FIXME: Differentiate between canceled wait and a negative response.
-            if (m_canceled)
-                return false;
-
-            HashMap<uint64_t, bool>::iterator iter = m_responses.find(requestID);
-            if (iter != m_responses.end()) {
-                bool result = iter->value;
-                m_responses.remove(iter);
-                return result;
-            }
-
-            m_condition.wait(m_mutex);
-        }
-
-        return false;
-    }
-
-    void didReceiveResponse(uint64_t requestID, bool response)
-    {
-        MutexLocker locker(m_mutex);
-        ASSERT(!m_responses.contains(requestID));
-
-        m_responses.set(requestID, response);
-        // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.
-        m_condition.broadcast();
-    }
-
-    void cancel()
-    {
-        m_canceled = true;
-
-        // FIXME (NetworkProcess): <rdar://problem/12886430>: Waking up all threads is quite inefficient.
-        m_condition.broadcast();
-    }
-
-private:
-    Mutex m_mutex;
-    ThreadCondition m_condition;
-
-    HashMap<uint64_t, bool> m_responses;
-    bool m_canceled;
-};
-
 #endif // BlockingResponseMap_h

Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp (139515 => 139516)


--- trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp	2013-01-12 00:08:30 UTC (rev 139516)
@@ -62,6 +62,18 @@
     ASSERT_NOT_REACHED();
 }
 
+void NetworkProcessConnection::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder)
+{
+    if (messageID.is<CoreIPC::MessageClassWebResourceLoader>()) {
+        if (WebResourceLoader* webResourceLoader = WebProcess::shared().webResourceLoadScheduler().webResourceLoaderForIdentifier(decoder.destinationID()))
+            webResourceLoader->didReceiveSyncWebResourceLoaderMessage(connection, messageID, decoder, replyEncoder);
+        
+        return;
+    }
+
+    ASSERT_NOT_REACHED();
+}
+
 void NetworkProcessConnection::didClose(CoreIPC::Connection*)
 {
     // The NetworkProcess probably crashed.

Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h (139515 => 139516)


--- trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h	2013-01-12 00:08:30 UTC (rev 139516)
@@ -61,6 +61,7 @@
 
     // CoreIPC::Connection::Client
     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
+    virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
     virtual void didClose(CoreIPC::Connection*);
     virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName) OVERRIDE;
 

Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (139515 => 139516)


--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp	2013-01-12 00:08:30 UTC (rev 139516)
@@ -68,14 +68,12 @@
     return m_coreLoader->identifier();
 }
 
-void WebResourceLoader::willSendRequest(uint64_t requestID, const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse)
+void WebResourceLoader::willSendRequest(const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse, ResourceRequest& newRequest)
 {
     LOG(Network, "(WebProcess) WebResourceLoader::willSendRequest to '%s'", proposedRequest.url().string().utf8().data());
     
-    ResourceRequest newRequest = proposedRequest;
+    newRequest = proposedRequest;
     m_coreLoader->willSendRequest(newRequest, redirectResponse);
-
-    send(Messages::NetworkResourceLoader::WillSendRequestHandled(requestID, newRequest));
 }
 
 void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResponse& response, const PlatformCertificateInfo& certificateInfo)
@@ -122,9 +120,9 @@
     m_coreLoader->didFinishLoading(finishTime);
 }
 
-void WebResourceLoader::canAuthenticateAgainstProtectionSpace(uint64_t requestID, const ProtectionSpace& protectionSpace)
+void WebResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace, bool& result)
 {
-    send(Messages::NetworkResourceLoader::CanAuthenticateAgainstProtectionSpaceHandled(requestID, m_coreLoader->canAuthenticateAgainstProtectionSpace(protectionSpace)));
+    result = m_coreLoader->canAuthenticateAgainstProtectionSpace(protectionSpace);
 }
 
 void WebResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)

Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h (139515 => 139516)


--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h	2013-01-12 00:08:30 UTC (rev 139516)
@@ -66,6 +66,7 @@
     uint64_t destinationID() const;
 
     void didReceiveWebResourceLoaderMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
+    void didReceiveSyncWebResourceLoaderMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
 
     using RefCounted<WebResourceLoader>::ref;
     using RefCounted<WebResourceLoader>::deref;
@@ -79,14 +80,14 @@
 private:
     WebResourceLoader(PassRefPtr<WebCore::ResourceLoader>);
 
-    void willSendRequest(uint64_t requestID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
+    void willSendRequest(const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::ResourceRequest& newRequest);
     void didReceiveResponseWithCertificateInfo(const WebCore::ResourceResponse&, const PlatformCertificateInfo&);
     void didReceiveData(const CoreIPC::DataReference&, int64_t encodedDataLength, bool allAtOnce);
     void didFinishResourceLoad(double finishTime);
     void didFailResourceLoad(const WebCore::ResourceError&);
     void didReceiveResource(const ShareableResource::Handle&, double finishTime);
 
-    void canAuthenticateAgainstProtectionSpace(uint64_t requestID, const WebCore::ProtectionSpace&);
+    void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&, bool& result);
     void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
     void didCancelAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
 

Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in (139515 => 139516)


--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in	2013-01-12 00:04:23 UTC (rev 139515)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in	2013-01-12 00:08:30 UTC (rev 139516)
@@ -23,13 +23,13 @@
 messages -> WebResourceLoader {
 
     // FIXME (NetworkProcess): We'll need much more granularity for response messages.
-    WillSendRequest(uint64_t requestID, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)
+    WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse) -> (WebCore::ResourceRequest newRequest)
     DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebKit::PlatformCertificateInfo certificateInfo)
     DidReceiveData(CoreIPC::DataReference data, int64_t encodedDataLength, bool allAtOnce)
     DidFinishResourceLoad(double finishTime)
     DidFailResourceLoad(WebCore::ResourceError error)
     
-    CanAuthenticateAgainstProtectionSpace(uint64_t requestID, WebCore::ProtectionSpace protectionSpace)
+    CanAuthenticateAgainstProtectionSpace(WebCore::ProtectionSpace protectionSpace) -> (bool response)
     DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge)
     DidCancelAuthenticationChallenge(WebCore::AuthenticationChallenge challenge)
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to