Changeset 255135 in webkit


Ignore:
Timestamp:
Jan 26, 2020 8:38:51 PM (4 years ago)
Author:
Chris Dumez
Message:

Frequent sync BackForwardBackListCount/BackForwardForwardListCount IPC on reddit.com
https://bugs.webkit.org/show_bug.cgi?id=206438

Reviewed by Darin Adler.

Frequent sync BackForwardBackListCount/BackForwardForwardListCount IPC on reddit.com. When scrolling on reddit.com,
you frequently see 2 consecutive sync IPCs (WebPageProxy::BackForwardBackListCount then WebPageProxy::BackForwardForwardListCount)
from the WebContent process to the UIProcess. Those are bad for performance. This happens every time the script on the page accesses
history.length, which is unfortunate, since this history length rarely changes.

To address the issue, the following changes were made:

  1. Merge BackForwardBackListCount / BackForwardForwardListCount IPCs into a single BackForwardListCounts IPC which returns both the back & forward counts, since we often need both (e.g. when accessing history.length) and since gettings those counts is very cheap compared to the cost of a sync IPC.
  2. Cache those counts in WebBackForwardListProxy and blow away the cached counts whenever the back/forward list changes. In the common case (where the back/forward list rarely changes), we now see a single sync IPC instead of many (verified on reddit.com).

No new tests, merely a performance improvement.

  • UIProcess/WebPageProxy.cpp:
  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebPage/WebBackForwardListProxy.cpp:

(WebKit::WebBackForwardListProxy::addItemFromUIProcess):
(WebKit::WebBackForwardListProxy::addItem):
(WebKit::WebBackForwardListProxy::goToItem):
(WebKit::WebBackForwardListProxy::backListCount const):
(WebKit::WebBackForwardListProxy::forwardListCount const):
(WebKit::WebBackForwardListProxy::cacheListCountsIfNecessary const):
(WebKit::WebBackForwardListProxy::clearCachedListCounts):
(WebKit::WebBackForwardListProxy::close):
(WebKit::WebBackForwardListProxy::clear):

  • WebProcess/WebPage/WebBackForwardListProxy.h:
