Title: [242143] branches/safari-607-branch

Diff

Modified: branches/safari-607-branch/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (242142 => 242143)


--- branches/safari-607-branch/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2019-02-27 20:11:23 UTC (rev 242143)
@@ -1051,8 +1051,10 @@
 #endif
 
 #if PLATFORM(MAC)
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     if (supportsSubpixelAntialiasedFonts && acceleratesDrawing)
         return kCAContentsFormatRGBA8ColorRGBA8LinearGlyphMask;
+    ALLOW_DEPRECATED_DECLARATIONS_END
 #else
     UNUSED_PARAM(supportsSubpixelAntialiasedFonts);
     UNUSED_PARAM(acceleratesDrawing);

Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/ChangeLog	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog	2019-02-27 20:11:23 UTC (rev 242143)
@@ -1,5 +1,50 @@
 2019-02-27  Babak Shafiei  <bshaf...@apple.com>
 
+        Apply patch. rdar://problem/48429676
+
+    2019-02-27  Alex Christensen  <achristen...@webkit.org>
+
+            Move ephemeral local storage from WebProcess to UIProcess
+            https://bugs.webkit.org/show_bug.cgi?id=195074
+            <rdar://problem/47937975>
+
+            Reviewed by Geoff Garen.
+
+            Before PSON, a page could navigate to another domain that navigates back and still have its local storage.
+            Since PSON makes it unreliable to retain the state in the WebProcess, move it to the process with the rest of the local storage.
+            If it's ephemeral, we obviously can't use the SQLite on-disk storage implementation, so use the same WebCore::StorageMap we used to in the WebProcess.
+
+            * UIProcess/WebStorage/StorageManager.cpp:
+            (WebKit::StorageManager::LocalStorageNamespace::LocalStorageNamespace):
+            (WebKit::StorageManager::StorageManager):
+            (WebKit::StorageManager::createLocalStorageMap):
+            (WebKit::StorageManager::createTransientLocalStorageMap):
+            (WebKit::StorageManager::createSessionStorageMap):
+            (WebKit::StorageManager::destroyStorageMap):
+            (WebKit::StorageManager::getValues):
+            (WebKit::StorageManager::setItem):
+            (WebKit::StorageManager::removeItem):
+            (WebKit::StorageManager::clear):
+            * UIProcess/WebStorage/StorageManager.h:
+            * UIProcess/WebStorage/StorageManager.messages.in:
+            * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+            (WebKit::WebsiteDataStore::WebsiteDataStore):
+            * WebProcess/WebStorage/StorageAreaMap.cpp:
+            (WebKit::StorageAreaMap::StorageAreaMap):
+            (WebKit::StorageAreaMap::setItem):
+            (WebKit::StorageAreaMap::removeItem):
+            (WebKit::StorageAreaMap::clear):
+            (WebKit::StorageAreaMap::loadValuesIfNeeded):
+            * WebProcess/WebStorage/StorageNamespaceImpl.cpp:
+            (WebKit::StorageNamespaceImpl::createEphemeralLocalStorageNamespace):
+            (WebKit::StorageNamespaceImpl::storageArea):
+            (WebKit::StorageNamespaceImpl::copy):
+            (): Deleted.
+            (WebKit::StorageNamespaceImpl::ephemeralLocalStorageArea): Deleted.
+            * WebProcess/WebStorage/StorageNamespaceImpl.h:
+
+2019-02-27  Babak Shafiei  <bshaf...@apple.com>
+
         Cherry-pick r242099. rdar://problem/48429675
 
     [iOS] Regression(PSON) Scroll position is no longer restored when navigating back to reddit.com

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabaseTracker.cpp (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabaseTracker.cpp	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/LocalStorageDatabaseTracker.cpp	2019-02-27 20:11:23 UTC (rev 242143)
@@ -48,8 +48,6 @@
     : m_queue(WTFMove(queue))
     , m_localStorageDirectory(localStorageDirectory.isolatedCopy())
 {
-    ASSERT(!m_localStorageDirectory.isEmpty());
-
     // Make sure the encoding is initialized before we start dispatching things to the queue.
     UTF8Encoding();
 
@@ -153,7 +151,8 @@
 String LocalStorageDatabaseTracker::databasePath(const String& filename) const
 {
     if (!SQLiteFileSystem::ensureDatabaseDirectoryExists(m_localStorageDirectory)) {
-        LOG_ERROR("Unable to create LocalStorage database path %s", m_localStorageDirectory.utf8().data());
+        if (!m_localStorageDirectory.isNull())
+            LOG_ERROR("Unable to create LocalStorage database path %s", m_localStorageDirectory.utf8().data());
         return String();
     }
 

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.cpp (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.cpp	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.cpp	2019-02-27 20:11:23 UTC (rev 242143)
@@ -107,6 +107,9 @@
     HashMap<SecurityOriginData, StorageArea*> m_storageAreaMap;
 };
 
+// Suggested by https://www.w3.org/TR/webstorage/#disk-space
+const unsigned localStorageDatabaseQuotaInBytes = 5 * 1024 * 1024;
+
 class StorageManager::TransientLocalStorageNamespace : public ThreadSafeRefCounted<TransientLocalStorageNamespace> {
 public:
     static Ref<TransientLocalStorageNamespace> create()
@@ -156,7 +159,7 @@
     {
     }
 
-    const unsigned m_quotaInBytes = 5 * 1024 * 1024;
+    const unsigned m_quotaInBytes = localStorageDatabaseQuotaInBytes;
 
     HashMap<SecurityOriginData, RefPtr<StorageArea>> m_storageAreaMap;
 };
@@ -326,7 +329,7 @@
 StorageManager::LocalStorageNamespace::LocalStorageNamespace(StorageManager* storageManager, uint64_t storageNamespaceID)
     : m_storageManager(storageManager)
     , m_storageNamespaceID(storageNamespaceID)
-    , m_quotaInBytes(5 * 1024 * 1024)
+    , m_quotaInBytes(localStorageDatabaseQuotaInBytes)
 {
 }
 
@@ -464,6 +467,7 @@
 StorageManager::StorageManager(const String& localStorageDirectory)
     : m_queue(WorkQueue::create("com.apple.WebKit.StorageManager"))
     , m_localStorageDatabaseTracker(LocalStorageDatabaseTracker::create(m_queue.copyRef(), localStorageDirectory))
+    , m_isEphemeral(localStorageDirectory.isNull())
 {
     // Make sure the encoding is initialized before we start dispatching things to the queue.
     UTF8Encoding();
@@ -673,6 +677,7 @@
 
 void StorageManager::createLocalStorageMap(IPC::Connection& connection, uint64_t storageMapID, uint64_t storageNamespaceID, SecurityOriginData&& securityOriginData)
 {
+    ASSERT(!m_isEphemeral);
     std::pair<IPC::Connection::UniqueID, uint64_t> connectionAndStorageMapIDPair(connection.uniqueID(), storageMapID);
 
     // FIXME: This should be a message check.
@@ -736,6 +741,10 @@
 
 void StorageManager::createSessionStorageMap(IPC::Connection& connection, uint64_t storageMapID, uint64_t storageNamespaceID, SecurityOriginData&& securityOriginData)
 {
+    if (m_isEphemeral) {
+        m_ephemeralStorage.add(securityOriginData, WebCore::StorageMap::create(localStorageDatabaseQuotaInBytes));
+        return;
+    }
     // FIXME: This should be a message check.
     ASSERT(m_sessionStorageNamespaces.isValidKey(storageNamespaceID));
 
@@ -785,10 +794,16 @@
     m_storageAreasByConnection.remove(connectionAndStorageMapIDPair);
 }
 
-void StorageManager::getValues(IPC::Connection& connection, uint64_t storageMapID, uint64_t storageMapSeed, HashMap<String, String>& values)
+void StorageManager::getValues(IPC::Connection& connection, WebCore::SecurityOriginData&& securityOriginData, uint64_t storageMapID, uint64_t storageMapSeed, HashMap<String, String>& values)
 {
     StorageArea* storageArea = findStorageArea(connection, storageMapID);
     if (!storageArea) {
+        if (m_isEphemeral) {
+            if (auto storageMap = m_ephemeralStorage.get(securityOriginData)) {
+                values = storageMap->items();
+                return;
+            }
+        }
         // This is a session storage area for a page that has already been closed. Ignore it.
         return;
     }
@@ -797,10 +812,17 @@
     connection.send(Messages::StorageAreaMap::DidGetValues(storageMapSeed), storageMapID);
 }
 
-void StorageManager::setItem(IPC::Connection& connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& value, const String& urlString)
+void StorageManager::setItem(IPC::Connection& connection, WebCore::SecurityOriginData&& securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& value, const String& urlString)
 {
     StorageArea* storageArea = findStorageArea(connection, storageMapID);
     if (!storageArea) {
+        if (m_isEphemeral) {
+            if (auto storageMap = m_ephemeralStorage.get(securityOriginData)) {
+                String oldValue;
+                bool quotaException;
+                storageMap->setItem(key, value, oldValue, quotaException);
+            }
+        }
         // This is a session storage area for a page that has already been closed. Ignore it.
         return;
     }
@@ -810,10 +832,16 @@
     connection.send(Messages::StorageAreaMap::DidSetItem(storageMapSeed, key, quotaError), storageMapID);
 }
 
-void StorageManager::removeItem(IPC::Connection& connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& urlString)
+void StorageManager::removeItem(IPC::Connection& connection, WebCore::SecurityOriginData&& securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& urlString)
 {
     StorageArea* storageArea = findStorageArea(connection, storageMapID);
     if (!storageArea) {
+        if (m_isEphemeral) {
+            if (auto storageMap = m_ephemeralStorage.get(securityOriginData)) {
+                String oldValue;
+                storageMap->removeItem(key, oldValue);
+            }
+        }
         // This is a session storage area for a page that has already been closed. Ignore it.
         return;
     }
@@ -822,10 +850,12 @@
     connection.send(Messages::StorageAreaMap::DidRemoveItem(storageMapSeed, key), storageMapID);
 }
 
-void StorageManager::clear(IPC::Connection& connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& urlString)
+void StorageManager::clear(IPC::Connection& connection, WebCore::SecurityOriginData&& securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& urlString)
 {
     StorageArea* storageArea = findStorageArea(connection, storageMapID);
     if (!storageArea) {
+        if (m_isEphemeral)
+            m_ephemeralStorage.remove(securityOriginData);
         // This is a session storage area for a page that has already been closed. Ignore it.
         return;
     }

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.h (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.h	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.h	2019-02-27 20:11:23 UTC (rev 242143)
@@ -27,6 +27,8 @@
 
 #include "Connection.h"
 #include "LocalStorageDatabaseTracker.h"
+#include <WebCore/SecurityOriginData.h>
+#include <WebCore/StorageMap.h>
 #include <wtf/Forward.h>
 #include <wtf/Function.h>
 #include <wtf/HashSet.h>
@@ -81,10 +83,10 @@
     void createSessionStorageMap(IPC::Connection&, uint64_t storageMapID, uint64_t storageNamespaceID, WebCore::SecurityOriginData&&);
     void destroyStorageMap(IPC::Connection&, uint64_t storageMapID);
 
-    void getValues(IPC::Connection&, uint64_t storageMapID, uint64_t storageMapSeed, HashMap<String, String>& values);
-    void setItem(IPC::Connection&, uint64_t storageAreaID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& value, const String& urlString);
-    void removeItem(IPC::Connection&, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& urlString);
-    void clear(IPC::Connection&, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& urlString);
+    void getValues(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageMapID, uint64_t storageMapSeed, HashMap<String, String>& values);
+    void setItem(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageAreaID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& value, const String& urlString);
+    void removeItem(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& urlString);
+    void clear(IPC::Connection&, WebCore::SecurityOriginData&&, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& urlString);
 
     class StorageArea;
     StorageArea* findStorageArea(IPC::Connection&, uint64_t) const;
@@ -106,6 +108,9 @@
     HashMap<uint64_t, RefPtr<SessionStorageNamespace>> m_sessionStorageNamespaces;
 
     HashMap<std::pair<IPC::Connection::UniqueID, uint64_t>, RefPtr<StorageArea>> m_storageAreasByConnection;
+
+    HashMap<WebCore::SecurityOriginData, Ref<WebCore::StorageMap>> m_ephemeralStorage;
+    bool m_isEphemeral { false };
 };
 
 } // namespace WebKit

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.messages.in (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.messages.in	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebStorage/StorageManager.messages.in	2019-02-27 20:11:23 UTC (rev 242143)
@@ -26,9 +26,9 @@
     CreateSessionStorageMap(uint64_t storageMapID, uint64_t storageNamespaceID, struct WebCore::SecurityOriginData securityOriginData) WantsConnection
     DestroyStorageMap(uint64_t storageMapID) WantsConnection
 
-    GetValues(uint64_t storageMapID, uint64_t storageMapSeed) -> (HashMap<String, String> values) LegacySync WantsConnection
+    GetValues(struct WebCore::SecurityOriginData securityOriginData, uint64_t storageMapID, uint64_t storageMapSeed) -> (HashMap<String, String> values) LegacySync WantsConnection
 
-    SetItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String key, String value, String urlString) WantsConnection
-    RemoveItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String key, String urlString) WantsConnection
-    Clear(uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String urlString) WantsConnection
+    SetItem(struct WebCore::SecurityOriginData securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String key, String value, String urlString) WantsConnection
+    RemoveItem(struct WebCore::SecurityOriginData securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String key, String urlString) WantsConnection
+    Clear(struct WebCore::SecurityOriginData securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, String urlString) WantsConnection
 }

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2019-02-27 20:11:23 UTC (rev 242143)
@@ -110,6 +110,7 @@
     : m_sessionID(sessionID)
     , m_resolvedConfiguration(WebsiteDataStoreConfiguration::create())
     , m_configuration(m_resolvedConfiguration->copy())
+    , m_storageManager(StorageManager::create({ }))
     , m_deviceIdHashSaltStorage(DeviceIdHashSaltStorage::create(isPersistent() ? m_configuration->deviceIdHashSaltsStorageDirectory() : String()))
     , m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore"))
 #if ENABLE(WEB_AUTHN)

Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp	2019-02-27 20:11:23 UTC (rev 242143)
@@ -84,7 +84,7 @@
         break;
 
     case StorageType::EphemeralLocal:
-        // The UI process is not involved for EphemeralLocal storages.
+        ASSERT_NOT_REACHED();
         return;
     }
 
@@ -139,7 +139,7 @@
 
     m_pendingValueChanges.add(key);
 
-    WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::SetItem(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, value, sourceFrame->document()->url()), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::SetItem(m_securityOrigin->data(), m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, value, sourceFrame->document()->url()), 0);
 }
 
 void StorageAreaMap::removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key)
