Changeset 141136 in webkit


Ignore:
Timestamp:
Jan 29, 2013, 12:06:19 PM (13 years ago)
Author:
Nate Chapin
Message:

.: Enable reuse of cached main resources
https://bugs.webkit.org/show_bug.cgi?id=105667

Reviewed by Adam Barth.

  • Source/autotools/symbols.filter: Expose MemoryCache::resourceForURL().

Source/WebCore: Enable reuse of cached main resources
https://bugs.webkit.org/show_bug.cgi?id=105667

Reviewed by Adam Barth.

Test: http/tests/cache/cached-main-resource.html

  • WebCore.exp.in:
  • dom/Document.cpp:

(WebCore::Document::hasManifest): Returns true if the <html> element has a non-empty manifest attribute.
(WebCore):

  • dom/Document.h:

(Document):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::loadedResourceFromMemoryCache): Don't send delegate callbacks for cache hit here, since

MainResourceLoader will take care of it.

  • loader/MainResourceLoader.cpp:

(WebCore::MainResourceLoader::MainResourceLoader):
(WebCore::MainResourceLoader::receivedError):
(WebCore::MainResourceLoader::willSendRequest):
(WebCore::MainResourceLoader::responseReceived): Don't try to cache loads from the application cache.
(WebCore::MainResourceLoader::didFinishLoading): Don't try to cache loads from the application cache.
(WebCore::MainResourceLoader::load): Ensure we create a resource load identifier for cache hits. Also,

ensure we correctly popualate fragment identifiers in the ResourceRequest reported to DocumentLoader.

(WebCore::MainResourceLoader::identifier):

  • loader/MainResourceLoader.h: Rename m_substituteDataLoadIdentifier to m_identifierForLoadWithoutResourceLoader

to better describe when it is used.

  • loader/cache/CachedRawResource.cpp:

(WebCore::CachedRawResource::didAddClient): Synthesize redirect notifications for cache hits if necessary.
(WebCore::CachedRawResource::willSendRequest): Note the redirects we received.
(WebCore::CachedRawResource::canReuse): Don't reuse a resource if the redirect chain included a "Cache-control: no-store".

  • loader/cache/CachedRawResource.h:

(CachedRawResource):
(RedirectPair):
(WebCore::CachedRawResource::RedirectPair::RedirectPair):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::addClientToSet): Don't return cached data for a main resource synchronously

  • loader/cache/CachedResource.h:

(WebCore::CachedResource::canReuse):
(CachedResource):

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::requestResource): Leave cahce reuse of main resources off for chromium for now.
(WebCore::CachedResourceLoader::determineRevalidationPolicy): Permit cache reuse for main resources.

  • testing/Internals.cpp:

(WebCore::Internals::isPreloaded):
(WebCore):
(WebCore::Internals::isLoadingFromMemoryCache):

  • testing/Internals.h:

(Internals):

  • testing/Internals.idl:

Source/WebKit/win: Enable reuse of cached main resources
https://bugs.webkit.org/show_bug.cgi?id=105667

Reviewed by Adam Barth.

  • WebKit.vcproj/WebKitExports.def.in: Expose some MemoryCache symbols for use in Internals.

LayoutTests: Enable reuse of cached main resources
https://bugs.webkit.org/show_bug.cgi?id=105667.

Reviewed by Adam Barth.

  • http/tests/cache/cached-main-resource-expected.txt: Added.
  • http/tests/cache/cached-main-resource.html: Added.
  • http/tests/cache/resources/cacheable-iframe.php: Added.
  • http/tests/inspector/resource-har-pages-expected.txt:
  • http/tests/loading/redirect-methods-expected.txt:
  • http/tests/misc/favicon-loads-with-images-disabled-expected.txt:
  • http/tests/misc/link-rel-icon-beforeload-expected.txt:
  • platform/chromium/TestExpectations:
