Title: [247617] branches/safari-608-branch/Source
Revision
247617
Author
kocsen_ch...@apple.com
Date
2019-07-18 13:26:03 -0700 (Thu, 18 Jul 2019)

Log Message

Cherry-pick r247555. rdar://problem/53254411

    Prewarm local storage in the NetworkProcess to reduce WebContent process hangs
    https://bugs.webkit.org/show_bug.cgi?id=199879
    <rdar://problem/53217757>

    Reviewed by Ryosuke Niwa.

    Source/WebCore:

    When JS accesses window.localStorage for the first time, we end up doing a
    synchronous IPC to the network process to pull in all items in the local
    storage for the origin. If the network process does not have this data in
    memory, it has to read it from a database on disk, which may take a significant
    amount of time and hang the WebContent process during this time.

    To alleviate this problem, this patch introduces prewarming on the local storage
    in the network process when loading a given origin in the WebContent process.
    This way, in most cases, when the JS accesses window.localStorage for the first
    time, the synchronous IPC to the network process returns much faster (measured
    50-100ms for a very large database, down from 250-300ms), as it only needs to
    IPC the data over, without the need to fetch it from disk.

    As a safety net to avoid excessive prewarming, we currently prewarm at most 5
    security origins per page load.

    * loader/DocumentLoader.cpp:
    (WebCore::DocumentLoader::commitData):
    * page/DOMWindow.cpp:
    (WebCore::DOMWindow::prewarmLocalStorageIfNecessary):
    * page/DOMWindow.h:
    * page/Frame.cpp:
    (WebCore::Frame::didPrewarmLocalStorage):
    (WebCore::Frame::mayPrewarmLocalStorage const):
    * page/Frame.h:
    * storage/Storage.cpp:
    (WebCore::Storage::prewarm):
    * storage/Storage.h:
    * storage/StorageArea.h:
    (WebCore::StorageArea::prewarm):

    Source/WebKit:

    * NetworkProcess/WebStorage/StorageManager.cpp:
    (WebKit::StorageManager::prewarm):
    (WebKit::StorageManager::getValues):
    * NetworkProcess/WebStorage/StorageManager.h:
    * NetworkProcess/WebStorage/StorageManager.messages.in:
    * WebProcess/WebStorage/StorageAreaImpl.cpp:
    (WebKit::StorageAreaImpl::prewarm):
    * WebProcess/WebStorage/StorageAreaImpl.h:
    * WebProcess/WebStorage/StorageAreaMap.cpp:
    (WebKit::StorageAreaMap::loadValuesIfNeeded):
    (WebKit::StorageAreaMap::prewarm):
    * WebProcess/WebStorage/StorageAreaMap.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247555 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-18 20:26:03 UTC (rev 247617)