@@ -155,7 +155,7 @@
 
     m_pendingValueChanges.add(key);
 
-    WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::RemoveItem(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, sourceFrame->document()->url()), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::RemoveItem(m_securityOrigin->data(), m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, key, sourceFrame->document()->url()), 0);
 }
 
 void StorageAreaMap::clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea)
@@ -164,7 +164,7 @@
 
     m_hasPendingClear = true;
     m_storageMap = StorageMap::create(m_quotaInBytes);
-    WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, sourceFrame->document()->url()), 0);
+    WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::Clear(m_securityOrigin->data(), m_storageMapID, sourceArea->storageAreaID(), m_currentSeed, sourceFrame->document()->url()), 0);
 }
 
 bool StorageAreaMap::contains(const String& key)
@@ -193,7 +193,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().parentProcessConnection()->sendSync(Messages::StorageManager::GetValues(m_storageMapID, m_currentSeed), Messages::StorageManager::GetValues::Reply(values), 0);
+    WebProcess::singleton().parentProcessConnection()->sendSync(Messages::StorageManager::GetValues(m_securityOrigin->data(), m_storageMapID, m_currentSeed), Messages::StorageManager::GetValues::Reply(values), 0);
 
     m_storageMap = StorageMap::create(m_quotaInBytes);
     m_storageMap->importItems(values);

Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp	2019-02-27 20:11:23 UTC (rev 242143)
@@ -47,7 +47,7 @@
 
 Ref<StorageNamespaceImpl> StorageNamespaceImpl::createEphemeralLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes)
 {
-    return adoptRef(*new StorageNamespaceImpl(StorageType::EphemeralLocal, identifier, nullptr, quotaInBytes));
+    return createSessionStorageNamespace(identifier, quotaInBytes);
 }
 
 Ref<StorageNamespaceImpl> StorageNamespaceImpl::createLocalStorageNamespace(uint64_t identifier, unsigned quotaInBytes)
