Changeset 166434 in webkit


Ignore:
Timestamp:
Mar 28, 2014 3:46:27 PM (10 years ago)
Author:
BJ Burg
Message:

Web Replay: add page-level setting to bypass the MemoryCache
https://bugs.webkit.org/show_bug.cgi?id=130728

Reviewed by Timothy Hatcher.

Source/WebCore:

When replaying a specific Page we don't want to store its cached resources in the
MemoryCache. This patch adds a page setting to prevent the page's resources from
being saved in the MemoryCache.

If Settings::usesMemoryCache() is false, page resources are given the special
SessionID bypassCacheSessionID(). The cached resource loader and memory cache
act as if the memory cache is disabled if the resource has this special session id.

Hook up ReplayController to override the memory cache setting during capture/replay.

Test: http/tests/cache/bypass-memory-cache-after-reload.html

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::revalidateResource):

  • loader/cache/MemoryCache.cpp:

(WebCore::MemoryCache::add):

  • page/Page.cpp:

(WebCore::Page::sessionID):

  • page/SessionID.h:

(WebCore::SessionID::bypassCacheSessionID):

  • page/Settings.cpp:

(WebCore::Settings::Settings):

  • page/Settings.h:

(WebCore::Settings::setUsesMemoryCache):
(WebCore::Settings::usesMemoryCache):

  • replay/ReplayController.cpp:

(WebCore::ReplayController::setForceDeterministicSettings):

  • replay/ReplayController.h:
  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setUsesMemoryCache):

  • testing/InternalSettings.h:
  • testing/InternalSettings.idl:

Source/WebKit2:

  • UIProcess/APISession.cpp:

(API::generateID): update the base ID for generating unique sessions.

LayoutTests:

Mac WebKit2 needs different expectations because of resource load timing characteristics
introduced by the interaction of Settings::usesMemoryCache and NetworkProcess.

  • http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
  • http/tests/cache/bypass-memory-cache-after-reload.html: Added.
  • platform/mac-wk2/http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