@@ -1,3 +1,103 @@
+2019-07-18  Kocsen Chung  <kocsen_ch...@apple.com>
+
+        Cherry-pick r247555. rdar://problem/53254411
+
+    Prewarm local storage in the NetworkProcess to reduce WebContent process hangs
+    https://bugs.webkit.org/show_bug.cgi?id=199879
+    <rdar://problem/53217757>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebCore:
+    
+    When JS accesses window.localStorage for the first time, we end up doing a
+    synchronous IPC to the network process to pull in all items in the local
+    storage for the origin. If the network process does not have this data in
+    memory, it has to read it from a database on disk, which may take a significant
+    amount of time and hang the WebContent process during this time.
+    
+    To alleviate this problem, this patch introduces prewarming on the local storage
+    in the network process when loading a given origin in the WebContent process.
+    This way, in most cases, when the JS accesses window.localStorage for the first
+    time, the synchronous IPC to the network process returns much faster (measured
+    50-100ms for a very large database, down from 250-300ms), as it only needs to
+    IPC the data over, without the need to fetch it from disk.
+    
+    As a safety net to avoid excessive prewarming, we currently prewarm at most 5
+    security origins per page load.
+    
+    * loader/DocumentLoader.cpp:
+    (WebCore::DocumentLoader::commitData):
+    * page/DOMWindow.cpp:
+    (WebCore::DOMWindow::prewarmLocalStorageIfNecessary):
+    * page/DOMWindow.h:
+    * page/Frame.cpp:
+    (WebCore::Frame::didPrewarmLocalStorage):
+    (WebCore::Frame::mayPrewarmLocalStorage const):
+    * page/Frame.h:
+    * storage/Storage.cpp:
+    (WebCore::Storage::prewarm):
+    * storage/Storage.h:
+    * storage/StorageArea.h:
+    (WebCore::StorageArea::prewarm):
+    
+    Source/WebKit:
+    
+    * NetworkProcess/WebStorage/StorageManager.cpp:
+    (WebKit::StorageManager::prewarm):
+    (WebKit::StorageManager::getValues):
+    * NetworkProcess/WebStorage/StorageManager.h:
+    * NetworkProcess/WebStorage/StorageManager.messages.in:
+    * WebProcess/WebStorage/StorageAreaImpl.cpp:
+    (WebKit::StorageAreaImpl::prewarm):
+    * WebProcess/WebStorage/StorageAreaImpl.h:
+    * WebProcess/WebStorage/StorageAreaMap.cpp:
+    (WebKit::StorageAreaMap::loadValuesIfNeeded):
+    (WebKit::StorageAreaMap::prewarm):
+    * WebProcess/WebStorage/StorageAreaMap.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-17  Chris Dumez  <cdu...@apple.com>
+
+            Prewarm local storage in the NetworkProcess to reduce WebContent process hangs
+            https://bugs.webkit.org/show_bug.cgi?id=199879
+            <rdar://problem/53217757>
+
+            Reviewed by Ryosuke Niwa.
+
+            When JS accesses window.localStorage for the first time, we end up doing a
+            synchronous IPC to the network process to pull in all items in the local
+            storage for the origin. If the network process does not have this data in
+            memory, it has to read it from a database on disk, which may take a significant
+            amount of time and hang the WebContent process during this time.
+
+            To alleviate this problem, this patch introduces prewarming on the local storage
+            in the network process when loading a given origin in the WebContent process.
+            This way, in most cases, when the JS accesses window.localStorage for the first
+            time, the synchronous IPC to the network process returns much faster (measured
+            50-100ms for a very large database, down from 250-300ms), as it only needs to
+            IPC the data over, without the need to fetch it from disk.
+
+            As a safety net to avoid excessive prewarming, we currently prewarm at most 5
+            security origins per page load.
+
+            * loader/DocumentLoader.cpp:
+            (WebCore::DocumentLoader::commitData):
+            * page/DOMWindow.cpp:
+            (WebCore::DOMWindow::prewarmLocalStorageIfNecessary):
+            * page/DOMWindow.h:
+            * page/Frame.cpp:
+            (WebCore::Frame::didPrewarmLocalStorage):
+            (WebCore::Frame::mayPrewarmLocalStorage const):
+            * page/Frame.h:
+            * storage/Storage.cpp:
+            (WebCore::Storage::prewarm):
+            * storage/Storage.h:
+            * storage/StorageArea.h:
+            (WebCore::StorageArea::prewarm):
+
 2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r247544. rdar://problem/53230040

Modified: branches/safari-608-branch/Source/WebCore/loader/DocumentLoader.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/loader/DocumentLoader.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/loader/DocumentLoader.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -1084,6 +1084,9 @@
         if (!isLoading())
             return;
 
+        if (auto* window = m_frame->document()->domWindow())
+            window->prewarmLocalStorageIfNecessary();
+
         bool userChosen;
         String encoding;
         if (overrideEncoding().isNull()) {

Modified: branches/safari-608-branch/Source/WebCore/page/DOMWindow.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/page/DOMWindow.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/page/DOMWindow.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -423,6 +423,29 @@
     m_performance = nullptr;
 }
 
+void DOMWindow::prewarmLocalStorageIfNecessary()
+{
+    auto* page = this->page();
+
+    // No need to prewarm for ephemeral sessions since the data is in memory only.
+    if (!page || page->usesEphemeralSession())
+        return;
+
+    if (!page->mainFrame().mayPrewarmLocalStorage())
+        return;
+
+    auto localStorageResult = this->localStorage();
+    if (localStorageResult.hasException())
+        return;
+
+    auto* localStorage = localStorageResult.returnValue();
+    if (!localStorage)
+        return;
+
+    if (localStorage->prewarm())
+        page->mainFrame().didPrewarmLocalStorage();
+}
+
 DOMWindow::~DOMWindow()
 {
     if (m_suspendedForDocumentSuspension)

Modified: branches/safari-608-branch/Source/WebCore/page/DOMWindow.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/page/DOMWindow.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/page/DOMWindow.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -181,6 +181,8 @@
 
     void showModalDialog(const String& urlString, const String& dialogFeaturesString, DOMWindow& activeWindow, DOMWindow& firstWindow, const WTF::Function<void(DOMWindow&)>& prepareDialogFunction);
 
+    void prewarmLocalStorageIfNecessary();
+
     void alert(const String& message = emptyString());
     bool confirm(const String& message);
     String prompt(const String& message, const String& defaultValue);

Modified: branches/safari-608-branch/Source/WebCore/page/Frame.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/page/Frame.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/page/Frame.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -117,6 +117,9 @@
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, frameCounter, ("Frame"));
 