Location:
trunk/Source/WebKit
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r255133 r255135  
     12020-01-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Frequent sync BackForwardBackListCount/BackForwardForwardListCount IPC on reddit.com
     4        https://bugs.webkit.org/show_bug.cgi?id=206438
     5
     6        Reviewed by Darin Adler.
     7
     8        Frequent sync BackForwardBackListCount/BackForwardForwardListCount IPC on reddit.com. When scrolling on reddit.com,
     9        you frequently see 2 consecutive sync IPCs (WebPageProxy::BackForwardBackListCount then WebPageProxy::BackForwardForwardListCount)
     10        from the WebContent process to the UIProcess. Those are bad for performance. This happens every time the script on the page accesses
     11        history.length, which is unfortunate, since this history length rarely changes.
     12
     13        To address the issue, the following changes were made:
     14        1. Merge BackForwardBackListCount / BackForwardForwardListCount IPCs into a single BackForwardListCounts IPC which returns both
     15           the back & forward counts, since we often need both (e.g. when accessing history.length) and since gettings those counts is
     16           very cheap compared to the cost of a sync IPC.
     17        2. Cache those counts in WebBackForwardListProxy and blow away the cached counts whenever the back/forward list changes. In the
     18           common case (where the back/forward list rarely changes), we now see a single sync IPC instead of many (verified on reddit.com).
     19
     20        No new tests, merely a performance improvement.
     21
     22        * UIProcess/WebPageProxy.cpp:
     23        * UIProcess/WebPageProxy.h:
     24        * UIProcess/WebPageProxy.messages.in:
     25        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
     26        (WebKit::WebBackForwardListProxy::addItemFromUIProcess):
     27        (WebKit::WebBackForwardListProxy::addItem):
     28        (WebKit::WebBackForwardListProxy::goToItem):
     29        (WebKit::WebBackForwardListProxy::backListCount const):
     30        (WebKit::WebBackForwardListProxy::forwardListCount const):
     31        (WebKit::WebBackForwardListProxy::cacheListCountsIfNecessary const):
     32        (WebKit::WebBackForwardListProxy::clearCachedListCounts):
     33        (WebKit::WebBackForwardListProxy::close):
     34        (WebKit::WebBackForwardListProxy::clear):
     35        * WebProcess/WebPage/WebBackForwardListProxy.h:
     36
    1372020-01-26  youenn fablet  <youenn@apple.com>
    238
  • trunk/Source/WebKit/Shared/WebBackForwardListCounts.h

    r255134 r255135  
    11/*
    2  * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include <WebCore/BackForwardClient.h>
    29 #include <WebCore/PageIdentifier.h>
    30 #include <wtf/HashSet.h>
    31 
    32 namespace WebCore {
    33 struct BackForwardItemIdentifier;
    34 }
     28#include "Decoder.h"
     29#include "Encoder.h"
     30#include <wtf/Optional.h>
    3531
    3632namespace WebKit {
    3733
    38 class WebPage;
     34struct WebBackForwardListCounts {
     35    uint32_t backCount { 0 };
     36    uint32_t forwardCount { 0 };
    3937
    40 class WebBackForwardListProxy : public WebCore::BackForwardClient {
    41 public:
    42     static Ref<WebBackForwardListProxy> create(WebPage& page) { return adoptRef(*new WebBackForwardListProxy(page)); }
     38    void encode(IPC::Encoder& encoder) const
     39    {
     40        encoder << backCount;
     41        encoder << forwardCount;
     42    }
    4343
    44     static WebCore::HistoryItem* itemForID(const WebCore::BackForwardItemIdentifier&);
    45     static void removeItem(const WebCore::BackForwardItemIdentifier&);
     44    static Optional<WebBackForwardListCounts> decode(IPC::Decoder& decoder)
     45    {
     46        Optional<uint32_t> backCount;
     47        decoder >> backCount;
     48        if (!backCount)
     49            return WTF::nullopt;
    4650
    47     enum class OverwriteExistingItem {
    48         Yes,
    49         No
    50     };
    51     void addItemFromUIProcess(const WebCore::BackForwardItemIdentifier&, Ref<WebCore::HistoryItem>&&, WebCore::PageIdentifier, OverwriteExistingItem);
     51        Optional<uint32_t> forwardCount;
     52        decoder >> forwardCount;
     53        if (!forwardCount)
     54            return WTF::nullopt;
    5255
    53     void clear();
    54 
    55 private:
    56     WebBackForwardListProxy(WebPage&);
    57 
    58     void addItem(Ref<WebCore::HistoryItem>&&) override;
    59 
    60     void goToItem(WebCore::HistoryItem&) override;
    61        
    62     RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
    63     unsigned backListCount() const override;
    64     unsigned forwardListCount() const override;
    65 
    66     void close() override;
    67 
    68     WebPage* m_page;
     56        return WebBackForwardListCounts { *backCount, *forwardCount };
     57    }
    6958};
    7059
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp

    r254884 r255135  
    335335}
    336336
    337 void ProvisionalPageProxy::backForwardGoToItem(const WebCore::BackForwardItemIdentifier& identifier, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler)
     337void ProvisionalPageProxy::backForwardGoToItem(const WebCore::BackForwardItemIdentifier& identifier, CompletionHandler<void(SandboxExtension::Handle&&, const WebBackForwardListCounts&)>&& completionHandler)
    338338{
    339339    m_page.backForwardGoToItemShared(m_process.copyRef(), identifier, WTFMove(completionHandler));
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h

    r254884 r255135  
    124124    void didFailProvisionalLoadForFrame(WebCore::FrameIdentifier, WebCore::SecurityOriginData&& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, WebCore::WillContinueLoading, const UserData&);
    125125    void startURLSchemeTask(URLSchemeTaskParameters&&);
    126     void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&);
     126    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&, const WebBackForwardListCounts&)>&&);
    127127    void decidePolicyForNavigationActionSync(WebCore::FrameIdentifier, bool isMainFrame, WebCore::SecurityOriginData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&,
    128128        FrameInfoData&&, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody,
  • trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp

    r254046 r255135  
    3131#include "SessionState.h"
    3232#include "WebBackForwardCache.h"
     33#include "WebBackForwardListCounts.h"
    3334#include "WebPageProxy.h"
    3435#include <WebCore/DiagnosticLoggingClient.h>
     
    275276}
    276277
     278WebBackForwardListCounts WebBackForwardList::counts() const
     279{
     280    return WebBackForwardListCounts { backListCount(), forwardListCount() };
     281}
     282
    277283Ref<API::Array> WebBackForwardList::backList() const
    278284{
  • trunk/Source/WebKit/UIProcess/WebBackForwardList.h

    r239427 r255135  
    3636
    3737struct BackForwardListState;
     38struct WebBackForwardListCounts;
    3839
    3940class WebBackForwardList : public API::ObjectImpl<API::Object::Type::BackForwardList> {
     
    6364    unsigned backListCount() const;
    6465    unsigned forwardListCount() const;
     66    WebBackForwardListCounts counts() const;
    6567
    6668    Ref<API::Array> backList() const;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r254886 r255135  
    9797#include "WebBackForwardCache.h"
    9898#include "WebBackForwardList.h"
     99#include "WebBackForwardListCounts.h"
    99100#include "WebBackForwardListItem.h"
    100101#include "WebCertificateInfo.h"
     
    60426043}
    60436044
    6044 void WebPageProxy::backForwardGoToItem(const BackForwardItemIdentifier& itemID, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler)
     6045void WebPageProxy::backForwardGoToItem(const BackForwardItemIdentifier& itemID, CompletionHandler<void(SandboxExtension::Handle&&, const WebBackForwardListCounts&)>&& completionHandler)
    60456046{
    60466047    // On process swap, we tell the previous process to ignore the load, which causes it so restore its current back forward item to its previous
     
    60486049    // Any real new load in the committed process would have cleared m_provisionalPage.
    60496050    if (m_provisionalPage)
    6050         return completionHandler({ });
     6051        return completionHandler({ }, m_backForwardList->counts());
    60516052
    60526053    SandboxExtension::Handle sandboxExtensionHandle;
     
    60546055}
    60556056
    6056 void WebPageProxy::backForwardGoToItemShared(Ref<WebProcessProxy>&& process, const BackForwardItemIdentifier& itemID, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler)
     6057void WebPageProxy::backForwardGoToItemShared(Ref<WebProcessProxy>&& process, const BackForwardItemIdentifier& itemID, CompletionHandler<void(SandboxExtension::Handle&&, const WebBackForwardListCounts&)>&& completionHandler)
    60576058{
    60586059    auto* item = m_backForwardList->itemForID(itemID);
    60596060    if (!item)
    6060         return completionHandler({ });
     6061        return completionHandler({ }, m_backForwardList->counts());
    60616062
    60626063    SandboxExtension::Handle sandboxExtensionHandle;
    60636064    maybeInitializeSandboxExtensionHandle(process, URL(URL(), item->url()), item->resourceDirectoryURL(),  sandboxExtensionHandle);
    60646065    m_backForwardList->goToItem(*item);
    6065     completionHandler(WTFMove(sandboxExtensionHandle));
     6066    completionHandler(WTFMove(sandboxExtensionHandle), m_backForwardList->counts());
    60666067}
    60676068
     
    60746075}
    60756076
    6076 void WebPageProxy::backForwardBackListCount(CompletionHandler<void(uint32_t)>&& completionHandler)
    6077 {
    6078     completionHandler(m_backForwardList->backListCount());
    6079 }
    6080 
    6081 void WebPageProxy::backForwardForwardListCount(CompletionHandler<void(uint32_t)>&& completionHandler)
    6082 {
    6083     completionHandler(m_backForwardList->forwardListCount());
     6077void WebPageProxy::backForwardListCounts(Messages::WebPageProxy::BackForwardListCountsDelayedReply&& completionHandler)
     6078{
     6079    completionHandler(m_backForwardList->counts());
    60846080}
    60856081
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r255054 r255135  
    309309
    310310struct AttributedString;
     311struct WebBackForwardListCounts;
    311312struct ColorSpaceData;
    312313struct DataDetectionResult;
     
    15961597    void loadDataWithNavigationShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt, WebCore::ShouldOpenExternalURLsPolicy = WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow);
    15971598    void loadRequestWithNavigationShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&& = WTF::nullopt);
    1598     void backForwardGoToItemShared(Ref<WebProcessProxy>&&, const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&);
     1599    void backForwardGoToItemShared(Ref<WebProcessProxy>&&, const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&, const WebBackForwardListCounts&)>&&);
    15991600    void decidePolicyForNavigationActionSyncShared(Ref<WebProcessProxy>&&, WebCore::FrameIdentifier, bool isMainFrame, WebCore::SecurityOriginData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&,
    16001601        FrameInfoData&&, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody,
     
    18941895    // Back/Forward list management
    18951896    void backForwardAddItem(BackForwardListItemState&&);
    1896     void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&);
     1897    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&, const WebBackForwardListCounts&)>&&);
    18971898    void backForwardItemAtIndex(int32_t index, CompletionHandler<void(Optional<WebCore::BackForwardItemIdentifier>&&)>&&);
    1898     void backForwardBackListCount(CompletionHandler<void(uint32_t)>&&);
    1899     void backForwardForwardListCount(CompletionHandler<void(uint32_t)>&&);
     1899    void backForwardListCounts(Messages::WebPageProxy::BackForwardListCountsDelayedReply&&);
    19001900    void backForwardClear();
    19011901
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r254312 r255135  
    225225    # BackForward messages
    226226    BackForwardAddItem(struct WebKit::BackForwardListItemState itemState)
    227     BackForwardGoToItem(struct WebCore::BackForwardItemIdentifier itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle) Synchronous
     227    BackForwardGoToItem(struct WebCore::BackForwardItemIdentifier itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle, struct WebKit::WebBackForwardListCounts counts) Synchronous
    228228    BackForwardItemAtIndex(int32_t itemIndex) -> (Optional<WebCore::BackForwardItemIdentifier> itemID) Synchronous
    229     BackForwardBackListCount() -> (uint32_t count) Synchronous
    230     BackForwardForwardListCount() -> (uint32_t count) Synchronous
     229    BackForwardListCounts() -> (struct WebKit::WebBackForwardListCounts counts) Synchronous
    231230    BackForwardClear()
    232231    WillGoToBackForwardListItem(struct WebCore::BackForwardItemIdentifier itemID, bool inBackForwardCache)
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r254931 r255135  
    951951                46BEB6E322FBB21A00269867 /* TransientLocalStorageNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 46BEB6E122FBB21A00269867 /* TransientLocalStorageNamespace.h */; };
    952952                46C392292316EC4D008EED9B /* WebPageProxyIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C392282316EC4D008EED9B /* WebPageProxyIdentifier.h */; };
     953                46CE3B1123D8C8490016A96A /* WebBackForwardListCounts.h in Headers */ = {isa = PBXBuildFile; fileRef = 46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */; };
    953954                46DF063C1F3905F8001980BB /* NetworkCORSPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */; };
    954955                46F77D8023BE63BE0090B5A7 /* DependencyProcessAssertion.h in Headers */ = {isa = PBXBuildFile; fileRef = 46F77D7E23BE63B10090B5A7 /* DependencyProcessAssertion.h */; };
     
    34903491                46BEB6E222FBB21A00269867 /* TransientLocalStorageNamespace.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TransientLocalStorageNamespace.cpp; sourceTree = "<group>"; };
    34913492                46C392282316EC4D008EED9B /* WebPageProxyIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPageProxyIdentifier.h; sourceTree = "<group>"; };
     3493                46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListCounts.h; sourceTree = "<group>"; };
    34923494                46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCORSPreflightChecker.cpp; sourceTree = "<group>"; };
    34933495                46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCORSPreflightChecker.h; sourceTree = "<group>"; };
     
    57595761                                2684054A18B866FF0022C38B /* VisibleContentRectUpdateInfo.cpp */,
    57605762                                2684054218B85A630022C38B /* VisibleContentRectUpdateInfo.h */,
     5763                                46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */,
    57615764                                518D2CAB12D5153B003BB93B /* WebBackForwardListItem.cpp */,
    57625765                                518D2CAC12D5153B003BB93B /* WebBackForwardListItem.h */,
     
    1056810571                                46F9B26323526EF3006FE5FA /* WebBackForwardCacheEntry.h in Headers */,
    1056910572                                BC72BA1E11E64907001EB4EA /* WebBackForwardList.h in Headers */,
     10573                                46CE3B1123D8C8490016A96A /* WebBackForwardListCounts.h in Headers */,
    1057010574                                518D2CAE12D5153B003BB93B /* WebBackForwardListItem.h in Headers */,
    1057110575                                BC72B9FB11E6476B001EB4EA /* WebBackForwardListProxy.h in Headers */,
  • trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp

    r251220 r255135  
    6161    ASSERT_UNUSED(overwriteExistingItem, overwriteExistingItem == OverwriteExistingItem::Yes || !idToHistoryItemMap().contains(itemID));
    6262    idToHistoryItemMap().set(itemID, item.ptr());
     63    clearCachedListCounts();
    6364}
    6465
     
    9899
    99100    LOG(BackForward, "(Back/Forward) WebProcess pid %i setting item %p for id %s with url %s", getCurrentProcessID(), item.ptr(), item->identifier().logString(), item->urlString().utf8().data());
     101    clearCachedListCounts();
    100102    m_page->send(Messages::WebPageProxy::BackForwardAddItem(toBackForwardListItemState(item.get())));
    101103}
     
    107109
    108110    SandboxExtension::Handle sandboxExtensionHandle;
    109     m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(item.identifier()), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle));
     111    WebBackForwardListCounts backForwardListCounts;
     112    m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(item.identifier()), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle, backForwardListCounts));
     113    m_cachedBackForwardListCounts = backForwardListCounts;
    110114    m_page->sandboxExtensionTracker().beginLoad(m_page->mainWebFrame(), WTFMove(sandboxExtensionHandle));
    111115}
     
    128132unsigned WebBackForwardListProxy::backListCount() const
    129133{
    130     if (!m_page)
    131         return 0;
    132 
    133     unsigned backListCount = 0;
    134     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardBackListCount(), Messages::WebPageProxy::BackForwardBackListCount::Reply(backListCount), m_page->identifier()))
    135         return 0;
    136 
    137     return backListCount;
     134    return cacheListCountsIfNecessary().backCount;
    138135}
    139136
    140137unsigned WebBackForwardListProxy::forwardListCount() const
    141138{
    142     if (!m_page)
    143         return 0;
     139    return cacheListCountsIfNecessary().forwardCount;
     140}
    144141
    145     unsigned forwardListCount = 0;
    146     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardForwardListCount(), Messages::WebPageProxy::BackForwardForwardListCount::Reply(forwardListCount), m_page->identifier()))
    147         return 0;
     142const WebBackForwardListCounts& WebBackForwardListProxy::cacheListCountsIfNecessary() const
     143{
     144    if (!m_cachedBackForwardListCounts) {
     145        WebBackForwardListCounts backForwardListCounts;
     146        if (m_page)
     147            WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardListCounts(), Messages::WebPageProxy::BackForwardListCounts::Reply(backForwardListCounts), m_page->identifier());
     148        m_cachedBackForwardListCounts = backForwardListCounts;
     149    }
     150    return *m_cachedBackForwardListCounts;
     151}
    148152
    149     return forwardListCount;
     153void WebBackForwardListProxy::clearCachedListCounts()
     154{
     155    m_cachedBackForwardListCounts = WTF::nullopt;
    150156}
    151157
     
    154160    ASSERT(m_page);
    155161    m_page = nullptr;
     162    m_cachedBackForwardListCounts = WebBackForwardListCounts { };
    156163}
    157164
    158165void WebBackForwardListProxy::clear()
    159166{
     167    m_cachedBackForwardListCounts = WebBackForwardListCounts { }; // Clearing the back/forward list will cause the counts to become 0.
    160168    m_page->send(Messages::WebPageProxy::BackForwardClear());
    161169}
  • trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h

    r245796 r255135  
    2626#pragma once
    2727
     28#include "WebBackForwardListCounts.h"
    2829#include <WebCore/BackForwardClient.h>
    2930#include <WebCore/PageIdentifier.h>
     
    6364    unsigned backListCount() const override;
    6465    unsigned forwardListCount() const override;
     66    const WebBackForwardListCounts& cacheListCountsIfNecessary() const;
     67    void clearCachedListCounts();
    6568
    6669    void close() override;
    6770
    6871    WebPage* m_page;
     72    mutable Optional<WebBackForwardListCounts> m_cachedBackForwardListCounts;
    6973};
    7074
Note: See TracChangeset for help on using the changeset viewer.