Location:
trunk
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r166428 r166434  
     12014-03-28  Brian Burg  <bburg@apple.com>
     2
     3        Web Replay: add page-level setting to bypass the MemoryCache
     4        https://bugs.webkit.org/show_bug.cgi?id=130728
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        Mac WebKit2 needs different expectations because of resource load timing characteristics
     9        introduced by the interaction of Settings::usesMemoryCache and NetworkProcess.
     10
     11        * http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
     12        * http/tests/cache/bypass-memory-cache-after-reload.html: Added.
     13        * platform/mac-wk2/http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
     14
    1152014-03-28  Radu Stavila  <stavila@adobe.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r166428 r166434  
     12014-03-28  Brian Burg  <bburg@apple.com>
     2
     3        Web Replay: add page-level setting to bypass the MemoryCache
     4        https://bugs.webkit.org/show_bug.cgi?id=130728
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        When replaying a specific Page we don't want to store its cached resources in the
     9        MemoryCache. This patch adds a page setting to prevent the page's resources from
     10        being saved in the MemoryCache.
     11
     12        If Settings::usesMemoryCache() is false, page resources are given the special
     13        SessionID bypassCacheSessionID(). The cached resource loader and memory cache
     14        act as if the memory cache is disabled if the resource has this special session id.
     15
     16        Hook up ReplayController to override the memory cache setting during capture/replay.
     17
     18        Test: http/tests/cache/bypass-memory-cache-after-reload.html
     19
     20        * loader/cache/CachedResourceLoader.cpp:
     21        (WebCore::CachedResourceLoader::requestResource):
     22        (WebCore::CachedResourceLoader::revalidateResource):
     23        * loader/cache/MemoryCache.cpp:
     24        (WebCore::MemoryCache::add):
     25        * page/Page.cpp:
     26        (WebCore::Page::sessionID):
     27        * page/SessionID.h:
     28        (WebCore::SessionID::bypassCacheSessionID):
     29        * page/Settings.cpp:
     30        (WebCore::Settings::Settings):
     31        * page/Settings.h:
     32        (WebCore::Settings::setUsesMemoryCache):
     33        (WebCore::Settings::usesMemoryCache):
     34        * replay/ReplayController.cpp:
     35        (WebCore::ReplayController::setForceDeterministicSettings):
     36        * replay/ReplayController.h:
     37        * testing/InternalSettings.cpp:
     38        (WebCore::InternalSettings::Backup::Backup):
     39        (WebCore::InternalSettings::Backup::restoreTo):
     40        (WebCore::InternalSettings::setUsesMemoryCache):
     41        * testing/InternalSettings.h:
     42        * testing/InternalSettings.idl:
     43
    1442014-03-28  Radu Stavila  <stavila@adobe.com>
    245
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r165427 r166434  
    485485
    486486    ASSERT(resource->url() == url.string());
    487     m_documentResources.set(resource->url(), resource);
     487
     488    if (sessionID() != SessionID::bypassCacheSessionID())
     489        m_documentResources.set(resource->url(), resource);
     490
    488491    return resource;
    489492}
     
    497500    ASSERT(!resource->resourceToRevalidate());
    498501    ASSERT(resource->sessionID() == sessionID());
     502    ASSERT(sessionID() != SessionID::bypassCacheSessionID());
    499503
    500504    // Copy the URL out of the resource to be revalidated in case it gets deleted by the remove() call below.
  • trunk/Source/WebCore/loader/cache/MemoryCache.cpp

    r165607 r166434  
    111111        return false;
    112112
     113    if (resource->sessionID() == SessionID::bypassCacheSessionID())
     114        return false;
     115
    113116    ASSERT(WTF::isMainThread());
    114117
  • trunk/Source/WebCore/page/Page.cpp

    r166323 r166434  
    15211521        return SessionID::legacyPrivateSessionID();
    15221522
     1523    if (!settings().usesMemoryCache())
     1524        return SessionID::bypassCacheSessionID();
     1525
    15231526    return SessionID::defaultSessionID();
    15241527}
  • trunk/Source/WebCore/page/SessionID.h

    r164726 r166434  
    4444    static SessionID defaultSessionID() { return SessionID(1); }
    4545    static SessionID legacyPrivateSessionID() { return SessionID(2); }
     46    static SessionID bypassCacheSessionID() { return SessionID(3); }
    4647private:
    4748    uint64_t m_sessionID;
  • trunk/Source/WebCore/page/Settings.cpp

    r165676 r166434  
    178178    , m_needsAdobeFrameReloadingQuirk(false)
    179179    , m_usesPageCache(false)
     180    , m_usesMemoryCache(true)
    180181    , m_fontRenderingMode(0)
    181182    , m_showTiledScrollingIndicator(false)
  • trunk/Source/WebCore/page/Settings.h

    r165676 r166434  
    182182    void setUsesPageCache(bool);
    183183    bool usesPageCache() const { return m_usesPageCache; }
    184        
     184
     185    void setUsesMemoryCache(bool usesMemoryCache) { m_usesMemoryCache = usesMemoryCache; }
     186    bool usesMemoryCache() const { return m_usesMemoryCache; }
     187
    185188    void setFontRenderingMode(FontRenderingMode mode);
    186189    FontRenderingMode fontRenderingMode() const;
     
    308311    bool m_needsAdobeFrameReloadingQuirk : 1;
    309312    bool m_usesPageCache : 1;
     313    bool m_usesMemoryCache : 1;
    310314    unsigned m_fontRenderingMode : 1;
    311315    bool m_showTiledScrollingIndicator : 1;
  • trunk/Source/WebCore/replay/ReplayController.cpp

    r166337 r166434  
    7272
    7373    if (shouldForce) {
     74        m_savedSettings.usesMemoryCache = m_page.settings().usesMemoryCache();
    7475        m_savedSettings.usesPageCache = m_page.settings().usesPageCache();
    7576
     77        m_page.settings().setUsesMemoryCache(false);
    7678        m_page.settings().setUsesPageCache(false);
    7779    } else {
     80        m_page.settings().setUsesMemoryCache(m_savedSettings.usesMemoryCache);
    7881        m_page.settings().setUsesPageCache(m_savedSettings.usesPageCache);
    7982    }
  • trunk/Source/WebCore/replay/ReplayController.h

    r166337 r166434  
    155155
    156156    struct SavedSettings {
     157        bool usesMemoryCache;
    157158        bool usesPageCache;
    158159
    159160        SavedSettings()
    160             : usesPageCache(false)
     161            : usesMemoryCache(true)
     162            , usesPageCache(false)
    161163        { }
    162164    };
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r164131 r166434  
    9292    , m_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
    9393    , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
     94    , m_usesMemoryCache(settings.usesMemoryCache())
    9495{
    9596}
     
    150151    settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
    151152    settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
     153    settings.setUsesMemoryCache(m_usesMemoryCache);
    152154    RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
    153155}
     
    494496}
    495497
    496 }
     498void InternalSettings::setUsesMemoryCache(bool usesMemoryCache, ExceptionCode& ec)
     499{
     500    InternalSettingsGuardForSettings();
     501    settings()->setUsesMemoryCache(usesMemoryCache);
     502}
     503
     504}
  • trunk/Source/WebCore/testing/InternalSettings.h

    r164131 r166434  
    8989        bool m_pluginReplacementEnabled;
    9090        bool m_shouldConvertPositionStyleOnCopy;
     91        bool m_usesMemoryCache;
    9192    };
    9293
     
    133134    void setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode&);
    134135    void setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode&);
    135 
     136    void setUsesMemoryCache(bool usesMemoryCache, ExceptionCode&);
    136137
    137138private:
  • trunk/Source/WebCore/testing/InternalSettings.idl

    r164131 r166434  
    6060    [RaisesException] void setBackgroundShouldExtendBeyondPage(boolean hasExtendedBackground);
    6161    [RaisesException] void setShouldConvertPositionStyleOnCopy(boolean convert);
     62    [RaisesException] void setUsesMemoryCache(boolean usesMemoryCache);
    6263};
  • trunk/Source/WebKit2/ChangeLog

    r166433 r166434  
     12014-03-28  Brian Burg  <bburg@apple.com>
     2
     3        Web Replay: add page-level setting to bypass the MemoryCache
     4        https://bugs.webkit.org/show_bug.cgi?id=130728
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UIProcess/APISession.cpp:
     9        (API::generateID): update the base ID for generating unique sessions.
     10
    1112014-03-28  Cody Krieger  <cjk@apple.com>
    212
  • trunk/Source/WebKit2/UIProcess/APISession.cpp

    r165794 r166434  
    3535    ASSERT(RunLoop::isMain());
    3636
    37     static uint64_t uniqueSessionID = WebCore::SessionID::legacyPrivateSessionID().sessionID();
     37    static uint64_t uniqueSessionID = WebCore::SessionID::bypassCacheSessionID().sessionID();
    3838    ASSERT_UNUSED(isEphemeral, isEphemeral);
    3939    return ++uniqueSessionID;
Note: See TracChangeset for help on using the changeset viewer.