Changeset 141684 in webkit


Ignore:
Timestamp:
Feb 1, 2013 11:40:08 PM (11 years ago)
Author:
simonjam@chromium.org
Message:

Add didChangePriority() to ResourceHandle
https://bugs.webkit.org/show_bug.cgi?id=107995

Reviewed by Darin Fisher.

Source/Platform:

  • chromium/public/WebURLLoader.h:

(WebKit):
(WebURLLoader):
(WebKit::WebURLLoader::didChangePriority): Added.

Source/WebCore:

For PLT, it's important that preloads remain a lower priority than parser requested resources.
This can lead to a 5% improvement.

The plan is to use this plumbing to expose the desired behavior. This patch simply allows a
resource's priority to change and have it propagate to the network layer. An upcoming patch will
lower the priority of preloads and then increase the priority when the parser officially requests
it.

No new tests. No visible change, because priority doesn't change yet.

  • loader/cache/CachedResource.cpp:

(WebCore):
(WebCore::CachedResource::setLoadPriority):

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::requestResource): Allow loads to modify priority.

  • loader/cache/CachedResourceRequest.h:

(WebCore::CachedResourceRequest::setPriority): Notify when priority changes.

  • platform/network/ResourceHandle.cpp:

(WebCore::ResourceHandle::didChangePriority): Added.
(WebCore):

  • platform/network/ResourceHandle.h:

(ResourceHandle):

  • platform/network/chromium/ResourceHandle.cpp:

(WebCore::ResourceHandleInternal::didChangePriority):
(WebCore):
(WebCore::ResourceHandle::didChangePriority):

  • platform/network/chromium/ResourceHandleInternal.h:

