Recursion handling cancelled authentication challenges in NetworkProcess
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 20:21:19 +0000 (20:21 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 20:21:19 +0000 (20:21 +0000)
<rdar://problem/13024541> and https://bugs.webkit.org/show_bug.cgi?id=107702

Reviewed by Alexey Proskuryakov.

Source/WebCore:

* WebCore.exp.in:

Source/WebKit2:

This turned in to both a bug fix with authentication and a minimal refactoring of NetworkResourceLoader.

- Rename ::stop to ::resourceHandleStopped
- Move all cleanup code to ::resourceHandleStopped
- Schedule a resourceHandleStopped call when an authentication cancellation occurs
- Tell the WebResourceLoader to cancel when an authentication cancellation occurs

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::~NetworkResourceLoader):
(WebKit::NetworkResourceLoader::start):
(WebKit::NetworkResourceLoader::performStops):
(WebKit::NetworkResourceLoader::resourceHandleStopped):
(WebKit::NetworkResourceLoader::didFail):
(WebKit::NetworkResourceLoader::receivedAuthenticationCancellation):
* NetworkProcess/NetworkResourceLoader.h:

* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::cancelResourceLoader):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Network/WebResourceLoader.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140572 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
Source/WebKit2/WebProcess/Network/WebResourceLoader.h
Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in

index dbbb3a0..585e2a0 100644 (file)
@@ -1,3 +1,12 @@
+2013-01-23  Brady Eidson  <beidson@apple.com>
+
+        Recursion handling cancelled authentication challenges in NetworkProcess
+        <rdar://problem/13024541> and https://bugs.webkit.org/show_bug.cgi?id=107702
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebCore.exp.in:
+
 2013-01-23  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=107628
index b3bacc2..84cb4f9 100644 (file)
@@ -302,6 +302,7 @@ __ZN7WebCore14ResourceHandle25loadResourceSynchronouslyEPNS_17NetworkingContextE
 __ZN7WebCore14ResourceHandle26synchronousLoadRunLoopModeEv
 __ZN7WebCore14ResourceHandle6createEPNS_17NetworkingContextERKNS_15ResourceRequestEPNS_20ResourceHandleClientEbb
 __ZN7WebCore14ResourceLoader14cancelledErrorEv
+__ZN7WebCore14ResourceLoader6cancelEv
 __ZN7WebCore14SchemeRegistry24registerURLSchemeAsLocalERKN3WTF6StringE
 __ZN7WebCore14SchemeRegistry25registerURLSchemeAsSecureERKN3WTF6StringE
 __ZN7WebCore14SchemeRegistry27registerURLSchemeAsNoAccessERKN3WTF6StringE
index 67304f4..32343e8 100644 (file)
@@ -1,3 +1,31 @@
+2013-01-23  Brady Eidson  <beidson@apple.com>
+
+        Recursion handling cancelled authentication challenges in NetworkProcess
+        <rdar://problem/13024541> and https://bugs.webkit.org/show_bug.cgi?id=107702
+
+        Reviewed by Alexey Proskuryakov.
+
+        This turned in to both a bug fix with authentication and a minimal refactoring of NetworkResourceLoader.
+
+        - Rename ::stop to ::resourceHandleStopped
+        - Move all cleanup code to ::resourceHandleStopped
+        - Schedule a resourceHandleStopped call when an authentication cancellation occurs
+        - Tell the WebResourceLoader to cancel when an authentication cancellation occurs
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::~NetworkResourceLoader):
+        (WebKit::NetworkResourceLoader::start):
+        (WebKit::NetworkResourceLoader::performStops):
+        (WebKit::NetworkResourceLoader::resourceHandleStopped):
+        (WebKit::NetworkResourceLoader::didFail):
+        (WebKit::NetworkResourceLoader::receivedAuthenticationCancellation):
+        * NetworkProcess/NetworkResourceLoader.h:
+
+        * WebProcess/Network/WebResourceLoader.cpp:
+        (WebKit::WebResourceLoader::cancelResourceLoader):
+        * WebProcess/Network/WebResourceLoader.h:
+        * WebProcess/Network/WebResourceLoader.messages.in:
+
 2013-01-23  Christophe Dumez  <christophe.dumez@intel.com>
 
         [EFL][WK2] Use C API inside ewk_cookie_manager
