Changeset 148922 in webkit


Ignore:
Timestamp:
Apr 22, 2013 3:56:19 PM (11 years ago)
Author:
andersca@apple.com
Message:

Web process should decide when to continue main resource loads
https://bugs.webkit.org/show_bug.cgi?id=114995

Reviewed by Sam Weinig.

Main resource loads can be converted to downloads, so we need the ability to let the web process decide when
to continue loading after a response has been received.

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::didReceiveResponseAsync):
For non-main resources, just call continueDidReceiveResponse directly; there's no need to ping-pong to the web process in that case.

(WebKit::NetworkResourceLoader::continueDidReceiveResponse):
Just call ResourceHandle::continueDidReceiveResponse.

  • NetworkProcess/NetworkResourceLoader.messages.in:

Add ContinueDidReceiveResponse message.

  • NetworkProcess/SchedulableLoader.cpp:

(WebKit::SchedulableLoader::SchedulableLoader):
Initialize m_isLoadingMainResource.

  • NetworkProcess/SchedulableLoader.h:

(WebKit::SchedulableLoader::isLoadingMainResource):
Add getter.

(SchedulableLoader):
Move m_shouldClearReferrerOnHTTPSToHTTPRedirect next to the rest of the booleans.

  • Shared/Network/NetworkResourceLoadParameters.cpp:

(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):

  • Shared/Network/NetworkResourceLoadParameters.h:

(NetworkResourceLoadParameters):
Add isMainResource flag.

  • WebProcess/Network/WebResourceLoadScheduler.cpp:

(WebKit::WebResourceLoadScheduler::scheduleSubresourceLoad):
Pass the cached resource to scheduleLoad.

(WebKit::WebResourceLoadScheduler::schedulePluginStreamLoad):
Pass null to scheduleLoad.

(WebKit::WebResourceLoadScheduler::scheduleLoad):
Initialize isMainResource.

  • WebProcess/Network/WebResourceLoader.cpp:

(WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo):
If this is a main resource load, send back a ContinueDidReceiveResponse message.