(ResourceHandleInternal):

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r141652 r141684  
     12013-02-01  James Simonsen  <simonjam@chromium.org>
     2
     3        Add didChangePriority() to ResourceHandle
     4        https://bugs.webkit.org/show_bug.cgi?id=107995
     5
     6        Reviewed by Darin Fisher.
     7
     8        * chromium/public/WebURLLoader.h:
     9        (WebKit):
     10        (WebURLLoader):
     11        (WebKit::WebURLLoader::didChangePriority): Added.
     12
    1132013-02-01  Kevin Ellis  <kevers@chromium.org>
    214
  • trunk/Source/Platform/chromium/public/WebURLLoader.h

    r112501 r141684  
    3333
    3434#include "WebCommon.h"
     35#include "WebURLRequest.h"
    3536
    3637namespace WebKit {
     
    3839class WebData;
    3940class WebURLLoaderClient;
    40 class WebURLRequest;
    4141class WebURLResponse;
    4242struct WebURLError;
     
    6565    // Suspends/resumes an asynchronous load.
    6666    virtual void setDefersLoading(bool) = 0;
     67
     68    // Notifies the loader that the priority of a WebURLRequest has changed from
     69    // its previous value. For example, a preload request starts with low
     70    // priority, but may increase when the resource is needed for rendering.
     71    virtual void didChangePriority(WebURLRequest::Priority newPriority) { }
    6772};
    6873
  • trunk/Source/WebCore/ChangeLog

    r141679 r141684  
     12013-02-01  James Simonsen  <simonjam@chromium.org>
     2
     3        Add didChangePriority() to ResourceHandle
     4        https://bugs.webkit.org/show_bug.cgi?id=107995
     5
     6        Reviewed by Darin Fisher.
     7
     8        For PLT, it's important that preloads remain a lower priority than parser requested resources.
     9        This can lead to a 5% improvement.
     10
     11        The plan is to use this plumbing to expose the desired behavior. This patch simply allows a
     12        resource's priority to change and have it propagate to the network layer. An upcoming patch will
     13        lower the priority of preloads and then increase the priority when the parser officially requests
     14        it.
     15
     16        No new tests. No visible change, because priority doesn't change yet.
     17
     18        * loader/cache/CachedResource.cpp:
     19        (WebCore):
     20        (WebCore::CachedResource::setLoadPriority):
     21        * loader/cache/CachedResourceLoader.cpp:
     22        (WebCore::CachedResourceLoader::requestResource): Allow loads to modify priority.
     23        * loader/cache/CachedResourceRequest.h:
     24        (WebCore::CachedResourceRequest::setPriority): Notify when priority changes.
     25        * platform/network/ResourceHandle.cpp:
     26        (WebCore::ResourceHandle::didChangePriority): Added.
     27        (WebCore):
     28        * platform/network/ResourceHandle.h:
     29        (ResourceHandle):
     30        * platform/network/chromium/ResourceHandle.cpp:
     31        (WebCore::ResourceHandleInternal::didChangePriority):
     32        (WebCore):
     33        (WebCore::ResourceHandle::didChangePriority):
     34        * platform/network/chromium/ResourceHandleInternal.h:
     35        (ResourceHandleInternal):
     36
    1372013-02-01  Roger Fong  <roger_fong@apple.com>
    238
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r141570 r141684  
    864864    return sizeof(CachedResource) + m_response.memoryUsage() + kAverageClientsHashMapSize + m_resourceRequest.url().string().length() * 2;
    865865}
    866    
    867 void CachedResource::setLoadPriority(ResourceLoadPriority loadPriority) 
    868 { 
     866
     867void CachedResource::setLoadPriority(ResourceLoadPriority loadPriority)
     868{
    869869    if (loadPriority == ResourceLoadPriorityUnresolved)
     870        loadPriority = defaultPriorityForResourceType(type());
     871    if (loadPriority == m_loadPriority)
    870872        return;
    871873    m_loadPriority = loadPriority;
     874    if (m_loader && m_loader->handle())
     875        m_loader->handle()->didChangePriority(loadPriority);
    872876}
    873877
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r141570 r141684  
    466466        return 0;
    467467
    468     resource->setLoadPriority(request.priority());
     468    if (!request.forPreload() || policy != Use)
     469        resource->setLoadPriority(request.priority());
     470
    469471    if ((policy != Use || resource->stillNeedsLoad()) && CachedResourceRequest::NoDefer == request.defer()) {
    470472        resource->load(this, request.options());
  • trunk/Source/WebCore/loader/cache/CachedResourceRequest.h

    r135452 r141684  
    5252    const ResourceLoaderOptions& options() const { return m_options; }
    5353    void setOptions(const ResourceLoaderOptions& options) { m_options = options; }
     54    void setPriority(ResourceLoadPriority priority) { m_priority = priority; }
    5455    ResourceLoadPriority priority() const { return m_priority; }
    5556    bool forPreload() const { return m_forPreload; }
  • trunk/Source/WebCore/platform/network/ResourceHandle.cpp

    r138413 r141684  
    186186}
    187187
     188void ResourceHandle::didChangePriority(ResourceLoadPriority)
     189{
     190    // Optionally implemented by platform.
     191}
     192
    188193void ResourceHandle::cacheMetadata(const ResourceResponse&, const Vector<char>&)
    189194{
  • trunk/Source/WebCore/platform/network/ResourceHandle.h

    r140836 r141684  
    3030#include "HTTPHeaderMap.h"
    3131#include "ResourceHandleTypes.h"
     32#include "ResourceLoadPriority.h"
    3233#include <wtf/OwnPtr.h>
    3334#include <wtf/RefCounted.h>
     
    191192    void pauseLoad(bool);
    192193#endif
    193      
     194
     195    void didChangePriority(ResourceLoadPriority);
     196
    194197    ResourceRequest& firstRequest();
    195198    const String& lastHTTPMethod() const;
  • trunk/Source/WebCore/platform/network/chromium/ResourceHandle.cpp

    r138962 r141684  
    8989}
    9090
     91void ResourceHandleInternal::didChangePriority(WebURLRequest::Priority newPriority)
     92{
     93    m_loader->didChangePriority(newPriority);
     94}
     95
    9196bool ResourceHandleInternal::allowStoredCredentials() const
    9297{
     
    277282}
    278283
     284void ResourceHandle::didChangePriority(ResourceLoadPriority newPriority)
     285{
     286    d->didChangePriority(static_cast<WebURLRequest::Priority>(newPriority));
     287}
     288
    279289// static
    280290void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vector<char>& data)
  • trunk/Source/WebCore/platform/network/chromium/ResourceHandleInternal.h

    r112780 r141684  
    3636#include <public/WebURLLoader.h>
    3737#include <public/WebURLLoaderClient.h>
     38#include <public/WebURLRequest.h>
    3839
    3940namespace WebCore {
     
    5253    void setDefersLoading(bool);
    5354    bool allowStoredCredentials() const;
     55    void didChangePriority(WebKit::WebURLRequest::Priority);
    5456
    5557    // WebURLLoaderClient methods:
Note: See TracChangeset for help on using the changeset viewer.