Changeset 197244 in webkit


Ignore:
Timestamp:
Feb 26, 2016 11:44:07 PM (8 years ago)
Author:
Carlos Garcia Campos
Message:

Network cache: old pages returned by disk cache on history navigation after session is restored
https://bugs.webkit.org/show_bug.cgi?id=153230

Reviewed by Chris Dumez.

Source/WebCore:

Add a flag to HistoryItem to mark them as restored from session
and use it from the FrameLoader to not change the policy request
when navigating to a history item that was restored from session,
except for iOS port.

  • history/HistoryItem.h:

(WebCore::HistoryItem::setWasRestoredFromSession):
(WebCore::HistoryItem::wasRestoredFromSession):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::loadDifferentDocumentItem):

Source/WebKit2:

Since r181734, the network cache never revalidates resources for
history navigation. This is good for the memory cache, but in the
case of disk cache, we might end up with outdated pages when
restoring the session. When restoring the session happens because
of an API request (we also restore the session when recovering
from a web process crash), we should revalidate back forward list
requests in the disk cache if needed. This will only happen the
first time they are loaded after a session restore. After a web process
crash, resources will be used uncondionally from the disk cache.

  • WebProcess/WebPage/WebBackForwardListProxy.cpp:

(WebKit::WebBackForwardListProxy::addItemFromUIProcess): Use Ref&&
instead of PassRefPtr.

  • WebProcess/WebPage/WebBackForwardListProxy.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WePage::WebPage): Call restoreSessionInternal passing