Location:
trunk
Files:
3 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r141108 r141136  
     12013-01-29  Nate Chapin  <japhet@chromium.org>
     2
     3        Enable reuse of cached main resources
     4        https://bugs.webkit.org/show_bug.cgi?id=105667
     5
     6        Reviewed by Adam Barth.
     7
     8        * Source/autotools/symbols.filter: Expose MemoryCache::resourceForURL().
     9
    1102013-01-29  Laszlo Gombos  <l.gombos@samsung.com>
    211
  • trunk/LayoutTests/ChangeLog

    r141133 r141136  
     12013-01-29  Nate Chapin  <japhet@chromium.org>
     2
     3        Enable reuse of cached main resources
     4        https://bugs.webkit.org/show_bug.cgi?id=105667.
     5
     6        Reviewed by Adam Barth.
     7
     8        * http/tests/cache/cached-main-resource-expected.txt: Added.
     9        * http/tests/cache/cached-main-resource.html: Added.
     10        * http/tests/cache/resources/cacheable-iframe.php: Added.
     11        * http/tests/inspector/resource-har-pages-expected.txt:
     12        * http/tests/loading/redirect-methods-expected.txt:
     13        * http/tests/misc/favicon-loads-with-images-disabled-expected.txt:
     14        * http/tests/misc/link-rel-icon-beforeload-expected.txt:
     15        * platform/chromium/TestExpectations:
     16
    1172013-01-29  Ryosuke Niwa  <rniwa@webkit.org>
    218
  • trunk/LayoutTests/http/tests/inspector/resource-har-pages-expected.txt

    r140105 r141136  
    11Tests conversion of Inspector's resource representation into HAR format.
    22
    3 Page reloaded.
    43{
    54    0 : {
     
    2928page: page_1 url: http://127.0.0.1:8000/inspector/resources/source1.js
    3029page: page_1 url: http://127.0.0.1:8000/resources/redirect.php?url=/inspector/resources/har-pages-navigation-target.html
     30Page reloaded.
    3131
  • trunk/LayoutTests/http/tests/loading/redirect-methods-expected.txt

    r140105 r141136  
    4343frame "1" - didCancelClientRedirectForFrame
    4444frame "1" - didCommitLoadForFrame
     45http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading
    4546frame "1" - didFinishDocumentLoadForFrame
    4647frame "1" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    4748frame "1" - didHandleOnloadEventsForFrame
    4849frame "1" - didFinishLoadForFrame
    49 http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading
    5050frame "1" - didStartProvisionalLoadForFrame
    5151http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/loading/resources/redirect-methods-result.php, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method POST> redirectResponse (null)
     
    7070frame "2" - didCancelClientRedirectForFrame
    7171frame "2" - didCommitLoadForFrame
     72http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading
    7273frame "2" - didFinishDocumentLoadForFrame
    7374frame "2" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    7475frame "2" - didHandleOnloadEventsForFrame
    7576frame "2" - didFinishLoadForFrame
    76 http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading
    7777frame "2" - didStartProvisionalLoadForFrame
    7878http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/loading/resources/redirect-methods-result.php, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method POST> redirectResponse (null)
     
    9797frame "3" - didCancelClientRedirectForFrame
    9898frame "3" - didCommitLoadForFrame
     99http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading
    99100frame "3" - didFinishDocumentLoadForFrame
    100101frame "3" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-result.php
    101102frame "3" - didHandleOnloadEventsForFrame
    102103frame "3" - didFinishLoadForFrame
    103 http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading
    104104frame "3" - didStartProvisionalLoadForFrame
    105105http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/loading/resources/redirect-methods-result.php, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method POST> redirectResponse (null)
  • trunk/LayoutTests/http/tests/misc/favicon-loads-with-images-disabled-expected.txt

    r140105 r141136  
    22http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html, main document URL http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html, http method GET> redirectResponse (null)
    33http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html, http status code 200>
     4http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html - didFinishLoading
    45Radar 6973106 and https://bugs.webkit.org/show_bug.cgi?id=27896 - Favicons still load when automatic image loading is disabled.
    56This test uses DRT's resource load delegate callback mode to see if the favicon is loaded even when image loading is off.
  • trunk/LayoutTests/http/tests/misc/link-rel-icon-beforeload-expected.txt

    r140105 r141136  
    22http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, main document URL http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, http method GET> redirectResponse (null)
    33http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, http status code 200>
     4http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html - didFinishLoading
    45http://127.0.0.1:8000/favicon.ico - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/favicon.ico, main document URL http://127.0.0.1:8000/misc/link-rel-icon-beforeload.html, http method GET> redirectResponse (null)
    56This test should not show a request for the favicon dont-load-this.ico, since the beforeload handler on the favicon link returns false. Therefore, if the resource request list below shows a request for dont-load-this.ico, then this test has failed.
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r141077 r141136  
    43344334webkit.org/b/107899 fast/repaint/selection-clear.html [ ImageOnlyFailure ]
    43354335
     4336webkit.org/b/107962 http/tests/misc/favicon-loads-with-images-disabled.html [ Failure ]
     4337webkit.org/b/107962 http/tests/loading/redirect-methods.html [ Failure ]
     4338webkit.org/b/107962 http/tests/cache/cached-main-resource.html [ Failure ]
     4339
    43364340webkit.org/b/107893 [ MountainLion ] fast/exclusions/shape-inside/shape-inside-first-fit-001.html [ ImageOnlyFailure ]
    43374341
  • trunk/Source/WebCore/ChangeLog

    r141135 r141136  
     12013-01-29  Nate Chapin  <japhet@chromium.org>
     2
     3        Enable reuse of cached main resources
     4        https://bugs.webkit.org/show_bug.cgi?id=105667
     5
     6        Reviewed by Adam Barth.
     7
     8        Test: http/tests/cache/cached-main-resource.html
     9
     10        * WebCore.exp.in:
     11        * dom/Document.cpp:
     12        (WebCore::Document::hasManifest): Returns true if the <html> element has a non-empty manifest attribute.
     13        (WebCore):
     14        * dom/Document.h:
     15        (Document):
     16        * loader/FrameLoader.cpp:
     17        (WebCore::FrameLoader::loadedResourceFromMemoryCache): Don't send delegate callbacks for cache hit here, since
     18            MainResourceLoader will take care of it.
     19        * loader/MainResourceLoader.cpp:
     20        (WebCore::MainResourceLoader::MainResourceLoader):
     21        (WebCore::MainResourceLoader::receivedError):
     22        (WebCore::MainResourceLoader::willSendRequest):
     23        (WebCore::MainResourceLoader::responseReceived): Don't try to cache loads from the application cache.
     24        (WebCore::MainResourceLoader::didFinishLoading): Don't try to cache loads from the application cache.
     25        (WebCore::MainResourceLoader::load): Ensure we create a resource load identifier for cache hits. Also,
     26            ensure we correctly popualate fragment identifiers in the ResourceRequest reported to DocumentLoader.
     27        (WebCore::MainResourceLoader::identifier):
     28        * loader/MainResourceLoader.h: Rename m_substituteDataLoadIdentifier to m_identifierForLoadWithoutResourceLoader
     29            to better describe when it is used.
     30        * loader/cache/CachedRawResource.cpp:
     31        (WebCore::CachedRawResource::didAddClient): Synthesize redirect notifications for cache hits if necessary.
     32        (WebCore::CachedRawResource::willSendRequest): Note the redirects we received.
     33        (WebCore::CachedRawResource::canReuse): Don't reuse a resource if the redirect chain included a "Cache-control: no-store".
     34        * loader/cache/CachedRawResource.h:
     35        (CachedRawResource):
     36        (RedirectPair):
     37        (WebCore::CachedRawResource::RedirectPair::RedirectPair):
     38        * loader/cache/CachedResource.cpp:
     39        (WebCore::CachedResource::addClientToSet): Don't return cached data for a main resource synchronously
     40        * loader/cache/CachedResource.h:
     41        (WebCore::CachedResource::canReuse):
     42        (CachedResource):
     43        * loader/cache/CachedResourceLoader.cpp:
     44        (WebCore::CachedResourceLoader::requestResource): Leave cahce reuse of main resources off for chromium for now.
     45        (WebCore::CachedResourceLoader::determineRevalidationPolicy): Permit cache reuse for main resources.
     46        * testing/Internals.cpp:
     47        (WebCore::Internals::isPreloaded):
     48        (WebCore):
     49        (WebCore::Internals::isLoadingFromMemoryCache):
     50        * testing/Internals.h:
     51        (Internals):
     52        * testing/Internals.idl:
     53
    1542013-01-29  Min Qin  <qinmin@chromium.org>
    255
  • trunk/Source/WebCore/WebCore.exp.in

    r141012 r141136  
    146146__ZN7WebCore11MemoryCache13setCapacitiesEjjj
    147147__ZN7WebCore11MemoryCache14evictResourcesEv
     148__ZN7WebCore11MemoryCache14resourceForURLERKNS_4KURLE
    148149__ZN7WebCore11MemoryCache19getOriginsWithCacheERN3WTF7HashSetINS1_6RefPtrINS_14SecurityOriginEEENS_18SecurityOriginHashENS1_10HashTraitsIS5_EEEE
    149150__ZN7WebCore11MemoryCache25removeResourcesWithOriginEPNS_14SecurityOriginE
  • trunk/Source/WebCore/dom/Document.cpp

    r140784 r141136  
    814814}
    815815
     816bool Document::hasManifest() const
     817{
     818    return documentElement() && documentElement()->hasTagName(htmlTag) && documentElement()->hasAttribute(manifestAttr);
     819}
     820
    816821void Document::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
    817822{
  • trunk/Source/WebCore/dom/Document.h

    r140105 r141136  
    341341        return m_documentElement.get();
    342342    }
     343
     344    bool hasManifest() const;
    343345   
    344346    virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r140748 r141136  
    28972897        return;
    28982898
     2899    // Main resource delegate messages are synthesized in MainResourceLoader, so we must not send them here.
     2900    if (resource->type() == CachedResource::MainResource)
     2901        return;
     2902
    28992903    if (!page->areMemoryCacheClientCallsEnabled()) {
    29002904        InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource);
  • trunk/Source/WebCore/loader/MainResourceLoader.cpp

    r140875 r141136  
    4747#include "HistoryItem.h"
    4848#include "InspectorInstrumentation.h"
     49#include "MemoryCache.h"
    4950#include "Page.h"
    5051#include "ProgressTracker.h"
     
    7475    , m_waitingForContentPolicy(false)
    7576    , m_timeOfLastDataReceived(0.0)
    76     , m_substituteDataLoadIdentifier(0)
     77    , m_identifierForLoadWithoutResourceLoader(0)
    7778{
    7879}
     
    9495    RefPtr<Frame> protectFrame(m_documentLoader->frame());
    9596
    96     if (m_substituteDataLoadIdentifier) {
     97    if (m_identifierForLoadWithoutResourceLoader) {
    9798        ASSERT(!loader());
    98         frameLoader()->client()->dispatchDidFailLoading(documentLoader(), m_substituteDataLoadIdentifier, error);
     99        frameLoader()->client()->dispatchDidFailLoading(documentLoader(), m_identifierForLoadWithoutResourceLoader, error);
    99100    }
    100101
     
    274275        documentLoader()->applicationCacheHost()->maybeLoadMainResourceForRedirect(newRequest, m_substituteData);
    275276        if (m_substituteData.isValid())
    276             m_substituteDataLoadIdentifier = identifier();
     277            m_identifierForLoadWithoutResourceLoader = identifier();
    277278    }
    278279
     
    380381{
    381382    ASSERT_UNUSED(resource, m_resource == resource);
    382     if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r))
     383    bool willLoadFallback = documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r);
     384
     385    // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
     386    // from the application cache, ensure we don't save the result for future use.
     387    bool shouldRemoveResourceFromCache = willLoadFallback;
     388#if PLATFORM(CHROMIUM)
     389    // chromium's ApplicationCacheHost implementation always returns true for maybeLoadFallbackForMainResponse(). However, all responses loaded
     390    // from appcache will have a non-zero appCacheID().
     391    if (r.appCacheID())
     392        shouldRemoveResourceFromCache = true;
     393#endif
     394    if (shouldRemoveResourceFromCache)
     395        memoryCache()->remove(m_resource.get());
     396
     397    if (willLoadFallback)
    383398        return;
    384399
     
    523538    if (!loader()) {
    524539        frameLoader()->notifier()->dispatchDidFinishLoading(documentLoader(), identifier(), finishTime);
    525         m_substituteDataLoadIdentifier = 0;
     540        m_identifierForLoadWithoutResourceLoader = 0;
    526541    }
    527542
     
    542557    documentLoader()->timing()->setResponseEnd(finishTime ? finishTime : (m_timeOfLastDataReceived ? m_timeOfLastDataReceived : monotonicallyIncreasingTime()));
    543558    documentLoader()->finishedLoading();
     559
     560    // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache
     561    // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
     562    if (Frame* frame = documentLoader()->frame()) {
     563        if (m_resource && frame->document()->hasManifest())
     564            memoryCache()->remove(m_resource.get());
     565    }
    544566
    545567    dl->applicationCacheHost()->finishedLoadingMainResource();
     
    645667
    646668    if (m_substituteData.isValid()) {
    647         m_substituteDataLoadIdentifier = m_documentLoader->frame()->page()->progress()->createUniqueIdentifier();
    648         frameLoader()->notifier()->assignIdentifierToInitialRequest(m_substituteDataLoadIdentifier, documentLoader(), request);
    649         frameLoader()->notifier()->dispatchWillSendRequest(documentLoader(), m_substituteDataLoadIdentifier, request, ResourceResponse());
     669        m_identifierForLoadWithoutResourceLoader = m_documentLoader->frame()->page()->progress()->createUniqueIdentifier();
     670        frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, documentLoader(), request);
     671        frameLoader()->notifier()->dispatchWillSendRequest(documentLoader(), m_identifierForLoadWithoutResourceLoader, request, ResourceResponse());
    650672        handleSubstituteDataLoadSoon(request);
    651673        return;
     
    660682        return;
    661683    }
     684    if (!loader()) {
     685        m_identifierForLoadWithoutResourceLoader = m_documentLoader->frame()->page()->progress()->createUniqueIdentifier();
     686        frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, documentLoader(), request);
     687        frameLoader()->notifier()->dispatchWillSendRequest(documentLoader(), m_identifierForLoadWithoutResourceLoader, request, ResourceResponse());
     688    }
    662689    m_resource->addClient(this);
    663690
    664     // We need to wait until after requestMainResource() is called to setRequest(), because there are a bunch of headers set when
    665     // the underlying ResourceLoader is created, and DocumentLoader::m_request needs to include those. However, the cache will
    666     // strip the fragment identifier (which DocumentLoader::m_request should also include), so add that back in.
     691    // A bunch of headers are set when the underlying ResourceLoader is created, and DocumentLoader::m_request needs to include those.
    667692    if (loader())
    668693        request = loader()->originalRequest();
     694    // If there was a fragment identifier on initialRequest, the cache will have stripped it. DocumentLoader::m_request should include
     695    // the fragment identifier, so add that back in.
     696    if (equalIgnoringFragmentIdentifier(initialRequest.url(), request.url()))
     697        request.setURL(initialRequest.url());
    669698    documentLoader()->setRequest(request);
    670699}
     
    694723unsigned long MainResourceLoader::identifier() const
    695724{
    696     ASSERT(!m_substituteDataLoadIdentifier || !loader() || !loader()->identifier());
    697     if (m_substituteDataLoadIdentifier)
    698         return m_substituteDataLoadIdentifier;
     725    ASSERT(!m_identifierForLoadWithoutResourceLoader || !loader() || !loader()->identifier());
     726    if (m_identifierForLoadWithoutResourceLoader)
     727        return m_identifierForLoadWithoutResourceLoader;
    699728    if (ResourceLoader* resourceLoader = loader())
    700729        return resourceLoader->identifier();
  • trunk/Source/WebCore/loader/MainResourceLoader.h

    r140875 r141136  
    129129    bool m_waitingForContentPolicy;
    130130    double m_timeOfLastDataReceived;
    131     unsigned long m_substituteDataLoadIdentifier;
     131    unsigned long m_identifierForLoadWithoutResourceLoader;
    132132
    133133#if USE(CONTENT_FILTERING)
  • trunk/Source/WebCore/loader/cache/CachedRawResource.cpp

    r140105 r141136  
    8181void CachedRawResource::didAddClient(CachedResourceClient* c)
    8282{
    83     if (m_response.isNull() || !hasClient(c))
     83    if (!hasClient(c))
    8484        return;
    8585    // The calls to the client can result in events running, potentially causing
     
    8888    CachedResourceHandle<CachedRawResource> protect(this);
    8989    CachedRawResourceClient* client = static_cast<CachedRawResourceClient*>(c);
    90     client->responseReceived(this, m_response);
     90    size_t redirectCount = m_redirectChain.size();
     91    for (size_t i = 0; i < redirectCount; i++) {
     92        RedirectPair redirect = m_redirectChain[i];
     93        ResourceRequest request(redirect.m_request);
     94        client->redirectReceived(this, request, redirect.m_redirectResponse);
     95        if (!hasClient(c))
     96            return;
     97    }
     98    ASSERT(redirectCount == m_redirectChain.size());
     99
     100    if (!m_response.isNull())
     101        client->responseReceived(this, m_response);
    91102    if (!hasClient(c))
    92103        return;
     
    111122        while (CachedRawResourceClient* c = w.next())
    112123            c->redirectReceived(this, request, response);
     124        m_redirectChain.append(RedirectPair(request, response));
    113125    }
    114126    CachedResource::willSendRequest(request, response);
     
    195207            return false;
    196208    }
     209
     210    for (size_t i = 0; i < m_redirectChain.size(); i++) {
     211        if (m_redirectChain[i].m_redirectResponse.cacheControlContainsNoStore())
     212            return false;
     213    }
     214
    197215    return true;
    198216}
  • trunk/Source/WebCore/loader/cache/CachedRawResource.h

    r140105 r141136  
    4949    void clear();
    5050
    51     bool canReuse(const ResourceRequest&) const;
     51    virtual bool canReuse(const ResourceRequest&) const;
    5252
    5353    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
     
    6868
    6969    unsigned long m_identifier;
     70
     71    struct RedirectPair {
     72    public:
     73        explicit RedirectPair(const ResourceRequest& request, const ResourceResponse& redirectResponse)
     74            : m_request(request)
     75            , m_redirectResponse(redirectResponse)
     76        {
     77        }
     78
     79        const ResourceRequest m_request;
     80        const ResourceResponse m_redirectResponse;
     81    };
     82
     83    Vector<RedirectPair> m_redirectChain;
    7084};
    7185
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r140174 r141136  
    498498        memoryCache()->addToLiveResourcesSize(this);
    499499
    500     if (m_type == RawResource && !m_response.isNull() && !m_proxyResource) {
    501         // Certain resources (especially XHRs) do crazy things if an asynchronous load returns
     500    if ((m_type == RawResource || m_type == MainResource) && !m_response.isNull() && !m_proxyResource) {
     501        // Certain resources (especially XHRs and main resources) do crazy things if an asynchronous load returns
    502502        // synchronously (e.g., scripts may not have set all the state they need to handle the load).
    503503        // Therefore, rather than immediately sending callbacks on a cache hit like other CachedResources,
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r140722 r141136  
    259259    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
    260260
     261    virtual bool canReuse(const ResourceRequest&) const { return true; }
     262
    261263protected:
    262264    virtual void checkNotify();
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r140522 r141136  
    478478    }
    479479
     480#if PLATFORM(CHROMIUM)
     481    // FIXME: Temporarily leave main resource caching disabled for chromium, see https://bugs.webkit.org/show_bug.cgi?id=107962
     482    // Ensure main resources aren't preloaded, and other main resource loads are removed from cache to prevent reuse.
     483    if (type == CachedResource::MainResource) {
     484        ASSERT(policy != Use);
     485        ASSERT(policy != Revalidate);
     486        memoryCache()->remove(resource.get());
     487        if (request.forPreload())
     488            return 0;
     489    }
     490#endif
     491
    480492    if (!request.resourceRequest().url().protocolIsData())
    481493        m_validatedURLs.add(request.resourceRequest().url());
     
    504516    memoryCache()->add(newResource.get());
    505517#if ENABLE(RESOURCE_TIMING)
    506     InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
    507     m_initiatorMap.add(newResource.get(), info);
     518    if (resource->type() != CachedResource::MainResource) {
     519        InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
     520        m_initiatorMap.add(newResource.get(), info);
     521    }
    508522#else
    509523    UNUSED_PARAM(request);
     
    523537        resource->setOwningCachedResourceLoader(this);
    524538#if ENABLE(RESOURCE_TIMING)
    525     InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
    526     m_initiatorMap.add(resource.get(), info);
     539    if (type != CachedResource::MainResource) {
     540        InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
     541        m_initiatorMap.add(resource.get(), info);
     542    }
    527543#endif
    528544    return resource;
     
    544560    }
    545561
    546     if (existingResource->type() == CachedResource::MainResource)
    547         return Reload;
    548 
    549     if (existingResource->type() == CachedResource::RawResource && !static_cast<CachedRawResource*>(existingResource)->canReuse(request))
     562    if (!existingResource->canReuse(request))
    550563        return Reload;
    551564
  • trunk/Source/WebCore/testing/Internals.cpp

    r140710 r141136  
    6666#include "Language.h"
    6767#include "MallocStatistics.h"
     68#include "MemoryCache.h"
    6869#include "MockPagePopupDriver.h"
    6970#include "NodeRenderingContext.h"
     
    290291    Document* document = contextDocument();
    291292    return document->cachedResourceLoader()->isPreloaded(url);
     293}
     294
     295bool Internals::isLoadingFromMemoryCache(const String& url)
     296{
     297    if (!contextDocument())
     298        return false;
     299    CachedResource* resource = memoryCache()->resourceForURL(contextDocument()->completeURL(url));
     300    return resource && resource->status() == CachedResource::Cached;
    292301}
    293302
  • trunk/Source/WebCore/testing/Internals.h

    r140710 r141136  
    7373
    7474    bool isPreloaded(const String& url);
     75    bool isLoadingFromMemoryCache(const String& url);
    7576
    7677    size_t numberOfScopedHTMLStyleChildren(const Node*, ExceptionCode&) const;
  • trunk/Source/WebCore/testing/Internals.idl

    r140710 r141136  
    3131    DOMString elementRenderTreeAsText(in Element element) raises(DOMException);
    3232    boolean isPreloaded(in DOMString url);
     33    boolean isLoadingFromMemoryCache(in DOMString url);
    3334
    3435    unsigned long numberOfScopedHTMLStyleChildren(in Node scope) raises(DOMException);
  • trunk/Source/WebKit/win/ChangeLog

    r140930 r141136  
     12013-01-29  Nate Chapin  <japhet@chromium.org>
     2
     3        Enable reuse of cached main resources
     4        https://bugs.webkit.org/show_bug.cgi?id=105667
     5
     6        Reviewed by Adam Barth.
     7
     8        * WebKit.vcproj/WebKitExports.def.in: Expose some MemoryCache symbols for use in Internals.
     9
    1102013-01-27  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
    211
  • trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in

    r140553 r141136  
    561561        ?cacheDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PAV23@PBUClassInfo@3@@Z
    562562        ?childItemWithTarget@HistoryItem@WebCore@@QBEPAV12@ABVString@WTF@@@Z
     563        ?completeURL@Document@WebCore@@QBE?AVKURL@2@ABVString@WTF@@@Z
    563564        ?create@Range@WebCore@@SA?AV?$PassRefPtr@VRange@WebCore@@@WTF@@V?$PassRefPtr@VDocument@WebCore@@@4@V?$PassRefPtr@VNode@WebCore@@@4@H1H@Z
    564565        ?create@SerializedScriptValue@WebCore@@SA?AV?$PassRefPtr@VSerializedScriptValue@WebCore@@@WTF@@ABVString@4@@Z
     
    13891390        ?mainThreadScrollingReasonsAsText@Page@WebCore@@QAE?AVString@WTF@@XZ
    13901391        ?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@@WTF@@PAVNode@2@VMarkerTypes@DocumentMarker@2@@Z
     1392        ?memoryCache@WebCore@@YAPAVMemoryCache@1@XZ
    13911393        ?nextSibling@ComposedShadowTreeWalker@WebCore@@QAEXXZ
    13921394        ?firstChild@ComposedShadowTreeWalker@WebCore@@QAEXXZ
     
    14081410        ?remove@String@WTF@@QAEXIH@Z
    14091411        ?removedLastRef@Node@WebCore@@AAEXXZ
     1412        ?resourceForURL@MemoryCache@WebCore@@QAEPAVCachedResource@2@ABVKURL@2@@Z
    14101413        ?reverseFind@StringImpl@WTF@@QAEI_WI@Z
    14111414        ?saveDocumentAndScrollState@HistoryController@WebCore@@QAEXXZ
  • trunk/Source/autotools/symbols.filter

    r140563 r141136  
    5151_ZN7WebCore10ClientRectC1ERKNS_7IntRectE;
    5252_ZN7WebCore10ShadowRoot6createEPNS_7ElementERi;
     53_ZN7WebCore11memoryCacheEv;
    5354_ZN7WebCore11EventTarget17toGeneratedStreamEv;
    5455_ZN7WebCore11EventTarget8toStreamEv;
    5556_ZN7WebCore11HistoryItem16setDocumentStateERKN3WTF6VectorINS1_6StringELj0EEE;
    5657_ZN7WebCore11HistoryItem16setDocumentStateERKN3WTF6VectorINS1_6StringELm0EEE;
     58_ZN7WebCore11MemoryCache14resourceForURLERKNS_4KURLE;
    5759_ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_13ContainerNodeEiib;
    5860_ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_7ElementEPKNS_5RangeERjS6_;
     
    147149_ZNK7WebCore6JSNode21pushEventHandlerScopeEPN3JSC9ExecStateEPNS1_14ScopeChainNodeE;
    148150_ZNK7WebCore7Element6shadowEv;
     151_ZNK7WebCore8Document11completeURLERKN3WTF6StringE;
    149152_ZNK7WebCore8Document4pageEv;
    150153_ZNK7WebCore8Document8settingsEv;
Note: See TracChangeset for help on using the changeset viewer.