@@ -79,9 +79,6 @@
 
 Ref<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOriginData& securityOrigin)
 {
-    if (m_storageType == StorageType::EphemeralLocal)
-        return ephemeralLocalStorageArea(securityOrigin);
-
     RefPtr<StorageAreaMap> map;
 
     auto& slot = m_storageAreaMaps.add(securityOrigin, nullptr).iterator->value;
@@ -94,106 +91,6 @@
     return StorageAreaImpl::create(map.releaseNonNull());
 }
 
-class StorageNamespaceImpl::EphemeralStorageArea final : public StorageArea {
-public:
-    static Ref<EphemeralStorageArea> create(const SecurityOriginData& origin, unsigned quotaInBytes)
-    {
-        return adoptRef(*new EphemeralStorageArea(origin, quotaInBytes));
-    }
-
-    Ref<EphemeralStorageArea> copy()
-    {
-        return adoptRef(*new EphemeralStorageArea(*this));
-    }
-
-private:
-    EphemeralStorageArea(const SecurityOriginData& origin, unsigned quotaInBytes)
-        : m_securityOriginData(origin)
-        , m_storageMap(StorageMap::create(quotaInBytes))
-    {
-    }
-
-    EphemeralStorageArea(EphemeralStorageArea& other)
-        : m_securityOriginData(other.m_securityOriginData)
-        , m_storageMap(other.m_storageMap)
-    {
-    }
-
-    // WebCore::StorageArea.
-    unsigned length()
-    {
-        return m_storageMap->length();
-    }
-
-    String key(unsigned index)
-    {
-        return m_storageMap->key(index);
-    }
-
-    String item(const String& key)
-    {
-        return m_storageMap->getItem(key);
-    }
-
-    void setItem(Frame*, const String& key, const String& value, bool& quotaException)
-    {
-        String oldValue;
-        if (auto newMap = m_storageMap->setItem(key, value, oldValue, quotaException))
-            m_storageMap = WTFMove(newMap);
-    }
-
-    void removeItem(Frame*, const String& key)
-    {
-        String oldValue;
-        if (auto newMap = m_storageMap->removeItem(key, oldValue))
-            m_storageMap = WTFMove(newMap);
-    }
-
-    void clear(Frame*)
-    {
-        if (!m_storageMap->length())
-            return;
-
-        m_storageMap = StorageMap::create(m_storageMap->quota());
-    }
-
-    bool contains(const String& key)
-    {
-        return m_storageMap->contains(key);
-    }
-
-    StorageType storageType() const
-    {
-        return StorageType::EphemeralLocal;
-    }
-
-    size_t memoryBytesUsedByCache()
-    {
-        return 0;
-    }
-
-    void incrementAccessCount() { }
-    void decrementAccessCount() { }
-    void closeDatabaseIfIdle() { }
-
-    const SecurityOriginData& securityOrigin() const
-    {
-        return m_securityOriginData;
-    }
-
-    SecurityOriginData m_securityOriginData;
-    RefPtr<StorageMap> m_storageMap;
-};
-
-Ref<StorageArea> StorageNamespaceImpl::ephemeralLocalStorageArea(const SecurityOriginData& securityOrigin)
-{
-    auto& slot = m_ephemeralLocalStorageAreas.add(securityOrigin, nullptr).iterator->value;
-    if (!slot)
-        slot = StorageNamespaceImpl::EphemeralStorageArea::create(securityOrigin, m_quotaInBytes);
-    ASSERT(slot);
-    return *slot;
-}
-
 Ref<StorageNamespace> StorageNamespaceImpl::copy(Page* newPage)
 {
     ASSERT(m_storageNamespaceID);
@@ -204,9 +101,6 @@
     ASSERT(m_storageType == StorageType::EphemeralLocal);
     auto newNamespace = adoptRef(*new StorageNamespaceImpl(m_storageType, m_storageNamespaceID, m_topLevelOrigin.get(), m_quotaInBytes));
 
-    for (auto& iter : m_ephemeralLocalStorageAreas)
-        newNamespace->m_ephemeralLocalStorageAreas.set(iter.key, iter.value->copy());
-
     return WTFMove(newNamespace);
 }
 

Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h (242142 => 242143)


--- branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h	2019-02-27 20:11:23 UTC (rev 242143)
@@ -59,8 +59,6 @@
     Ref<WebCore::StorageArea> storageArea(const WebCore::SecurityOriginData&) override;
     Ref<WebCore::StorageNamespace> copy(WebCore::Page*) override;
 
-    Ref<WebCore::StorageArea> ephemeralLocalStorageArea(const WebCore::SecurityOriginData&);
-
     const WebCore::StorageType m_storageType;
     const uint64_t m_storageNamespaceID;
 
@@ -70,9 +68,6 @@
     const unsigned m_quotaInBytes;
 
     HashMap<WebCore::SecurityOriginData, StorageAreaMap*> m_storageAreaMaps;
-
-    class EphemeralStorageArea;
-    HashMap<WebCore::SecurityOriginData, RefPtr<EphemeralStorageArea>> m_ephemeralLocalStorageAreas;
 };
 
 } // namespace WebKit

Modified: branches/safari-607-branch/Tools/ChangeLog (242142 => 242143)


--- branches/safari-607-branch/Tools/ChangeLog	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Tools/ChangeLog	2019-02-27 20:11:23 UTC (rev 242143)
@@ -1,5 +1,19 @@
 2019-02-27  Babak Shafiei  <bshaf...@apple.com>
 
