Title: [289336] branches/safari-613-branch/Source/WebKit
Revision
289336
Author
[email protected]
Date
2022-02-07 18:57:17 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r288924. rdar://problem/87163253

    Write origin file when OriginStorageManager is destroyed
    https://bugs.webkit.org/show_bug.cgi?id=235897
    rdar://87163253

    Reviewed by Darin Adler.

    The first WebStorage message sent from web process to network process is sync, and writing origin file when
    creating OriginStorageManager will delay the reply. Since we can get the origin information from in-memory map
    when OriginStorageManager is present, we may delay the write to until when OriginStorageManager is destroyed.
    This fixes the PLT regression from r286936.

    * NetworkProcess/storage/NetworkStorageManager.cpp:
    (WebKit::NetworkStorageManager::localOriginStorageManager):
    * NetworkProcess/storage/OriginStorageManager.cpp:
    (WebKit::OriginStorageManager::OriginStorageManager):
    (WebKit::OriginStorageManager::~OriginStorageManager):
    * NetworkProcess/storage/OriginStorageManager.h:

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

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (289335 => 289336)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:57:13 UTC (rev 289335)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:57:17 UTC (rev 289336)
@@ -1,5 +1,50 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288924. rdar://problem/87163253
+
+    Write origin file when OriginStorageManager is destroyed
+    https://bugs.webkit.org/show_bug.cgi?id=235897
+    rdar://87163253
+    
+    Reviewed by Darin Adler.
+    
+    The first WebStorage message sent from web process to network process is sync, and writing origin file when
+    creating OriginStorageManager will delay the reply. Since we can get the origin information from in-memory map
+    when OriginStorageManager is present, we may delay the write to until when OriginStorageManager is destroyed.
+    This fixes the PLT regression from r286936.
+    
+    * NetworkProcess/storage/NetworkStorageManager.cpp:
+    (WebKit::NetworkStorageManager::localOriginStorageManager):
+    * NetworkProcess/storage/OriginStorageManager.cpp:
+    (WebKit::OriginStorageManager::OriginStorageManager):
+    (WebKit::OriginStorageManager::~OriginStorageManager):
+    * NetworkProcess/storage/OriginStorageManager.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-01  Sihui Liu  <[email protected]>
+
+            Write origin file when OriginStorageManager is destroyed
+            https://bugs.webkit.org/show_bug.cgi?id=235897
+            rdar://87163253
+
+            Reviewed by Darin Adler.
+
+            The first WebStorage message sent from web process to network process is sync, and writing origin file when
+            creating OriginStorageManager will delay the reply. Since we can get the origin information from in-memory map
+            when OriginStorageManager is present, we may delay the write to until when OriginStorageManager is destroyed.
+            This fixes the PLT regression from r286936.
+
+            * NetworkProcess/storage/NetworkStorageManager.cpp:
+            (WebKit::NetworkStorageManager::localOriginStorageManager):
+            * NetworkProcess/storage/OriginStorageManager.cpp:
+            (WebKit::OriginStorageManager::OriginStorageManager):
+            (WebKit::OriginStorageManager::~OriginStorageManager):
+            * NetworkProcess/storage/OriginStorageManager.h:
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288922. rdar://problem/88172449
 
     [WP] Remove PostScript conversion code

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp (289335 => 289336)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp	2022-02-08 02:57:13 UTC (rev 289335)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp	2022-02-08 02:57:17 UTC (rev 289336)
@@ -210,8 +210,12 @@
 
     return *m_localOriginStorageManagers.ensure(origin, [&] {
         auto originDirectory = originDirectoryPath(m_path, origin, m_salt);
-        writeOriginToFileIfNecessary(originFilePath(originDirectory), origin);
-        return makeUnique<OriginStorageManager>(WTFMove(originDirectory), LocalStorageManager::localStorageFilePath(m_customLocalStoragePath, origin));
+        // We write origin file at when OriginStorageManager is destroyed to avoid delay
+        // in replying sync messages for Web Storage API.
+        auto writeOriginFileFunction = [originFile = originFilePath(originDirectory), origin]() {
+            writeOriginToFileIfNecessary(originFile, origin);
+        };
+        return makeUnique<OriginStorageManager>(WTFMove(writeOriginFileFunction), WTFMove(originDirectory), LocalStorageManager::localStorageFilePath(m_customLocalStoragePath, origin));
     }).iterator->value;
 }
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp (289335 => 289336)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp	2022-02-08 02:57:13 UTC (rev 289335)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp	2022-02-08 02:57:17 UTC (rev 289336)
@@ -269,14 +269,19 @@
     std::unique_ptr<SessionStorageManager> m_sessionStorageManager;
 };
 
-OriginStorageManager::OriginStorageManager(String&& path, String&& localStoragePath)
-    : m_path(WTFMove(path))
+OriginStorageManager::OriginStorageManager(Function<void()>&& writeOriginFileFunction, String&& path, String&& localStoragePath)
+    : m_writeOriginFileFunction(WTFMove(writeOriginFileFunction))
+    , m_path(WTFMove(path))
     , m_localStoragePath(WTFMove(localStoragePath))
 {
     ASSERT(!RunLoop::isMain());
 }
 
-OriginStorageManager::~OriginStorageManager() = default;
+OriginStorageManager::~OriginStorageManager()
+{
+    if (m_writeOriginFileFunction)
+        m_writeOriginFileFunction();
+}
 
 void OriginStorageManager::connectionClosed(IPC::Connection::UniqueID connection)
 {

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/OriginStorageManager.h (289335 => 289336)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/OriginStorageManager.h	2022-02-08 02:57:13 UTC (rev 289335)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/storage/OriginStorageManager.h	2022-02-08 02:57:17 UTC (rev 289336)
@@ -44,7 +44,7 @@
 class OriginStorageManager {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    OriginStorageManager(String&& path, String&& localStoragePath);
+    OriginStorageManager(Function<void()>&&, String&& path, String&& localStoragePath);
     ~OriginStorageManager();
 
     void connectionClosed(IPC::Connection::UniqueID);
@@ -69,6 +69,7 @@
     void createOriginFileIfNecessary(const WebCore::ClientOrigin&);
     void deleteOriginFileIfNecessary();
 
+    Function<void()> m_writeOriginFileFunction;
     std::unique_ptr<StorageBucket> m_defaultBucket;
     String m_path;
     bool m_persisted { false };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to