Changeset 290223 in webkit
- Timestamp:
- Feb 19, 2022 11:12:29 PM (5 months ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/inspector/InspectorInstrumentation.cpp (modified) (1 diff)
-
WebCore/inspector/InspectorInstrumentation.h (modified) (3 diffs)
-
WebCore/inspector/agents/InspectorDOMStorageAgent.cpp (modified) (2 diffs)
-
WebCore/inspector/agents/InspectorDOMStorageAgent.h (modified) (1 diff)
-
WebCore/loader/EmptyClients.cpp (modified) (1 diff)
-
WebCore/page/DOMWindow.cpp (modified) (1 diff)
-
WebCore/storage/StorageEventDispatcher.cpp (modified) (6 diffs)
-
WebCore/storage/StorageEventDispatcher.h (modified) (1 diff)
-
WebCore/storage/StorageNamespace.h (modified) (1 diff)
-
WebCore/storage/StorageNamespaceProvider.cpp (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebStorage/StorageAreaMap.cpp (modified) (8 diffs)
-
WebKit/WebProcess/WebStorage/StorageAreaMap.h (modified) (2 diffs)
-
WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp (modified) (1 diff)
-
WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h (modified) (1 diff)
-
WebKitLegacy/ChangeLog (modified) (1 diff)
-
WebKitLegacy/Storage/StorageAreaImpl.cpp (modified) (6 diffs)
-
WebKitLegacy/Storage/StorageAreaImpl.h (modified) (3 diffs)
-
WebKitLegacy/Storage/StorageNamespaceImpl.cpp (modified) (2 diffs)
-
WebKitLegacy/Storage/StorageNamespaceImpl.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r290217 r290223 1 2022-02-19 Chris Dumez <cdumez@apple.com> 2 3 Optimize DOM storage event dispatch 4 https://bugs.webkit.org/show_bug.cgi?id=236871 5 6 Reviewed by Sihui Liu. 7 8 Made the following optimization to DOM storage event dispatch: 9 1. Pass a SecurityOrigin around instead of a SecurityOriginData. Otherwise, 10 dispatchLocalStorageEvents() / dispatchSessionStorageEvents() just keep 11 reconstructing the SecurityOrigin from the SecurityOriginData for every 12 frame. 13 2. When gathering the list of frames where we need to dispatch the storage 14 event, discard the ones that do not have a "storage" event listener. 15 16 * inspector/InspectorInstrumentation.cpp: 17 (WebCore::InspectorInstrumentation::didDispatchDOMStorageEventImpl): 18 * inspector/InspectorInstrumentation.h: 19 (WebCore::InspectorInstrumentation::didDispatchDOMStorageEvent): 20 * inspector/agents/InspectorDOMStorageAgent.cpp: 21 (WebCore::InspectorDOMStorageAgent::storageId): 22 (WebCore::InspectorDOMStorageAgent::didDispatchDOMStorageEvent): 23 (WebCore::InspectorDOMStorageAgent::findStorageArea): 24 * inspector/agents/InspectorDOMStorageAgent.h: 25 * loader/EmptyClients.cpp: 26 * page/DOMWindow.cpp: 27 * storage/StorageEventDispatcher.cpp: 28 (WebCore::StorageEventDispatcher::dispatchSessionStorageEvents): 29 (WebCore::StorageEventDispatcher::dispatchLocalStorageEvents): 30 (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames): 31 (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames): 32 * storage/StorageEventDispatcher.h: 33 * storage/StorageNamespace.h: 34 * storage/StorageNamespaceProvider.cpp: 35 (WebCore::StorageNamespaceProvider::localStorageArea): 36 1 37 2022-02-19 Mark Lam <mark.lam@apple.com> 2 38 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r289698 r290223 1008 1008 } 1009 1009 1010 void InspectorInstrumentation::didDispatchDOMStorageEventImpl(InstrumentingAgents& instrumentingAgents, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin*securityOrigin)1010 void InspectorInstrumentation::didDispatchDOMStorageEventImpl(InstrumentingAgents& instrumentingAgents, const String& key, const String& oldValue, const String& newValue, StorageType storageType, const SecurityOrigin& securityOrigin) 1011 1011 { 1012 1012 if (auto* domStorageAgent = instrumentingAgents.enabledDOMStorageAgent()) -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r289698 r290223 275 275 static void didOpenDatabase(Database&); 276 276 277 static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);277 static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, const SecurityOrigin&); 278 278 279 279 static bool shouldWaitForDebuggerOnStart(ScriptExecutionContext&); … … 478 478 static void didOpenDatabaseImpl(InstrumentingAgents&, Database&); 479 479 480 static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);480 static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, const SecurityOrigin&); 481 481 482 482 static bool shouldWaitForDebuggerOnStartImpl(InstrumentingAgents&); … … 1326 1326 } 1327 1327 1328 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin*securityOrigin)1328 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, const SecurityOrigin& securityOrigin) 1329 1329 { 1330 1330 FAST_RETURN_IF_NO_FRONTENDS(void()); -
trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp
r266902 r290223 169 169 Ref<SecurityOrigin> securityOrigin = document->securityOrigin(); 170 170 bool isLocalStorage = window->optionalLocalStorage() == &storage; 171 return InspectorDOMStorageAgent::storageId(securityOrigin .ptr(), isLocalStorage)->toJSONString();172 } 173 174 Ref<Protocol::DOMStorage::StorageId> InspectorDOMStorageAgent::storageId( SecurityOrigin*securityOrigin, bool isLocalStorage)171 return InspectorDOMStorageAgent::storageId(securityOrigin, isLocalStorage)->toJSONString(); 172 } 173 174 Ref<Protocol::DOMStorage::StorageId> InspectorDOMStorageAgent::storageId(const SecurityOrigin& securityOrigin, bool isLocalStorage) 175 175 { 176 176 return Protocol::DOMStorage::StorageId::create() 177 .setSecurityOrigin(securityOrigin ->toRawString())177 .setSecurityOrigin(securityOrigin.toRawString()) 178 178 .setIsLocalStorage(isLocalStorage) 179 179 .release(); 180 180 } 181 181 182 void InspectorDOMStorageAgent::didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin*securityOrigin)182 void InspectorDOMStorageAgent::didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, const SecurityOrigin& securityOrigin) 183 183 { 184 184 auto id = InspectorDOMStorageAgent::storageId(securityOrigin, storageType == StorageType::Local); … … 215 215 216 216 if (!*isLocalStorage) 217 return m_inspectedPage.sessionStorage()->storageArea(targetFrame->document()->securityOrigin() .data());217 return m_inspectedPage.sessionStorage()->storageArea(targetFrame->document()->securityOrigin()); 218 218 return m_inspectedPage.storageNamespaceProvider().localStorageArea(*targetFrame->document()); 219 219 } -
trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h
r266885 r290223 66 66 67 67 // InspectorInstrumentation 68 void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);68 void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, const SecurityOrigin&); 69 69 70 70 // CommandLineAPI 71 71 static String storageId(Storage&); 72 static Ref<Inspector::Protocol::DOMStorage::StorageId> storageId( SecurityOrigin*, bool isLocalStorage);72 static Ref<Inspector::Protocol::DOMStorage::StorageId> storageId(const SecurityOrigin&, bool isLocalStorage); 73 73 74 74 private: -
trunk/Source/WebCore/loader/EmptyClients.cpp
r289994 r290223 499 499 } 500 500 private: 501 Ref<StorageArea> storageArea(const SecurityOrigin Data&) final { return adoptRef(*new EmptyStorageArea); }501 Ref<StorageArea> storageArea(const SecurityOrigin&) final { return adoptRef(*new EmptyStorageArea); } 502 502 Ref<StorageNamespace> copy(Page&) final { return adoptRef(*new EmptyStorageNamespace { m_sessionID }); } 503 503 PAL::SessionID sessionID() const final { return m_sessionID; } -
trunk/Source/WebCore/page/DOMWindow.cpp
r290026 r290223 831 831 return nullptr; 832 832 833 auto storageArea = page->sessionStorage()->storageArea(document->securityOrigin() .data());833 auto storageArea = page->sessionStorage()->storageArea(document->securityOrigin()); 834 834 m_sessionStorage = Storage::create(*this, WTFMove(storageArea)); 835 835 return m_sessionStorage.get(); -
trunk/Source/WebCore/storage/StorageEventDispatcher.cpp
r282799 r290223 41 41 namespace WebCore { 42 42 43 void StorageEventDispatcher::dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin Data& securityOrigin, Frame* sourceFrame)43 void StorageEventDispatcher::dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin& securityOrigin, Frame* sourceFrame) 44 44 { 45 45 Page* page = sourceFrame->page(); … … 47 47 return; 48 48 49 Vector<Ref Ptr<Frame>> frames;49 Vector<Ref<Frame>> frames; 50 50 51 51 // Send events only to our page. 52 52 for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext()) { 53 if ( !frame->document())53 if (auto* window = frame->window(); !window || !window->hasEventListeners(eventNames().storageEvent)) 54 54 continue; 55 if (sourceFrame != frame && frame->document()->securityOrigin().equal( securityOrigin.securityOrigin().ptr()))56 frames.append( frame);55 if (sourceFrame != frame && frame->document()->securityOrigin().equal(&securityOrigin)) 56 frames.append(*frame); 57 57 } 58 58 … … 60 60 } 61 61 62 void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin Data& securityOrigin, Frame* sourceFrame)62 void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin& securityOrigin, Frame* sourceFrame) 63 63 { 64 64 Page* page = sourceFrame->page(); … … 66 66 return; 67 67 68 Vector<Ref Ptr<Frame>> frames;68 Vector<Ref<Frame>> frames; 69 69 70 70 // Send events to every page. 71 71 for (auto& pageInGroup : page->group().pages()) { 72 72 for (auto* frame = &pageInGroup.mainFrame(); frame; frame = frame->tree().traverseNext()) { 73 if ( !frame->document())73 if (auto* window = frame->window(); !window || !window->hasEventListeners(eventNames().storageEvent)) 74 74 continue; 75 if (sourceFrame != frame && frame->document()->securityOrigin().equal( securityOrigin.securityOrigin().ptr()))76 frames.append( frame);75 if (sourceFrame != frame && frame->document()->securityOrigin().equal(&securityOrigin)) 76 frames.append(*frame); 77 77 } 78 78 } … … 81 81 } 82 82 83 void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, const Vector<Ref Ptr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData& securityOrigin)83 void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, const Vector<Ref<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOrigin& securityOrigin) 84 84 { 85 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Session, securityOrigin .securityOrigin().ptr());85 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Session, securityOrigin); 86 86 87 87 for (auto& frame : frames) { … … 93 93 } 94 94 95 void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector<Ref Ptr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData& securityOrigin)95 void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector<Ref<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOrigin& securityOrigin) 96 96 { 97 97 for (auto& page : pageGroup.pages()) 98 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Local, securityOrigin .securityOrigin().ptr());98 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, newValue, StorageType::Local, securityOrigin); 99 99 100 100 for (auto& frame : frames) { -
trunk/Source/WebCore/storage/StorageEventDispatcher.h
r222113 r290223 37 37 class Page; 38 38 class PageGroup; 39 struct SecurityOriginData;39 class SecurityOrigin; 40 40 41 41 class StorageEventDispatcher { 42 42 public: 43 WEBCORE_EXPORT static void dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin Data&, Frame* sourceFrame);44 WEBCORE_EXPORT static void dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin Data&, Frame* sourceFrame);43 WEBCORE_EXPORT static void dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin&, Frame* sourceFrame); 44 WEBCORE_EXPORT static void dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, const SecurityOrigin&, Frame* sourceFrame); 45 45 46 WEBCORE_EXPORT static void dispatchSessionStorageEventsToFrames(Page&, const Vector<Ref Ptr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData&);47 WEBCORE_EXPORT static void dispatchLocalStorageEventsToFrames(PageGroup&, const Vector<Ref Ptr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOriginData&);46 WEBCORE_EXPORT static void dispatchSessionStorageEventsToFrames(Page&, const Vector<Ref<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOrigin&); 47 WEBCORE_EXPORT static void dispatchLocalStorageEventsToFrames(PageGroup&, const Vector<Ref<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, const SecurityOrigin&); 48 48 private: 49 49 // Do not instantiate. -
trunk/Source/WebCore/storage/StorageNamespace.h
r255875 r290223 36 36 37 37 class Page; 38 class SecurityOrigin; 38 39 class StorageArea; 39 struct SecurityOriginData;40 40 41 41 class StorageNamespace : public RefCounted<StorageNamespace> { 42 42 public: 43 43 virtual ~StorageNamespace() = default; 44 virtual Ref<StorageArea> storageArea(const SecurityOrigin Data&) = 0;44 virtual Ref<StorageArea> storageArea(const SecurityOrigin&) = 0; 45 45 46 46 // FIXME: This is only valid for session storage and should probably be moved to a subclass. -
trunk/Source/WebCore/storage/StorageNamespaceProvider.cpp
r278849 r290223 61 61 storageNamespace = &localStorageNamespace(document.page()->sessionID()); 62 62 63 return storageNamespace->storageArea(document.securityOrigin() .data());63 return storageNamespace->storageArea(document.securityOrigin()); 64 64 } 65 65 -
trunk/Source/WebKit/ChangeLog
r290219 r290223 1 2022-02-19 Chris Dumez <cdumez@apple.com> 2 3 Optimize DOM storage event dispatch 4 https://bugs.webkit.org/show_bug.cgi?id=236871 5 6 Reviewed by Sihui Liu. 7 8 Made the following optimization to DOM storage event dispatch: 9 1. Pass a SecurityOrigin around instead of a SecurityOriginData. Otherwise, 10 dispatchLocalStorageEvents() / dispatchSessionStorageEvents() just keep 11 reconstructing the SecurityOrigin from the SecurityOriginData for every 12 frame. 13 2. When gathering the list of frames where we need to dispatch the storage 14 event, discard the ones that do not have a "storage" event listener. 15 16 * WebProcess/WebStorage/StorageAreaMap.cpp: 17 (WebKit::StorageAreaMap::StorageAreaMap): 18 (WebKit::framesForEventDispatching): 19 (WebKit::StorageAreaMap::dispatchSessionStorageEvent): 20 (WebKit::StorageAreaMap::dispatchLocalStorageEvent): 21 * WebProcess/WebStorage/StorageAreaMap.h: 22 * WebProcess/WebStorage/StorageNamespaceImpl.cpp: 23 (WebKit::StorageNamespaceImpl::storageArea): 24 * WebProcess/WebStorage/StorageNamespaceImpl.h: 25 1 26 2022-02-19 Tim Horton <timothy_horton@apple.com> 2 27 -
trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp
r288551 r290223 39 39 #include <WebCore/DOMWindow.h> 40 40 #include <WebCore/Document.h> 41 #include <WebCore/EventNames.h> 41 42 #include <WebCore/Frame.h> 42 43 #include <WebCore/Page.h> … … 51 52 using namespace WebCore; 52 53 53 StorageAreaMap::StorageAreaMap(StorageNamespaceImpl& storageNamespace, Ref< WebCore::SecurityOrigin>&& securityOrigin)54 StorageAreaMap::StorageAreaMap(StorageNamespaceImpl& storageNamespace, Ref<const WebCore::SecurityOrigin>&& securityOrigin) 54 55 : m_identifier(StorageAreaMapIdentifier::generate()) 55 56 , m_namespace(storageNamespace) … … 296 297 } 297 298 298 static Vector<Ref Ptr<Frame>> framesForEventDispatching(Page& page,SecurityOrigin& origin, StorageType storageType, const std::optional<StorageAreaImplIdentifier>& storageAreaImplID)299 { 300 Vector<Ref Ptr<Frame>> frames;299 static Vector<Ref<Frame>> framesForEventDispatching(Page& page, const SecurityOrigin& origin, StorageType storageType, const std::optional<StorageAreaImplIdentifier>& storageAreaImplID) 300 { 301 Vector<Ref<Frame>> frames; 301 302 page.forEachDocument([&](auto& document) { 302 303 if (!document.securityOrigin().equal(&origin)) … … 304 305 305 306 auto* window = document.domWindow(); 306 if (!window )307 if (!window || !window->hasEventListeners(eventNames().storageEvent)) 307 308 return; 308 309 … … 328 329 329 330 if (auto* frame = document.frame()) 330 frames.append( frame);331 frames.append(*frame); 331 332 }); 332 333 return frames; … … 346 347 347 348 auto frames = framesForEventDispatching(*page, m_securityOrigin, StorageType::Session, storageAreaImplID); 348 StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, m_securityOrigin ->data());349 StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, m_securityOrigin); 349 350 } 350 351 … … 353 354 ASSERT(isLocalStorage(type())); 354 355 355 Vector<Ref Ptr<Frame>> frames;356 Vector<Ref<Frame>> frames; 356 357 357 358 // Namespace IDs for local storage namespaces are currently equivalent to web page group IDs. … … 360 361 frames.appendVector(framesForEventDispatching(page, m_securityOrigin, StorageType::Local, storageAreaImplID)); 361 362 362 StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin ->data());363 StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin); 363 364 } 364 365 -
trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.h
r288551 r290223 51 51 WTF_MAKE_FAST_ALLOCATED; 52 52 public: 53 StorageAreaMap(StorageNamespaceImpl&, Ref< WebCore::SecurityOrigin>&&);53 StorageAreaMap(StorageNamespaceImpl&, Ref<const WebCore::SecurityOrigin>&&); 54 54 ~StorageAreaMap(); 55 55 … … 101 101 uint64_t m_lastHandledMessageIdentifier { 0 }; 102 102 StorageNamespaceImpl& m_namespace; 103 Ref< WebCore::SecurityOrigin> m_securityOrigin;103 Ref<const WebCore::SecurityOrigin> m_securityOrigin; 104 104 std::unique_ptr<WebCore::StorageMap> m_map; 105 105 std::optional<StorageAreaIdentifier> m_remoteAreaIdentifier; -
trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp
r286936 r290223 101 101 } 102 102 103 Ref<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOrigin Data& securityOriginData)103 Ref<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOrigin& securityOrigin) 104 104 { 105 auto& map = m_storageAreaMaps.ensure(securityOrigin Data, [&] {106 return makeUnique<StorageAreaMap>(*this, securityOrigin Data.securityOrigin());105 auto& map = m_storageAreaMaps.ensure(securityOrigin.data(), [&] { 106 return makeUnique<StorageAreaMap>(*this, securityOrigin); 107 107 }).iterator->value; 108 108 return StorageAreaImpl::create(*map); -
trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.h
r281398 r290223 68 68 StorageNamespaceImpl(WebCore::StorageType, Identifier, const std::optional<WebCore::PageIdentifier>&, WebCore::SecurityOrigin* topLevelOrigin, unsigned quotaInBytes); 69 69 70 Ref<WebCore::StorageArea> storageArea(const WebCore::SecurityOrigin Data&) override;70 Ref<WebCore::StorageArea> storageArea(const WebCore::SecurityOrigin&) final; 71 71 uint64_t storageAreaMapCountForTesting() const final { return m_storageAreaMaps.size(); } 72 72 -
trunk/Source/WebKitLegacy/ChangeLog
r289474 r290223 1 2022-02-19 Chris Dumez <cdumez@apple.com> 2 3 Optimize DOM storage event dispatch 4 https://bugs.webkit.org/show_bug.cgi?id=236871 5 6 Reviewed by Sihui Liu. 7 8 Made the following optimization to DOM storage event dispatch: 9 1. Pass a SecurityOrigin around instead of a SecurityOriginData. Otherwise, 10 dispatchLocalStorageEvents() / dispatchSessionStorageEvents() just keep 11 reconstructing the SecurityOrigin from the SecurityOriginData for every 12 frame. 13 2. When gathering the list of frames where we need to dispatch the storage 14 event, discard the ones that do not have a "storage" event listener. 15 16 * Storage/StorageAreaImpl.cpp: 17 (WebKit::StorageAreaImpl::StorageAreaImpl): 18 (WebKit::StorageAreaImpl::create): 19 (WebKit::StorageAreaImpl::clearForOriginDeletion): 20 (WebKit::StorageAreaImpl::sync): 21 (WebKit::StorageAreaImpl::sessionChanged): 22 * Storage/StorageAreaImpl.h: 23 * Storage/StorageNamespaceImpl.cpp: 24 (WebKit::StorageNamespaceImpl::storageArea): 25 * Storage/StorageNamespaceImpl.h: 26 1 27 2022-02-09 Sihui Liu <sihui_liu@apple.com> 2 28 -
trunk/Source/WebKitLegacy/Storage/StorageAreaImpl.cpp
r276659 r290223 45 45 } 46 46 47 inline StorageAreaImpl::StorageAreaImpl(StorageType storageType, const SecurityOrigin Data& origin, RefPtr<StorageSyncManager>&& syncManager, unsigned quota)47 inline StorageAreaImpl::StorageAreaImpl(StorageType storageType, const SecurityOrigin& origin, RefPtr<StorageSyncManager>&& syncManager, unsigned quota) 48 48 : m_storageType(storageType) 49 49 , m_securityOrigin(origin) … … 54 54 { 55 55 ASSERT(isMainThread()); 56 57 // Accessing the shared global StorageTracker when a StorageArea is created 56 57 // Accessing the shared global StorageTracker when a StorageArea is created 58 58 // ensures that the tracker is properly initialized before anyone actually needs to use it. 59 59 StorageTracker::tracker(); 60 60 } 61 61 62 Ref<StorageAreaImpl> StorageAreaImpl::create(StorageType storageType, const SecurityOrigin Data& origin, RefPtr<StorageSyncManager>&& syncManager, unsigned quota)62 Ref<StorageAreaImpl> StorageAreaImpl::create(StorageType storageType, const SecurityOrigin& origin, RefPtr<StorageSyncManager>&& syncManager, unsigned quota) 63 63 { 64 64 Ref<StorageAreaImpl> area = adoptRef(*new StorageAreaImpl(storageType, origin, WTFMove(syncManager), quota)); … … 66 66 // not silently ignoring it. https://bugs.webkit.org/show_bug.cgi?id=25894 67 67 if (area->m_storageSyncManager) { 68 area->m_storageAreaSync = StorageAreaSync::create(area->m_storageSyncManager.get(), area.copyRef(), area->m_securityOrigin .databaseIdentifier());68 area->m_storageAreaSync = StorageAreaSync::create(area->m_storageSyncManager.get(), area.copyRef(), area->m_securityOrigin->data().databaseIdentifier()); 69 69 ASSERT(area->m_storageAreaSync); 70 70 } … … 204 204 ASSERT(!m_isShutdown); 205 205 blockUntilImportComplete(); 206 206 207 207 m_storageMap.clear(); 208 208 … … 212 212 } 213 213 } 214 214 215 215 void StorageAreaImpl::sync() 216 216 { 217 217 ASSERT(!m_isShutdown); 218 218 blockUntilImportComplete(); 219 219 220 220 if (m_storageAreaSync) 221 221 m_storageAreaSync->scheduleSync(); … … 288 288 289 289 if (isNewSessionPersistent && !m_storageAreaSync && m_storageSyncManager) { 290 m_storageAreaSync = StorageAreaSync::create(m_storageSyncManager.get(), *this, m_securityOrigin .databaseIdentifier());290 m_storageAreaSync = StorageAreaSync::create(m_storageSyncManager.get(), *this, m_securityOrigin->data().databaseIdentifier()); 291 291 return; 292 292 } -
trunk/Source/WebKitLegacy/Storage/StorageAreaImpl.h
r276659 r290223 44 44 class StorageAreaImpl : public WebCore::StorageArea { 45 45 public: 46 static Ref<StorageAreaImpl> create(WebCore::StorageType, const WebCore::SecurityOrigin Data&, RefPtr<WebCore::StorageSyncManager>&&, unsigned quota);46 static Ref<StorageAreaImpl> create(WebCore::StorageType, const WebCore::SecurityOrigin&, RefPtr<WebCore::StorageSyncManager>&&, unsigned quota); 47 47 virtual ~StorageAreaImpl(); 48 48 … … 77 77 78 78 private: 79 StorageAreaImpl(WebCore::StorageType, const WebCore::SecurityOrigin Data&, RefPtr<WebCore::StorageSyncManager>&&, unsigned quota);79 StorageAreaImpl(WebCore::StorageType, const WebCore::SecurityOrigin&, RefPtr<WebCore::StorageSyncManager>&&, unsigned quota); 80 80 explicit StorageAreaImpl(const StorageAreaImpl&); 81 81 … … 86 86 87 87 WebCore::StorageType m_storageType; 88 WebCore::SecurityOriginDatam_securityOrigin;88 Ref<const WebCore::SecurityOrigin> m_securityOrigin; 89 89 WebCore::StorageMap m_storageMap; 90 90 -
trunk/Source/WebKitLegacy/Storage/StorageNamespaceImpl.cpp
r283237 r290223 29 29 #include "StorageSyncManager.h" 30 30 #include "StorageTracker.h" 31 #include <WebCore/SecurityOrigin.h> 31 32 #include <WebCore/StorageMap.h> 32 33 #include <WebCore/StorageType.h> … … 103 104 } 104 105 105 Ref<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOrigin Data& origin)106 Ref<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOrigin& origin) 106 107 { 107 108 ASSERT(isMainThread()); 108 109 ASSERT(!m_isShutdown); 109 110 110 if (RefPtr<StorageAreaImpl> storageArea = m_storageAreaMap.get(origin)) 111 return storageArea.releaseNonNull(); 112 113 auto storageArea = StorageAreaImpl::create(m_storageType, origin, m_syncManager.get(), m_quota); 114 m_storageAreaMap.set(origin, storageArea.ptr()); 115 return WTFMove(storageArea); 111 return *m_storageAreaMap.ensure(origin.data(), [&] { 112 return StorageAreaImpl::create(m_storageType, origin, m_syncManager.get(), m_quota); 113 }).iterator->value; 116 114 } 117 115 -
trunk/Source/WebKitLegacy/Storage/StorageNamespaceImpl.h
r249354 r290223 38 38 class StorageAreaImpl; 39 39 40 class StorageNamespaceImpl : public WebCore::StorageNamespace {40 class StorageNamespaceImpl final : public WebCore::StorageNamespace { 41 41 public: 42 42 static Ref<StorageNamespaceImpl> createSessionStorageNamespace(unsigned quota, PAL::SessionID); … … 55 55 void closeIdleLocalStorageDatabases(); 56 56 57 PAL::SessionID sessionID() const override{ return m_sessionID; }58 void setSessionIDForTesting(PAL::SessionID) override;57 PAL::SessionID sessionID() const final { return m_sessionID; } 58 void setSessionIDForTesting(PAL::SessionID) final; 59 59 60 60 private: 61 61 StorageNamespaceImpl(WebCore::StorageType, const String& path, unsigned quota, PAL::SessionID); 62 62 63 Ref<WebCore::StorageArea> storageArea(const WebCore::SecurityOrigin Data&) override;64 Ref<StorageNamespace> copy(WebCore::Page& newPage) override;63 Ref<WebCore::StorageArea> storageArea(const WebCore::SecurityOrigin&) final; 64 Ref<StorageNamespace> copy(WebCore::Page& newPage) final; 65 65 66 66 typedef HashMap<WebCore::SecurityOriginData, RefPtr<StorageAreaImpl>> StorageAreaMap;
Note: See TracChangeset
for help on using the changeset viewer.