+        Apply patch. rdar://problem/48429676
+
+    2019-02-27  Alex Christensen  <achristen...@webkit.org>
+
+            Move ephemeral local storage from WebProcess to UIProcess
+            https://bugs.webkit.org/show_bug.cgi?id=195074
+            <rdar://problem/47937975>
+
+            Reviewed by Geoff Garen.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
+2019-02-27  Babak Shafiei  <bshaf...@apple.com>
+
         Cherry-pick r242089. rdar://problem/48429668
 
     WebPageProxy should nullify m_userMediaPermissionRequestManager after resetting the media state

Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (242142 => 242143)


--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-02-27 19:53:42 UTC (rev 242142)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-02-27 20:11:23 UTC (rev 242143)
@@ -4390,6 +4390,58 @@
     done = false;
 }
 
+TEST(ProcessSwap, EphemeralLocalStorage)
+{
+    auto processPoolConfiguration = psonProcessPoolConfiguration();
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [webViewConfiguration setProcessPool:processPool.get()];
+    [webViewConfiguration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
+    auto handler = adoptNS([[PSONScheme alloc] init]);
+    [handler addMappingFromURLString:@"pson://www.webkit.org/iframe.html" toData:"<script>window.localStorage.setItem('c','d')</script>"];
+    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"pson"];
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://webkit.org/"]]];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView evaluateJavaScript:@"window.localStorage.setItem('a','b')" completionHandler:^(id, NSError *) {
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://example.com/"]]];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://webkit.org/"]]];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView evaluateJavaScript:@"window.localStorage.getItem('a')" completionHandler:^(id result, NSError *) {
+        EXPECT_TRUE([@"b" isEqualToString:result]);
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView loadHTMLString:@"<html><iframe src=''></iframe></html>" baseURL:[NSURL URLWithString:@"http://www.example.com/"]];
+    TestWebKitAPI::Util::run(&done);
+
+    done = false;
+    [webView evaluateJavaScript:@"window.localStorage.getItem('a')" completionHandler:^(id result, NSError *) {
+        EXPECT_FALSE([@"b" isEqualToString:result]);
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+}
+
 TEST(ProcessSwap, UsePrewarmedProcessAfterTerminatingNetworkProcess)
 {
     auto processPoolConfiguration = psonProcessPoolConfiguration();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to