+// We prewarm local storage for at most 5 origins in a given page.
+static const unsigned maxlocalStoragePrewarmingCount { 5 };
+
 static inline Frame* parentFromOwnerElement(HTMLFrameOwnerElement* ownerElement)
 {
     if (!ownerElement)
@@ -992,6 +995,19 @@
         tree().removeChild(*child);
 }
 
+void Frame::didPrewarmLocalStorage()
+{
+    ASSERT(isMainFrame());
+    ASSERT(m_localStoragePrewarmingCount < maxlocalStoragePrewarmingCount);
+    ++m_localStoragePrewarmingCount;
+}
+
+bool Frame::mayPrewarmLocalStorage() const
+{
+    ASSERT(isMainFrame());
+    return m_localStoragePrewarmingCount < maxlocalStoragePrewarmingCount;
+}
+
 void Frame::selfOnlyRef()
 {
     ASSERT(isMainFrame());

Modified: branches/safari-608-branch/Source/WebCore/page/Frame.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/page/Frame.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/page/Frame.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -290,6 +290,9 @@
     bool isURLAllowed(const URL&) const;
     WEBCORE_EXPORT bool isAlwaysOnLoggingAllowed() const;
 
+    void didPrewarmLocalStorage();
+    bool mayPrewarmLocalStorage() const;
+
 // ========
 
     void selfOnlyRef();
@@ -349,6 +352,7 @@
     unsigned m_navigationDisableCount { 0 };
     unsigned m_selfOnlyRefCount { 0 };
     bool m_hasHadUserInteraction { false };
+    unsigned m_localStoragePrewarmingCount { 0 };
 
 protected:
     UniqueRef<EventHandler> m_eventHandler;

Modified: branches/safari-608-branch/Source/WebCore/storage/Storage.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/storage/Storage.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/storage/Storage.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -97,6 +97,11 @@
     return { };
 }
 