Location:
trunk/Source/WebKit2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r148919 r148922  
     12013-04-22  Anders Carlsson  <andersca@apple.com>
     2
     3        Web process should decide when to continue main resource loads
     4        https://bugs.webkit.org/show_bug.cgi?id=114995
     5
     6        Reviewed by Sam Weinig.
     7
     8        Main resource loads can be converted to downloads, so we need the ability to let the web process decide when
     9        to continue loading after a response has been received.
     10
     11        * NetworkProcess/NetworkResourceLoader.cpp:
     12        (WebKit::NetworkResourceLoader::didReceiveResponseAsync):
     13        For non-main resources, just call continueDidReceiveResponse directly; there's no need to ping-pong to the web process in that case.
     14
     15        (WebKit::NetworkResourceLoader::continueDidReceiveResponse):
     16        Just call ResourceHandle::continueDidReceiveResponse.
     17
     18        * NetworkProcess/NetworkResourceLoader.messages.in:
     19        Add ContinueDidReceiveResponse message.
     20       
     21        * NetworkProcess/SchedulableLoader.cpp:
     22        (WebKit::SchedulableLoader::SchedulableLoader):
     23        Initialize m_isLoadingMainResource.
     24
     25        * NetworkProcess/SchedulableLoader.h:
     26        (WebKit::SchedulableLoader::isLoadingMainResource):
     27        Add getter.
     28
     29        (SchedulableLoader):
     30        Move m_shouldClearReferrerOnHTTPSToHTTPRedirect next to the rest of the booleans.
     31
     32        * Shared/Network/NetworkResourceLoadParameters.cpp:
     33        (WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
     34        (WebKit::NetworkResourceLoadParameters::encode):
     35        (WebKit::NetworkResourceLoadParameters::decode):
     36        * Shared/Network/NetworkResourceLoadParameters.h:
     37        (NetworkResourceLoadParameters):
     38        Add isMainResource flag.
     39
     40        * WebProcess/Network/WebResourceLoadScheduler.cpp:
     41        (WebKit::WebResourceLoadScheduler::scheduleSubresourceLoad):
     42        Pass the cached resource to scheduleLoad.
     43
     44        (WebKit::WebResourceLoadScheduler::schedulePluginStreamLoad):
     45        Pass null to scheduleLoad.
     46
     47        (WebKit::WebResourceLoadScheduler::scheduleLoad):
     48        Initialize isMainResource.
     49
     50        * WebProcess/Network/WebResourceLoader.cpp:
     51        (WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo):
     52        If this is a main resource load, send back a ContinueDidReceiveResponse message.
     53
    1542013-04-22  Tim Horton  <timothy_horton@apple.com>
    255
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp

    r147952 r148922  
    206206    sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(response, PlatformCertificateInfo(response)));
    207207
    208     m_handle->continueDidReceiveResponse();
     208    if (!isLoadingMainResource()) {
     209        // For main resources, the web process is responsible for sending back a NetworkResourceLoader::ContinueDidReceiveResponse message.
     210        m_handle->continueDidReceiveResponse();
     211        return;
     212    }
    209213}
    210214
     
    280284}
    281285
     286void NetworkResourceLoader::continueDidReceiveResponse()
     287{
     288    m_handle->continueDidReceiveResponse();
     289}
     290
    282291void NetworkResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
    283292{
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h

    r147952 r148922  
    107107
    108108    void continueWillSendRequest(const WebCore::ResourceRequest& newRequest);
     109    void continueDidReceiveResponse();
    109110#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
    110111    void continueCanAuthenticateAgainstProtectionSpace(bool);
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.messages.in

    r146929 r148922  
    2424
    2525    ContinueWillSendRequest(WebCore::ResourceRequest request)
     26    ContinueDidReceiveResponse()
    2627    ContinueCanAuthenticateAgainstProtectionSpace(bool canAuthenticate)
    2728}
  • trunk/Source/WebKit2/NetworkProcess/SchedulableLoader.cpp

    r148913 r148922  
    4747    , m_allowStoredCredentials(parameters.allowStoredCredentials)
    4848    , m_inPrivateBrowsingMode(parameters.inPrivateBrowsingMode)
     49    , m_shouldClearReferrerOnHTTPSToHTTPRedirect(parameters.shouldClearReferrerOnHTTPSToHTTPRedirect)
     50    , m_isLoadingMainResource(parameters.isMainResource)
    4951    , m_connection(connection)
    50     , m_shouldClearReferrerOnHTTPSToHTTPRedirect(parameters.shouldClearReferrerOnHTTPSToHTTPRedirect)
    5152{
    5253    for (size_t i = 0, count = parameters.requestBodySandboxExtensions.size(); i < count; ++i) {
  • trunk/Source/WebKit2/NetworkProcess/SchedulableLoader.h

    r145485 r148922  
    5353    WebCore::StoredCredentials allowStoredCredentials() const { return m_allowStoredCredentials; }
    5454    bool inPrivateBrowsingMode() const { return m_inPrivateBrowsingMode; }
     55    bool isLoadingMainResource() const { return m_isLoadingMainResource; }
    5556
    5657    NetworkConnectionToWebProcess* connectionToWebProcess() const { return m_connection.get(); }
     
    8182    WebCore::StoredCredentials m_allowStoredCredentials;
    8283    bool m_inPrivateBrowsingMode;
     84    bool m_shouldClearReferrerOnHTTPSToHTTPRedirect;
     85    bool m_isLoadingMainResource;
    8386
    8487    Vector<RefPtr<SandboxExtension> > m_requestBodySandboxExtensions;
     
    8891   
    8992    RefPtr<HostRecord> m_hostRecord;
    90 
    91     bool m_shouldClearReferrerOnHTTPSToHTTPRedirect;
    9293};
    9394
  • trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp

    r148913 r148922  
    4747    , inPrivateBrowsingMode(false)
    4848    , shouldClearReferrerOnHTTPSToHTTPRedirect(true)
     49    , isMainResource(false)
    4950{
    5051}
     
    9495    encoder << inPrivateBrowsingMode;
    9596    encoder << shouldClearReferrerOnHTTPSToHTTPRedirect;
     97    encoder << isMainResource;
    9698}
    9799
     
    140142    if (!decoder.decode(result.shouldClearReferrerOnHTTPSToHTTPRedirect))
    141143        return false;
     144    if (!decoder.decode(result.isMainResource))
     145        return false;
    142146
    143147    return true;
  • trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h

    r148913 r148922  
    6161    bool inPrivateBrowsingMode;
    6262    bool shouldClearReferrerOnHTTPSToHTTPRedirect;
     63    bool isMainResource;
    6364};
    6465
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp

    r148913 r148922  
    3838#include "WebProcess.h"
    3939#include "WebResourceLoader.h"
     40#include <WebCore/CachedResource.h>
    4041#include <WebCore/Document.h>
    4142#include <WebCore/DocumentLoader.h>
     
    7071    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, resource, request, options);
    7172    if (loader)
    72         scheduleLoad(loader.get(), priority, frame->document()->referrerPolicy() == ReferrerPolicyDefault);
     73        scheduleLoad(loader.get(), resource, priority, frame->document()->referrerPolicy() == ReferrerPolicyDefault);
    7374    return loader.release();
    7475}
     
    7879    RefPtr<NetscapePlugInStreamLoader> loader = NetscapePlugInStreamLoader::create(frame, client, request);
    7980    if (loader)
    80         scheduleLoad(loader.get(), ResourceLoadPriorityLow, frame->document()->referrerPolicy() == ReferrerPolicyDefault);
     81        scheduleLoad(loader.get(), 0, ResourceLoadPriorityLow, frame->document()->referrerPolicy() == ReferrerPolicyDefault);
    8182    return loader.release();
    8283}
    8384
    84 void WebResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, ResourceLoadPriority priority, bool shouldClearReferrerOnHTTPSToHTTPRedirect)
     85void WebResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, CachedResource* resource, ResourceLoadPriority priority, bool shouldClearReferrerOnHTTPSToHTTPRedirect)
    8586{
    8687    ASSERT(resourceLoader);
     
    118119    loadParameters.inPrivateBrowsingMode = privateBrowsingEnabled;
    119120    loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect;
     121    loadParameters.isMainResource = resource && resource->type() == CachedResource::MainResource;
    120122
    121123    if (!WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ScheduleResourceLoad(loadParameters), 0)) {
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.h

    r141981 r148922  
    6464
    6565private:
    66     void scheduleLoad(WebCore::ResourceLoader*, WebCore::ResourceLoadPriority, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
     66    void scheduleLoad(WebCore::ResourceLoader*, WebCore::CachedResource*, WebCore::ResourceLoadPriority, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
    6767    void scheduleInternallyFailedLoad(WebCore::ResourceLoader*);
    6868    void internallyFailedLoadTimerFired();
  • trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp

    r147568 r148922  
    3737#include "WebErrors.h"
    3838#include "WebProcess.h"
     39#include <WebCore/DocumentLoader.h>
    3940#include <WebCore/ResourceBuffer.h>
    4041#include <WebCore/ResourceError.h>
     
    105106    responseCopy.setCertificateChain(certificateInfo.certificateChain());
    106107    m_coreLoader->didReceiveResponse(responseCopy);
     108
     109    if (m_coreLoader == m_coreLoader->documentLoader()->mainResourceLoader())
     110        send(Messages::NetworkResourceLoader::ContinueDidReceiveResponse());
    107111}
    108112
Note: See TracChangeset for help on using the changeset viewer.