index 5f50ef8..0eac5c0 100644 (file)
@@ -56,6 +56,7 @@ NetworkResourceLoader::NetworkResourceLoader(const NetworkResourceLoadParameters
 NetworkResourceLoader::~NetworkResourceLoader()
 {
     ASSERT(isMainThread());
+    ASSERT(!m_handle);
 }
 
 CoreIPC::Connection* NetworkResourceLoader::connection() const
@@ -72,7 +73,7 @@ void NetworkResourceLoader::start()
 {
     ASSERT(isMainThread());
 
-    // Explicit ref() balanced by a deref() in NetworkResourceLoader::stop()
+    // Explicit ref() balanced by a deref() in NetworkResourceLoader::resourceHandleStopped()
     ref();
     
     // FIXME (NetworkProcess): Create RemoteNetworkingContext with actual settings.
@@ -120,16 +121,21 @@ void NetworkResourceLoader::performStops(void*)
     }
     
     for (size_t i = 0; i < requests.size(); ++i)
-        requests[i]->stop();
+        requests[i]->resourceHandleStopped();
 }
 
-void NetworkResourceLoader::stop()
+void NetworkResourceLoader::resourceHandleStopped()
 {
     ASSERT(isMainThread());
 
-    // Remove this load identifier soon so we can start more network requests.
+    if (FormData* formData = loadParameters().request().httpBody())
+        formData->removeGeneratedFilesIfNeeded();
+
+    m_handle = 0;
+
+    // Tell the scheduler about this finished loader soon so it can start more network requests.
     NetworkProcess::shared().networkResourceLoadScheduler().scheduleRemoveLoader(this);
-    
+
     // Explicit deref() balanced by a ref() in NetworkResourceLoader::start()
     // This might cause the NetworkResourceLoader to be destroyed and therefore we do it last.
     deref();
@@ -164,8 +170,6 @@ void NetworkResourceLoader::didFail(ResourceHandle*, const ResourceError& error)
 {
     // FIXME (NetworkProcess): For the memory cache we'll need to update the finished status of the cached resource here.
     // Such bookkeeping will need to be thread safe, as this callback is happening on a background thread.
-    if (FormData* formData = loadParameters().request().httpBody())
-        formData->removeGeneratedFilesIfNeeded();
     send(Messages::WebResourceLoader::DidFailResourceLoad(error));
     scheduleStopOnMainThread();
 }
@@ -272,8 +276,11 @@ void NetworkResourceLoader::receivedAuthenticationCancellation(const Authenticat
     if (m_currentAuthenticationChallenge->identifier() != challenge.identifier())
         return;
 
-    m_currentAuthenticationChallenge->authenticationClient()->receivedCancellation(*m_currentAuthenticationChallenge);
+    m_handle->cancel();
     m_currentAuthenticationChallenge.clear();
+
+    send(Messages::WebResourceLoader::CancelResourceLoader());
+    scheduleStopOnMainThread();
 }
 
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
index ebf38eb..c34a7d0 100644 (file)
@@ -109,7 +109,7 @@ private:
     void scheduleStopOnMainThread();
     static void performStops(void*);
 
-    void stop();
+    void resourceHandleStopped();
 
     RefPtr<RemoteNetworkingContext> m_networkingContext;
     RefPtr<WebCore::ResourceHandle> m_handle;    
index 15e0396..668b463 100644 (file)
@@ -68,6 +68,11 @@ uint64_t WebResourceLoader::destinationID() const
     return m_coreLoader->identifier();
 }
 
+void WebResourceLoader::cancelResourceLoader()
+{
+    m_coreLoader->cancel();
+}
+
 void WebResourceLoader::willSendRequest(const ResourceRequest& proposedRequest, const ResourceResponse& redirectResponse, ResourceRequest& newRequest)
 {
     LOG(Network, "(WebProcess) WebResourceLoader::willSendRequest to '%s'", proposedRequest.url().string().utf8().data());
index 41c3326..78a29fc 100644 (file)
@@ -80,6 +80,8 @@ public:
 private:
     WebResourceLoader(PassRefPtr<WebCore::ResourceLoader>);
 
+    void cancelResourceLoader();
+
     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);
index d5c0959..da08b4a 100644 (file)
@@ -22,6 +22,8 @@
 
 messages -> WebResourceLoader {
 
+    CancelResourceLoader()
+
     // FIXME (NetworkProcess): We'll need much more granularity for response messages.
     WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse) -> (WebCore::ResourceRequest newRequest)
     DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebKit::PlatformCertificateInfo certificateInfo)