+bool Storage::prewarm()
+{
+    return m_storageArea->prewarm();
+}
+
 ExceptionOr<void> Storage::clear()
 {
     auto* frame = this->frame();

Modified: branches/safari-608-branch/Source/WebCore/storage/Storage.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/storage/Storage.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/storage/Storage.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -46,6 +46,7 @@
     ExceptionOr<void> removeItem(const String& key);
     ExceptionOr<void> clear();
     bool contains(const String& key) const;
+    bool prewarm();
 
     // Bindings support functions.
     bool isSupportedPropertyName(const String&) const;

Modified: branches/safari-608-branch/Source/WebCore/storage/StorageArea.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebCore/storage/StorageArea.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebCore/storage/StorageArea.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -58,6 +58,7 @@
     virtual void incrementAccessCount() { }
     virtual void decrementAccessCount() { }
     virtual void closeDatabaseIfIdle() { }
+    virtual bool prewarm() { return false; }
 
     virtual const SecurityOriginData& securityOrigin() const = 0;
 };

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-07-18 20:26:03 UTC (rev 247617)
@@ -1,3 +1,85 @@
+2019-07-18  Kocsen Chung  <kocsen_ch...@apple.com>
+
+        Cherry-pick r247555. rdar://problem/53254411
+
+    Prewarm local storage in the NetworkProcess to reduce WebContent process hangs
+    https://bugs.webkit.org/show_bug.cgi?id=199879
+    <rdar://problem/53217757>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Source/WebCore:
+    
+    When JS accesses window.localStorage for the first time, we end up doing a
+    synchronous IPC to the network process to pull in all items in the local
+    storage for the origin. If the network process does not have this data in
+    memory, it has to read it from a database on disk, which may take a significant
+    amount of time and hang the WebContent process during this time.
+    
+    To alleviate this problem, this patch introduces prewarming on the local storage
+    in the network process when loading a given origin in the WebContent process.
+    This way, in most cases, when the JS accesses window.localStorage for the first
+    time, the synchronous IPC to the network process returns much faster (measured
+    50-100ms for a very large database, down from 250-300ms), as it only needs to
+    IPC the data over, without the need to fetch it from disk.
+    
+    As a safety net to avoid excessive prewarming, we currently prewarm at most 5
+    security origins per page load.
+    
+    * loader/DocumentLoader.cpp:
+    (WebCore::DocumentLoader::commitData):
+    * page/DOMWindow.cpp:
+    (WebCore::DOMWindow::prewarmLocalStorageIfNecessary):
+    * page/DOMWindow.h:
+    * page/Frame.cpp:
+    (WebCore::Frame::didPrewarmLocalStorage):
+    (WebCore::Frame::mayPrewarmLocalStorage const):
+    * page/Frame.h:
+    * storage/Storage.cpp:
+    (WebCore::Storage::prewarm):
+    * storage/Storage.h:
+    * storage/StorageArea.h:
+    (WebCore::StorageArea::prewarm):
+    
+    Source/WebKit:
+    
+    * NetworkProcess/WebStorage/StorageManager.cpp:
+    (WebKit::StorageManager::prewarm):
+    (WebKit::StorageManager::getValues):
+    * NetworkProcess/WebStorage/StorageManager.h:
+    * NetworkProcess/WebStorage/StorageManager.messages.in:
+    * WebProcess/WebStorage/StorageAreaImpl.cpp:
+    (WebKit::StorageAreaImpl::prewarm):
+    * WebProcess/WebStorage/StorageAreaImpl.h:
+    * WebProcess/WebStorage/StorageAreaMap.cpp:
+    (WebKit::StorageAreaMap::loadValuesIfNeeded):
+    (WebKit::StorageAreaMap::prewarm):
+    * WebProcess/WebStorage/StorageAreaMap.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-17  Chris Dumez  <cdu...@apple.com>
+
+            Prewarm local storage in the NetworkProcess to reduce WebContent process hangs
+            https://bugs.webkit.org/show_bug.cgi?id=199879
+            <rdar://problem/53217757>
+
+            Reviewed by Ryosuke Niwa.
+
+            * NetworkProcess/WebStorage/StorageManager.cpp:
+            (WebKit::StorageManager::prewarm):
+            (WebKit::StorageManager::getValues):
+            * NetworkProcess/WebStorage/StorageManager.h:
+            * NetworkProcess/WebStorage/StorageManager.messages.in:
+            * WebProcess/WebStorage/StorageAreaImpl.cpp:
+            (WebKit::StorageAreaImpl::prewarm):
+            * WebProcess/WebStorage/StorageAreaImpl.h:
+            * WebProcess/WebStorage/StorageAreaMap.cpp:
+            (WebKit::StorageAreaMap::loadValuesIfNeeded):
+            (WebKit::StorageAreaMap::prewarm):
+            * WebProcess/WebStorage/StorageAreaMap.h:
+
 2019-07-17  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r247559. rdar://problem/53230035

Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -65,11 +65,11 @@
 
     bool isEphemeral() const { return !m_localStorageNamespace; }
 
+    void openDatabaseAndImportItemsIfNeeded() const;
+
 private:
     explicit StorageArea(LocalStorageNamespace*, const SecurityOriginData&, unsigned quotaInBytes);
 
-    void openDatabaseAndImportItemsIfNeeded() const;
-
     void dispatchEvents(IPC::Connection::UniqueID sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
 
     // Will be null if the storage area belongs to a session storage namespace or the storage area is in an ephemeral session.
@@ -845,9 +845,16 @@
     m_storageAreasByConnection.remove(connectionAndStorageMapIDPair);
 }
 
