Changeset 140005 in webkit


Ignore:
Timestamp:
Jan 17, 2013 11:09:16 AM (11 years ago)
Author:
Nate Chapin
Message:

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

Reviewed by Antti Koivisto.

  • 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 Antti Koivisto.

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.

  • 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::determineRevalidationPolicy): Permit cache reuse for main resources.

  • testing/Internals.cpp:

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

  • 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 Antti Koivisto.

  • 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 Antti Koivisto.

  • 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:
Location:
trunk
Files:
3 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r139992 r140005  
     12013-01-17  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 Antti Koivisto.
     7
     8        * Source/autotools/symbols.filter: Expose MemoryCache::resourceForURL().
     9
    1102013-01-17  Seokju Kwon  <seokju.kwon@gmail.com>
    211
  • trunk/LayoutTests/ChangeLog

    r139999 r140005  
     12013-01-17  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 Antti Koivisto.
     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
    1162013-01-17  Shinya Kawanaka  <shinyak@chromium.org>
    217
  • trunk/LayoutTests/http/tests/inspector/resource-har-pages-expected.txt

    r139694 r140005  
    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

    r139694 r140005  
    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

    r139694 r140005  
    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

    r139694 r140005  
    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/Source/WebCore/ChangeLog

    r140003 r140005  
     12013-01-17  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 Antti Koivisto.
     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        * dom/Document.h:
     14        (Document):
     15        * loader/FrameLoader.cpp:
     16        (WebCore::FrameLoader::loadedResourceFromMemoryCache): Don't send delegate callbacks for cache hit here, since
     17            MainResourceLoader will take care of it.
     18        * loader/MainResourceLoader.cpp:
     19        (WebCore::MainResourceLoader::MainResourceLoader):
     20        (WebCore::MainResourceLoader::receivedError):
     21        (WebCore::MainResourceLoader::willSendRequest):
     22        (WebCore::MainResourceLoader::responseReceived): Don't try to cache loads from the application cache.
     23        (WebCore::MainResourceLoader::didFinishLoading): Don't try to cache loads from the application cache.
     24        (WebCore::MainResourceLoader::load): Ensure we create a resource load identifier for cache hits. Also,
     25            ensure we correctly popualate fragment identifiers in the ResourceRequest reported to DocumentLoader.
     26        (WebCore::MainResourceLoader::identifier):
     27        * loader/MainResourceLoader.h: Rename m_substituteDataLoadIdentifier to m_identifierForLoadWithoutResourceLoader
     28            to better describe when it is used.
     29        * loader/cache/CachedRawResource.cpp:
     30        (WebCore::CachedRawResource::didAddClient): Synthesize redirect notifications for cache hits if necessary.
     31        (WebCore::CachedRawResource::willSendRequest): Note the redirects we received.
     32        (WebCore::CachedRawResource::canReuse): Don't reuse a resource if the redirect chain included a "Cache-control: no-store".
     33        * loader/cache/CachedRawResource.h:
     34        (CachedRawResource):
     35        (RedirectPair):
     36        (WebCore::CachedRawResource::RedirectPair::RedirectPair):
     37        * loader/cache/CachedResource.cpp:
     38        (WebCore::CachedResource::addClientToSet):: Don't return cached data for a main resource synchronously
     39        * loader/cache/CachedResource.h:
     40        (WebCore::CachedResource::canReuse):
     41        (CachedResource):
     42        * loader/cache/CachedResourceLoader.cpp:
     43        (WebCore::CachedResourceLoader::determineRevalidationPolicy): Permit cache reuse for main resources.
     44        * testing/Internals.cpp:
     45        (WebCore::Internals::isLoadingFromMemoryCache):
     46        (WebCore):
     47        * testing/Internals.h:
     48        (Internals):
     49        * testing/Internals.idl:
     50
    1512013-01-17  Eugene Klyuchnikov  <eustas@chromium.org>
    252
  • trunk/Source/WebCore/WebCore.exp.in

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

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

    r139780 r140005  
    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

    r139935 r140005  
    28942894        return;
    28952895
     2896    // Main resource delegate messages are synthesized in MainResourceLoader, so we must not send them here.
     2897    if (resource->type() == CachedResource::MainResource)
     2898        return;
     2899
    28962900    if (!page->areMemoryCacheClientCallsEnabled()) {
    28972901        InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource);
  • trunk/Source/WebCore/loader/MainResourceLoader.cpp

    r139694 r140005  
    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#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
    7879    , m_filter(0)
     
    100101    RefPtr<Frame> protectFrame(m_documentLoader->frame());
    101102
    102     if (m_substituteDataLoadIdentifier) {
     103    if (m_identifierForLoadWithoutResourceLoader) {
    103104        ASSERT(!loader());
    104         frameLoader()->client()->dispatchDidFailLoading(documentLoader(), m_substituteDataLoadIdentifier, error);
     105        frameLoader()->client()->dispatchDidFailLoading(documentLoader(), m_identifierForLoadWithoutResourceLoader, error);
    105106    }
    106107
     
    287288        documentLoader()->applicationCacheHost()->maybeLoadMainResourceForRedirect(newRequest, m_substituteData);
    288289        if (m_substituteData.isValid())
    289             m_substituteDataLoadIdentifier = identifier();
     290            m_identifierForLoadWithoutResourceLoader = identifier();
    290291    }
    291292
     
    393394{
    394395    ASSERT_UNUSED(resource, m_resource == resource);
    395     if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r))
     396    bool willLoadFallback = documentLoader()->applicationCacheHost()->maybeLoadFallbackForMainResponse(request(), r);
     397
     398    // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
     399    // from the application cache, ensure we don't save the result for future use.
     400    bool shouldRemoveResourceFromCache = willLoadFallback;
     401#if PLATFORM(CHROMIUM)
     402    // chromium's ApplicationCacheHost implementation always returns true for maybeLoadFallbackForMainResponse(). However, all responses loaded
     403    // from appcache will have a non-zero appCacheID().
     404    if (r.appCacheID())
     405        shouldRemoveResourceFromCache = true;
     406#endif
     407    if (shouldRemoveResourceFromCache)
     408        memoryCache()->remove(m_resource.get());
     409
     410    if (willLoadFallback)
    396411        return;
    397412
     
    541556    if (!loader()) {
    542557        frameLoader()->notifier()->dispatchDidFinishLoading(documentLoader(), identifier(), finishTime);
    543         m_substituteDataLoadIdentifier = 0;
     558        m_identifierForLoadWithoutResourceLoader = 0;
    544559    }
    545560
     
    563578    documentLoader()->finishedLoading();
    564579
     580    // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache
     581    // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
     582    if (Frame* frame = documentLoader()->frame()) {
     583        if (m_resource && frame->document()->hasManifest())
     584            memoryCache()->remove(m_resource.get());
     585    }
     586
    565587    dl->applicationCacheHost()->finishedLoadingMainResource();
    566588}
     
    672694
    673695    if (m_substituteData.isValid()) {
    674         m_substituteDataLoadIdentifier = m_documentLoader->frame()->page()->progress()->createUniqueIdentifier();
    675         frameLoader()->notifier()->assignIdentifierToInitialRequest(m_substituteDataLoadIdentifier, documentLoader(), request);
    676         frameLoader()->notifier()->dispatchWillSendRequest(documentLoader(), m_substituteDataLoadIdentifier, request, ResourceResponse());
     696        m_identifierForLoadWithoutResourceLoader = m_documentLoader->frame()->page()->progress()->createUniqueIdentifier();
     697        frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, documentLoader(), request);
     698        frameLoader()->notifier()->dispatchWillSendRequest(documentLoader(), m_identifierForLoadWithoutResourceLoader, request, ResourceResponse());
    677699        handleSubstituteDataLoadSoon(request);
    678700        return;
     
    687709        return;
    688710    }
     711    if (!loader()) {
     712        m_identifierForLoadWithoutResourceLoader = m_documentLoader->frame()->page()->progress()->createUniqueIdentifier();
     713        frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, documentLoader(), request);
     714        frameLoader()->notifier()->dispatchWillSendRequest(documentLoader(), m_identifierForLoadWithoutResourceLoader, request, ResourceResponse());
     715    }
    689716    m_resource->addClient(this);
    690717
    691     // We need to wait until after requestMainResource() is called to setRequest(), because there are a bunch of headers set when
    692     // the underlying ResourceLoader is created, and DocumentLoader::m_request needs to include those. However, the cache will
    693     // strip the fragment identifier (which DocumentLoader::m_request should also include), so add that back in.
     718    // A bunch of headers are set when the underlying ResourceLoader is created, and DocumentLoader::m_request needs to include those.
    694719    if (loader())
    695720        request = loader()->originalRequest();
     721    // If there was a fragment identifier on initialRequest, the cache will have stripped it. DocumentLoader::m_request should include
     722    // the fragment identifier, so add that back in.
     723    if (equalIgnoringFragmentIdentifier(initialRequest.url(), request.url()))
     724        request.setURL(initialRequest.url());
    696725    documentLoader()->setRequest(request);
    697726}
     
    721750unsigned long MainResourceLoader::identifier() const
    722751{
    723     ASSERT(!m_substituteDataLoadIdentifier || !loader() || !loader()->identifier());
    724     if (m_substituteDataLoadIdentifier)
    725         return m_substituteDataLoadIdentifier;
     752    ASSERT(!m_identifierForLoadWithoutResourceLoader || !loader() || !loader()->identifier());
     753    if (m_identifierForLoadWithoutResourceLoader)
     754        return m_identifierForLoadWithoutResourceLoader;
    726755    if (ResourceLoader* resourceLoader = loader())
    727756        return resourceLoader->identifier();
  • trunk/Source/WebCore/loader/MainResourceLoader.h

    r139694 r140005  
    129129    bool m_waitingForContentPolicy;
    130130    double m_timeOfLastDataReceived;
    131     unsigned long m_substituteDataLoadIdentifier;
     131    unsigned long m_identifierForLoadWithoutResourceLoader;
    132132
    133133#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
  • trunk/Source/WebCore/loader/cache/CachedRawResource.cpp

    r139694 r140005  
    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

    r139694 r140005  
    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

    r139694 r140005  
    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

    r139694 r140005  
    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

    r139694 r140005  
    541541    }
    542542
    543     if (existingResource->type() == CachedResource::MainResource)
    544         return Reload;
    545 
    546     if (existingResource->type() == CachedResource::RawResource && !static_cast<CachedRawResource*>(existingResource)->canReuse(request))
     543    if (!existingResource->canReuse(request))
    547544        return Reload;
    548545
  • trunk/Source/WebCore/testing/Internals.cpp

    r139694 r140005  
    6666#include "Language.h"
    6767#include "MallocStatistics.h"
     68#include "MemoryCache.h"
    6869#include "MockPagePopupDriver.h"
    6970#include "NodeRenderingContext.h"
     
    292293
    293294    return document->cachedResourceLoader()->isPreloaded(url);
     295}
     296
     297bool Internals::isLoadingFromMemoryCache(const String& url)
     298{
     299    if (!contextDocument())
     300        return false;
     301    CachedResource* resource = memoryCache()->resourceForURL(contextDocument()->completeURL(url));
     302    return resource && resource->status() == CachedResource::Cached;
    294303}
    295304
  • trunk/Source/WebCore/testing/Internals.h

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

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

    r139801 r140005  
     12013-01-17  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 Antti Koivisto.
     7
     8        * WebKit.vcproj/WebKitExports.def.in: Expose some MemoryCache symbols for use in Internals.
     9
    1102013-01-15  peavo@outlook.com  <peavo@outlook.com>
    211
  • trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in

    r139694 r140005  
    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
     
    13911392        ?mainThreadScrollingReasonsAsText@Page@WebCore@@QAE?AVString@WTF@@XZ
    13921393        ?markersFor@DocumentMarkerController@WebCore@@QAE?AV?$Vector@PAVDocumentMarker@WebCore@@$0A@@WTF@@PAVNode@2@VMarkerTypes@DocumentMarker@2@@Z
     1394        ?memoryCache@WebCore@@YAPAVMemoryCache@1@XZ
    13931395        ?nextSibling@ComposedShadowTreeWalker@WebCore@@QAEXXZ
    13941396        ?firstChild@ComposedShadowTreeWalker@WebCore@@QAEXXZ
     
    14101412        ?remove@String@WTF@@QAEXIH@Z
    14111413        ?removedLastRef@Node@WebCore@@AAEXXZ
     1414        ?resourceForURL@MemoryCache@WebCore@@QAEPAVCachedResource@2@ABVKURL@2@@Z
    14121415        ?reverseFind@StringImpl@WTF@@QAEI_WI@Z
    14131416        ?saveDocumentAndScrollState@HistoryController@WebCore@@QAEXXZ
  • trunk/Source/autotools/symbols.filter

    r139694 r140005  
    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.