No as restoredByAPIRequest parameter.
(WebKit::WebPage::restoreSessionInternal): Set restoredFromSession
flag to the created HistoryItem if the item was restored from
session by an API request.
(WebKit::WebPage::restoreSession): Call restoreSessionInternal
passing Yes as restoredByAPIRequest parameter.

  • WebProcess/WebPage/WebPage.h:
Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197240 r197244  
     12016-02-26  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Network cache: old pages returned by disk cache on history navigation after session is restored
     4        https://bugs.webkit.org/show_bug.cgi?id=153230
     5
     6        Reviewed by Chris Dumez.
     7
     8        Add a flag to HistoryItem to mark them as restored from session
     9        and use it from the FrameLoader to not change the policy request
     10        when navigating to a history item that was restored from session,
     11        except for iOS port.
     12
     13        * history/HistoryItem.h:
     14        (WebCore::HistoryItem::setWasRestoredFromSession):
     15        (WebCore::HistoryItem::wasRestoredFromSession):
     16        * loader/FrameLoader.cpp:
     17        (WebCore::FrameLoader::loadDifferentDocumentItem):
     18
    1192016-02-26  Michael Catanzaro  <mcatanzaro@igalia.com>
    220
  • trunk/Source/WebCore/history/HistoryItem.h

    r194492 r197244  
    206206    void notifyChanged();
    207207
     208    void setWasRestoredFromSession(bool wasRestoredFromSession) { m_wasRestoredFromSession = wasRestoredFromSession; }
     209    bool wasRestoredFromSession() const { return m_wasRestoredFromSession; }
     210
    208211private:
    209212    WEBCORE_EXPORT HistoryItem();
     
    232235    bool m_lastVisitWasFailure;
    233236    bool m_isTargetItem;
     237    bool m_wasRestoredFromSession { false };
    234238
    235239    std::unique_ptr<Vector<String>> m_redirectURLs;
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r196807 r197244  
    33373337        case FrameLoadType::Back:
    33383338        case FrameLoadType::Forward:
    3339         case FrameLoadType::IndexedBackForward:
    3340             request.setCachePolicy(ReturnCacheDataElseLoad);
     3339        case FrameLoadType::IndexedBackForward: {
     3340#if PLATFORM(IOS)
     3341            bool allowStaleData = true;
     3342#else
     3343            bool allowStaleData = !item.wasRestoredFromSession();
     3344#endif
     3345            if (allowStaleData)
     3346                request.setCachePolicy(ReturnCacheDataElseLoad);
     3347            item.setWasRestoredFromSession(false);
    33413348            break;
     3349        }
    33423350        case FrameLoadType::Standard:
    33433351        case FrameLoadType::RedirectWithLockedBackForwardList:
  • trunk/Source/WebKit2/ChangeLog

    r197239 r197244  
     12016-02-26  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Network cache: old pages returned by disk cache on history navigation after session is restored
     4        https://bugs.webkit.org/show_bug.cgi?id=153230
     5
     6        Reviewed by Chris Dumez.
     7
     8        Since r181734, the network cache never revalidates resources for
     9        history navigation. This is good for the memory cache, but in the
     10        case of disk cache, we might end up with outdated pages when
     11        restoring the session. When restoring the session happens because
     12        of an API request (we also restore the session when recovering
     13        from a web process crash), we should revalidate back forward list
     14        requests in the disk cache if needed. This will only happen the
     15        first time they are loaded after a session restore. After a web process
     16        crash, resources will be used uncondionally from the disk cache.
     17
     18        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
     19        (WebKit::WebBackForwardListProxy::addItemFromUIProcess): Use Ref&&
     20        instead of PassRefPtr.
     21        * WebProcess/WebPage/WebBackForwardListProxy.h:
     22        * WebProcess/WebPage/WebPage.cpp:
     23        (WebKit::WePage::WebPage): Call restoreSessionInternal passing
     24        No as restoredByAPIRequest parameter.
     25        (WebKit::WebPage::restoreSessionInternal): Set restoredFromSession
     26        flag to the created HistoryItem if the item was restored from
     27        session by an API request.
     28        (WebKit::WebPage::restoreSession): Call restoreSessionInternal
     29        passing Yes as restoredByAPIRequest parameter.
     30        * WebProcess/WebPage/WebPage.h:
     31
    1322016-02-26  Michael Catanzaro  <mcatanzaro@igalia.com>
    233
  • trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp

    r184054 r197244  
    9595}
    9696
    97 void WebBackForwardListProxy::addItemFromUIProcess(uint64_t itemID, PassRefPtr<WebCore::HistoryItem> prpItem, uint64_t pageID)
    98 {
    99     RefPtr<HistoryItem> item = prpItem;
    100    
     97void WebBackForwardListProxy::addItemFromUIProcess(uint64_t itemID, Ref<HistoryItem>&& item, uint64_t pageID)
     98{
    10199    // This item/itemID pair should not already exist in our maps.
    102     ASSERT(!historyItemToIDMap().contains(item.get()));
     100    ASSERT(!historyItemToIDMap().contains(item.ptr()));
    103101    ASSERT(!idToHistoryItemMap().contains(itemID));
    104102
    105     historyItemToIDMap().set<ItemAndPageID>(item, { .itemID = itemID, .pageID = pageID });
    106     idToHistoryItemMap().set(itemID, item);
     103    historyItemToIDMap().set<ItemAndPageID>(item.ptr(), { .itemID = itemID, .pageID = pageID });
     104    idToHistoryItemMap().set(itemID, item.ptr());
    107105}
    108106
  • trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h

    r186566 r197244  
    4343    static void removeItem(uint64_t itemID);
    4444
    45     static void addItemFromUIProcess(uint64_t itemID, PassRefPtr<WebCore::HistoryItem>, uint64_t pageID);
     45    static void addItemFromUIProcess(uint64_t itemID, Ref<WebCore::HistoryItem>&&, uint64_t pageID);
    4646    static void setHighestItemIDFromUIProcess(uint64_t itemID);
    4747   
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r197114 r197244  
    491491   
    492492    if (!parameters.itemStates.isEmpty())
    493         restoreSession(parameters.itemStates);
     493        restoreSessionInternal(parameters.itemStates, WasRestoredByAPIRequest::No);
    494494
    495495    if (parameters.sessionID.isValid())
     
    22322232}
    22332233
     2234void WebPage::restoreSessionInternal(const Vector<BackForwardListItemState>& itemStates, WasRestoredByAPIRequest restoredByAPIRequest)
     2235{
     2236    for (const auto& itemState : itemStates) {
     2237        auto historyItem = toHistoryItem(itemState.pageState);
     2238        historyItem->setWasRestoredFromSession(restoredByAPIRequest == WasRestoredByAPIRequest::Yes);
     2239        WebBackForwardListProxy::addItemFromUIProcess(itemState.identifier, WTFMove(historyItem), m_pageID);
     2240    }
     2241}
     2242
    22342243void WebPage::restoreSession(const Vector<BackForwardListItemState>& itemStates)
    22352244{
    2236     for (const auto& itemState : itemStates)
    2237         WebBackForwardListProxy::addItemFromUIProcess(itemState.identifier, toHistoryItem(itemState.pageState), m_pageID);
     2245    restoreSessionInternal(itemStates, WasRestoredByAPIRequest::Yes);
    22382246}
    22392247
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r197213 r197244  
    10211021    void loadURLInFrame(const String&, uint64_t frameID);
    10221022
     1023    enum class WasRestoredByAPIRequest { No, Yes };
     1024    void restoreSessionInternal(const Vector<BackForwardListItemState>&, WasRestoredByAPIRequest);
    10231025    void restoreSession(const Vector<BackForwardListItemState>&);
    10241026    void didRemoveBackForwardItem(uint64_t);
Note: See TracChangeset for help on using the changeset viewer.