-void StorageManager::getValues(IPC::Connection& connection, WebCore::SecurityOriginData&& securityOriginData, uint64_t storageMapID, uint64_t storageMapSeed, GetValuesCallback&& completionHandler)
+void StorageManager::prewarm(IPC::Connection& connection, uint64_t storageMapID)
 {
     ASSERT(!RunLoop::isMain());
+    if (auto* storageArea = findStorageArea(connection, storageMapID))
+        storageArea->openDatabaseAndImportItemsIfNeeded();
+}
+
+void StorageManager::getValues(IPC::Connection& connection, uint64_t storageMapID, uint64_t storageMapSeed, GetValuesCallback&& completionHandler)
+{
+    ASSERT(!RunLoop::isMain());
     auto* storageArea = findStorageArea(connection, storageMapID);
 
     // This is a session storage area for a page that has already been closed. Ignore it.

Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -86,7 +86,8 @@
     void createSessionStorageMap(IPC::Connection&, uint64_t storageMapID, uint64_t storageNamespaceID, WebCore::SecurityOriginData&&);
     void destroyStorageMap(IPC::Connection&, uint64_t storageMapID);
 
-    void getValues(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageMapID, uint64_t storageMapSeed, GetValuesCallback&&);
+    void getValues(IPC::Connection&, uint64_t storageMapID, uint64_t storageMapSeed, GetValuesCallback&&);
+    void prewarm(IPC::Connection&, uint64_t storageMapID);
     void setItem(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& value, const String& urlString);
     void setItems(IPC::Connection&, uint64_t storageMapID, const HashMap<String, String>& items);
     void removeItem(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& urlString);

Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.messages.in (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.messages.in	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/WebStorage/StorageManager.messages.in	2019-07-18 20:26:03 UTC (rev 247617)
@@ -26,7 +26,8 @@
     CreateSessionStorageMap(uint64_t storageMapID, uint64_t storageNamespaceID, struct WebCore::SecurityOriginData securityOriginData) WantsConnection
     DestroyStorageMap(uint64_t storageMapID) WantsConnection
 
-    GetValues(struct WebCore::SecurityOriginData securityOriginData, uint64_t storageMapID, uint64_t storageMapSeed) -> (HashMap<String, String> values) Synchronous WantsConnection
+    Prewarm(uint64_t storageMapID) WantsConnection
+    GetValues(uint64_t storageMapID, uint64_t storageMapSeed) -> (HashMap<String, String> values) Synchronous WantsConnection
 
     SetItem(struct WebCore::SecurityOriginData securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String key, String value, String urlString) WantsConnection
     SetItems(uint64_t storageMapID, HashMap<String, String> items) WantsConnection

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -73,6 +73,11 @@
     return m_storageAreaMap->item(key);
 }
 
+bool StorageAreaImpl::prewarm()
+{
+    return m_storageAreaMap->prewarm();
+}
+
 void StorageAreaImpl::setItem(Frame* sourceFrame, const String& key, const String& value, bool& quotaException)
 {
     ASSERT(!value.isNull());

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -61,6 +61,7 @@
     void decrementAccessCount() override;
     void closeDatabaseIfIdle() override;
     const WebCore::SecurityOriginData& securityOrigin() const override;
+    bool prewarm() final;
 
     uint64_t m_storageAreaID;
     Ref<StorageAreaMap> m_storageAreaMap;

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp	2019-07-18 20:26:03 UTC (rev 247617)
@@ -178,7 +178,7 @@
     // FIXME: This should use a special sendSync flag to indicate that we don't want to process incoming messages while waiting for a reply.
     // (This flag does not yet exist). Since loadValuesIfNeeded() ends up being called from within _javascript_ code, processing incoming synchronous messages
     // could lead to weird reentrency bugs otherwise.
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::StorageManager::GetValues(m_securityOrigin->data(), m_storageMapID, m_currentSeed), Messages::StorageManager::GetValues::Reply(values), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::StorageManager::GetValues(m_storageMapID, m_currentSeed), Messages::StorageManager::GetValues::Reply(values), 0);
 
     m_storageMap = StorageMap::create(m_quotaInBytes);
     m_storageMap->importItems(WTFMove(values));
@@ -187,6 +187,17 @@
     m_hasPendingGetValues = true;
 }
 
+bool StorageAreaMap::prewarm()
+{
+    if (m_didPrewarm || m_storageMap)
+        return false;
+    m_didPrewarm = true;
+
+    connect();
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::StorageManager::Prewarm(m_storageMapID), 0);
+    return true;
+}
+
 void StorageAreaMap::didGetValues(uint64_t storageMapSeed)
 {
     if (m_currentSeed != storageMapSeed)

Modified: branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.h (247616 => 247617)


--- branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.h	2019-07-18 20:25:53 UTC (rev 247616)
+++ branches/safari-608-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.h	2019-07-18 20:26:03 UTC (rev 247617)
@@ -57,6 +57,7 @@
     void removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key);
     void clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea);
     bool contains(const String& key);
+    bool prewarm();
 
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
@@ -104,6 +105,7 @@
     HashCountedSet<String> m_pendingValueChanges;
 
     bool m_isDisconnected { true };
+    bool m_didPrewarm { false };
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to