Changeset 248452 in webkit
- Timestamp:
- Aug 8, 2019, 5:08:07 PM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
NetworkProcess/WebStorage/LocalStorageNamespace.cpp (modified) (5 diffs)
-
NetworkProcess/WebStorage/SessionStorageNamespace.cpp (modified) (7 diffs)
-
NetworkProcess/WebStorage/StorageArea.cpp (modified) (13 diffs)
-
NetworkProcess/WebStorage/StorageManager.cpp (modified) (20 diffs)
-
NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r248447 r248452 1 2019-08-08 Chris Dumez <cdumez@apple.com> 2 3 Add threading assertions to WebStorage code 4 https://bugs.webkit.org/show_bug.cgi?id=200550 5 6 Reviewed by Geoffrey Garen. 7 8 Add threading assertions to WebStorage code for extra safety. 9 10 * NetworkProcess/WebStorage/LocalStorageNamespace.cpp: 11 (WebKit::LocalStorageNamespace::LocalStorageNamespace): 12 (WebKit::LocalStorageNamespace::~LocalStorageNamespace): 13 (WebKit::LocalStorageNamespace::getOrCreateStorageArea): 14 (WebKit::LocalStorageNamespace::clearStorageAreasMatchingOrigin): 15 (WebKit::LocalStorageNamespace::clearAllStorageAreas): 16 (WebKit::LocalStorageNamespace::ephemeralOrigins const): 17 (WebKit::LocalStorageNamespace::cloneTo): 18 * NetworkProcess/WebStorage/SessionStorageNamespace.cpp: 19 (WebKit::SessionStorageNamespace::SessionStorageNamespace): 20 (WebKit::SessionStorageNamespace::~SessionStorageNamespace): 21 (WebKit::SessionStorageNamespace::addAllowedConnection): 22 (WebKit::SessionStorageNamespace::removeAllowedConnection): 23 (WebKit::SessionStorageNamespace::getOrCreateStorageArea): 24 (WebKit::SessionStorageNamespace::cloneTo): 25 (WebKit::SessionStorageNamespace::origins const): 26 (WebKit::SessionStorageNamespace::clearStorageAreasMatchingOrigin): 27 (WebKit::SessionStorageNamespace::clearAllStorageAreas): 28 * NetworkProcess/WebStorage/StorageArea.cpp: 29 (WebKit::StorageArea::StorageArea): 30 (WebKit::StorageArea::~StorageArea): 31 (WebKit::StorageArea::addListener): 32 (WebKit::StorageArea::removeListener): 33 (WebKit::StorageArea::hasListener const): 34 (WebKit::StorageArea::clone const): 35 (WebKit::StorageArea::setItem): 36 (WebKit::StorageArea::setItems): 37 (WebKit::StorageArea::removeItem): 38 (WebKit::StorageArea::clear): 39 (WebKit::StorageArea::items const): 40 (WebKit::StorageArea::openDatabaseAndImportItemsIfNeeded const): 41 (WebKit::StorageArea::dispatchEvents const): 42 * NetworkProcess/WebStorage/StorageManager.cpp: 43 (WebKit::StorageManager::createSessionStorageNamespace): 44 (WebKit::StorageManager::destroySessionStorageNamespace): 45 (WebKit::StorageManager::addAllowedSessionStorageNamespaceConnection): 46 (WebKit::StorageManager::removeAllowedSessionStorageNamespaceConnection): 47 (WebKit::StorageManager::cloneSessionStorageNamespace): 48 (WebKit::StorageManager::processDidCloseConnection): 49 (WebKit::StorageManager::getSessionStorageOrigins): 50 (WebKit::StorageManager::deleteSessionStorageOrigins): 51 (WebKit::StorageManager::deleteSessionStorageEntriesForOrigins): 52 (WebKit::StorageManager::getLocalStorageOrigins): 53 (WebKit::StorageManager::getLocalStorageOriginDetails): 54 (WebKit::StorageManager::deleteLocalStorageEntriesForOrigin): 55 (WebKit::StorageManager::deleteLocalStorageOriginsModifiedSince): 56 (WebKit::StorageManager::deleteLocalStorageEntriesForOrigins): 57 (WebKit::StorageManager::waitUntilTasksFinished): 58 (WebKit::StorageManager::suspend): 59 (WebKit::StorageManager::resume): 60 (WebKit::StorageManager::findStorageArea const): 61 (WebKit::StorageManager::getOrCreateLocalStorageNamespace): 62 (WebKit::StorageManager::getOrCreateTransientLocalStorageNamespace): 63 * NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp: 64 (WebKit::TransientLocalStorageNamespace::TransientLocalStorageNamespace): 65 (WebKit::TransientLocalStorageNamespace::~TransientLocalStorageNamespace): 66 (WebKit::TransientLocalStorageNamespace::getOrCreateStorageArea): 67 (WebKit::TransientLocalStorageNamespace::origins const): 68 (WebKit::TransientLocalStorageNamespace::clearStorageAreasMatchingOrigin): 69 (WebKit::TransientLocalStorageNamespace::clearAllStorageAreas): 70 1 71 2019-08-08 Brent Fulgham <bfulgham@apple.com> 2 72 -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageNamespace.cpp
r248422 r248452 40 40 , m_quotaInBytes(StorageManager::localStorageDatabaseQuotaInBytes) 41 41 { 42 ASSERT(!RunLoop::isMain()); 42 43 } 43 44 44 45 LocalStorageNamespace::~LocalStorageNamespace() 45 46 { 47 ASSERT(!RunLoop::isMain()); 46 48 } 47 49 48 50 auto LocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin, IsEphemeral isEphemeral) -> Ref<StorageArea> 49 51 { 52 ASSERT(!RunLoop::isMain()); 50 53 return *m_storageAreaMap.ensure(securityOrigin, [&]() mutable { 51 54 return StorageArea::create(isEphemeral == IsEphemeral::Yes ? nullptr : this, WTFMove(securityOrigin), m_quotaInBytes); … … 55 58 void LocalStorageNamespace::clearStorageAreasMatchingOrigin(const SecurityOriginData& securityOrigin) 56 59 { 60 ASSERT(!RunLoop::isMain()); 57 61 auto originAndStorageArea = m_storageAreaMap.find(securityOrigin); 58 62 if (originAndStorageArea != m_storageAreaMap.end()) … … 62 66 void LocalStorageNamespace::clearAllStorageAreas() 63 67 { 68 ASSERT(!RunLoop::isMain()); 64 69 for (auto storageArea : m_storageAreaMap.values()) 65 70 storageArea->clear(); … … 68 73 Vector<SecurityOriginData> LocalStorageNamespace::ephemeralOrigins() const 69 74 { 75 ASSERT(!RunLoop::isMain()); 70 76 Vector<SecurityOriginData> origins; 71 77 for (const auto& storageArea : m_storageAreaMap.values()) { … … 78 84 void LocalStorageNamespace::cloneTo(LocalStorageNamespace& newLocalStorageNamespace) 79 85 { 86 ASSERT(!RunLoop::isMain()); 80 87 for (auto& pair : m_storageAreaMap) 81 88 newLocalStorageNamespace.m_storageAreaMap.add(pair.key, pair.value->clone()); -
trunk/Source/WebKit/NetworkProcess/WebStorage/SessionStorageNamespace.cpp
r248422 r248452 36 36 : m_quotaInBytes(quotaInBytes) 37 37 { 38 ASSERT(!RunLoop::isMain()); 38 39 } 39 40 40 41 SessionStorageNamespace::~SessionStorageNamespace() 41 42 { 43 ASSERT(!RunLoop::isMain()); 42 44 } 43 45 44 46 void SessionStorageNamespace::addAllowedConnection(IPC::Connection::UniqueID allowedConnection) 45 47 { 48 ASSERT(!RunLoop::isMain()); 46 49 m_allowedConnections.add(allowedConnection); 47 50 } … … 50 53 void SessionStorageNamespace::removeAllowedConnection(IPC::Connection::UniqueID allowedConnection) 51 54 { 55 ASSERT(!RunLoop::isMain()); 52 56 ASSERT(m_allowedConnections.contains(allowedConnection)); 53 57 m_allowedConnections.remove(allowedConnection); … … 55 59 auto SessionStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin) -> Ref<StorageArea> 56 60 { 61 ASSERT(!RunLoop::isMain()); 57 62 return *m_storageAreaMap.ensure(securityOrigin, [this, &securityOrigin]() mutable { 58 63 return StorageArea::create(nullptr, WTFMove(securityOrigin), m_quotaInBytes); … … 62 67 void SessionStorageNamespace::cloneTo(SessionStorageNamespace& newSessionStorageNamespace) 63 68 { 69 ASSERT(!RunLoop::isMain()); 64 70 ASSERT_UNUSED(newSessionStorageNamespace, newSessionStorageNamespace.isEmpty()); 65 71 … … 70 76 Vector<SecurityOriginData> SessionStorageNamespace::origins() const 71 77 { 78 ASSERT(!RunLoop::isMain()); 72 79 Vector<SecurityOriginData> origins; 73 80 … … 82 89 void SessionStorageNamespace::clearStorageAreasMatchingOrigin(const SecurityOriginData& securityOrigin) 83 90 { 91 ASSERT(!RunLoop::isMain()); 84 92 auto originAndStorageArea = m_storageAreaMap.find(securityOrigin); 85 93 if (originAndStorageArea != m_storageAreaMap.end()) … … 89 97 void SessionStorageNamespace::clearAllStorageAreas() 90 98 { 99 ASSERT(!RunLoop::isMain()); 91 100 for (auto& storageArea : m_storageAreaMap.values()) 92 101 storageArea->clear(); -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp
r248422 r248452 43 43 , m_storageMap(StorageMap::create(m_quotaInBytes)) 44 44 { 45 ASSERT(!RunLoop::isMain()); 45 46 } 46 47 47 48 StorageArea::~StorageArea() 48 49 { 50 ASSERT(!RunLoop::isMain()); 49 51 ASSERT(m_eventListeners.isEmpty()); 50 52 ASSERT(!m_localStorageNamespace); … … 56 58 void StorageArea::addListener(IPC::Connection::UniqueID connectionID, uint64_t storageMapID) 57 59 { 60 ASSERT(!RunLoop::isMain()); 58 61 ASSERT(!m_eventListeners.contains(std::make_pair(connectionID, storageMapID))); 59 62 m_eventListeners.add(std::make_pair(connectionID, storageMapID)); … … 62 65 void StorageArea::removeListener(IPC::Connection::UniqueID connectionID, uint64_t storageMapID) 63 66 { 67 ASSERT(!RunLoop::isMain()); 64 68 ASSERT(isEphemeral() || m_eventListeners.contains(std::make_pair(connectionID, storageMapID))); 65 69 m_eventListeners.remove(std::make_pair(connectionID, storageMapID)); … … 68 72 bool StorageArea::hasListener(IPC::Connection::UniqueID connectionID, uint64_t storageMapID) const 69 73 { 74 ASSERT(!RunLoop::isMain()); 70 75 return m_eventListeners.contains(std::make_pair(connectionID, storageMapID)); 71 76 } … … 73 78 Ref<StorageArea> StorageArea::clone() const 74 79 { 80 ASSERT(!RunLoop::isMain()); 75 81 ASSERT(!m_localStorageNamespace); 76 82 … … 83 89 void StorageArea::setItem(IPC::Connection::UniqueID sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException) 84 90 { 91 ASSERT(!RunLoop::isMain()); 85 92 openDatabaseAndImportItemsIfNeeded(); 86 93 … … 102 109 void StorageArea::setItems(const HashMap<String, String>& items) 103 110 { 111 ASSERT(!RunLoop::isMain()); 104 112 // Import items from web process if items are not stored on disk. 105 113 if (!isEphemeral()) … … 120 128 void StorageArea::removeItem(IPC::Connection::UniqueID sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& urlString) 121 129 { 130 ASSERT(!RunLoop::isMain()); 122 131 openDatabaseAndImportItemsIfNeeded(); 123 132 … … 138 147 void StorageArea::clear(IPC::Connection::UniqueID sourceConnection, uint64_t sourceStorageAreaID, const String& urlString) 139 148 { 149 ASSERT(!RunLoop::isMain()); 140 150 openDatabaseAndImportItemsIfNeeded(); 141 151 … … 153 163 const HashMap<String, String>& StorageArea::items() const 154 164 { 165 ASSERT(!RunLoop::isMain()); 155 166 openDatabaseAndImportItemsIfNeeded(); 156 167 … … 160 171 void StorageArea::clear() 161 172 { 173 ASSERT(!RunLoop::isMain()); 162 174 m_storageMap = StorageMap::create(m_quotaInBytes); 163 175 … … 177 189 void StorageArea::openDatabaseAndImportItemsIfNeeded() const 178 190 { 191 ASSERT(!RunLoop::isMain()); 179 192 if (!m_localStorageNamespace) 180 193 return; … … 194 207 void StorageArea::dispatchEvents(IPC::Connection::UniqueID sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const 195 208 { 209 ASSERT(!RunLoop::isMain()); 196 210 for (auto it = m_eventListeners.begin(), end = m_eventListeners.end(); it != end; ++it) { 197 211 sourceStorageAreaID = it->first == sourceConnection ? sourceStorageAreaID : 0; -
trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManager.cpp
r248422 r248452 68 68 void StorageManager::createSessionStorageNamespace(uint64_t storageNamespaceID, unsigned quotaInBytes) 69 69 { 70 ASSERT(RunLoop::isMain()); 70 71 m_queue->dispatch([this, protectedThis = makeRef(*this), storageNamespaceID, quotaInBytes]() mutable { 71 72 m_sessionStorageNamespaces.ensure(storageNamespaceID, [quotaInBytes] { … … 77 78 void StorageManager::destroySessionStorageNamespace(uint64_t storageNamespaceID) 78 79 { 80 ASSERT(RunLoop::isMain()); 79 81 m_queue->dispatch([this, protectedThis = makeRef(*this), storageNamespaceID] { 80 82 ASSERT(m_sessionStorageNamespaces.contains(storageNamespaceID)); … … 88 90 void StorageManager::addAllowedSessionStorageNamespaceConnection(uint64_t storageNamespaceID, IPC::Connection& allowedConnection) 89 91 { 92 ASSERT(RunLoop::isMain()); 90 93 auto allowedConnectionID = allowedConnection.uniqueID(); 91 94 auto addResult = m_connections.add(allowedConnectionID); … … 102 105 void StorageManager::removeAllowedSessionStorageNamespaceConnection(uint64_t storageNamespaceID, IPC::Connection& allowedConnection) 103 106 { 107 ASSERT(RunLoop::isMain()); 104 108 auto allowedConnectionID = allowedConnection.uniqueID(); 105 109 m_queue->dispatch([this, protectedThis = makeRef(*this), allowedConnectionID, storageNamespaceID]() mutable { … … 112 116 void StorageManager::cloneSessionStorageNamespace(uint64_t storageNamespaceID, uint64_t newStorageNamespaceID) 113 117 { 118 ASSERT(RunLoop::isMain()); 114 119 m_queue->dispatch([this, protectedThis = makeRef(*this), storageNamespaceID, newStorageNamespaceID] { 115 120 SessionStorageNamespace* sessionStorageNamespace = m_sessionStorageNamespaces.get(storageNamespaceID); … … 137 142 void StorageManager::processDidCloseConnection(IPC::Connection& connection) 138 143 { 144 ASSERT(RunLoop::isMain()); 139 145 if (m_connections.remove(connection.uniqueID())) 140 146 connection.removeWorkQueueMessageReceiver(Messages::StorageManager::messageReceiverName()); … … 169 175 void StorageManager::getSessionStorageOrigins(Function<void(HashSet<WebCore::SecurityOriginData>&&)>&& completionHandler) 170 176 { 177 ASSERT(RunLoop::isMain()); 171 178 m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable { 172 179 HashSet<SecurityOriginData> origins; … … 185 192 void StorageManager::deleteSessionStorageOrigins(Function<void()>&& completionHandler) 186 193 { 194 ASSERT(RunLoop::isMain()); 187 195 m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable { 188 196 for (auto& sessionStorageNamespace : m_sessionStorageNamespaces.values()) … … 195 203 void StorageManager::deleteSessionStorageEntriesForOrigins(const Vector<WebCore::SecurityOriginData>& origins, Function<void()>&& completionHandler) 196 204 { 205 ASSERT(RunLoop::isMain()); 197 206 m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigins = crossThreadCopy(origins), completionHandler = WTFMove(completionHandler)]() mutable { 198 207 for (auto& origin : copiedOrigins) { … … 207 216 void StorageManager::getLocalStorageOrigins(Function<void(HashSet<WebCore::SecurityOriginData>&&)>&& completionHandler) 208 217 { 218 ASSERT(RunLoop::isMain()); 209 219 m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable { 210 220 HashSet<SecurityOriginData> origins; … … 233 243 void StorageManager::getLocalStorageOriginDetails(Function<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&& completionHandler) 234 244 { 245 ASSERT(RunLoop::isMain()); 235 246 m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable { 236 247 Vector<LocalStorageDatabaseTracker::OriginDetails> originDetails; … … 246 257 void StorageManager::deleteLocalStorageEntriesForOrigin(const SecurityOriginData& securityOrigin) 247 258 { 259 ASSERT(RunLoop::isMain()); 248 260 m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigin = securityOrigin.isolatedCopy()]() mutable { 249 261 for (auto& localStorageNamespace : m_localStorageNamespaces.values()) … … 260 272 void StorageManager::deleteLocalStorageOriginsModifiedSince(WallTime time, Function<void()>&& completionHandler) 261 273 { 274 ASSERT(RunLoop::isMain()); 262 275 m_queue->dispatch([this, protectedThis = makeRef(*this), time, completionHandler = WTFMove(completionHandler)]() mutable { 263 276 if (m_localStorageDatabaseTracker) { … … 284 297 void StorageManager::deleteLocalStorageEntriesForOrigins(const Vector<WebCore::SecurityOriginData>& origins, Function<void()>&& completionHandler) 285 298 { 299 ASSERT(RunLoop::isMain()); 286 300 m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigins = crossThreadCopy(origins), completionHandler = WTFMove(completionHandler)]() mutable { 287 301 for (auto& origin : copiedOrigins) { … … 477 491 void StorageManager::waitUntilTasksFinished() 478 492 { 493 ASSERT(RunLoop::isMain()); 479 494 BinarySemaphore semaphore; 480 495 m_queue->dispatch([this, &semaphore] { … … 497 512 void StorageManager::suspend(CompletionHandler<void()>&& completionHandler) 498 513 { 514 ASSERT(RunLoop::isMain()); 499 515 CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler)); 500 516 if (!m_localStorageDatabaseTracker) … … 526 542 void StorageManager::resume() 527 543 { 544 ASSERT(RunLoop::isMain()); 528 545 if (!m_localStorageDatabaseTracker) 529 546 return; … … 538 555 StorageArea* StorageManager::findStorageArea(IPC::Connection& connection, uint64_t storageMapID) const 539 556 { 557 ASSERT(!RunLoop::isMain()); 540 558 std::pair<IPC::Connection::UniqueID, uint64_t> connectionAndStorageMapIDPair(connection.uniqueID(), storageMapID); 541 559 … … 548 566 LocalStorageNamespace* StorageManager::getOrCreateLocalStorageNamespace(uint64_t storageNamespaceID) 549 567 { 568 ASSERT(!RunLoop::isMain()); 550 569 if (!m_localStorageNamespaces.isValidKey(storageNamespaceID)) 551 570 return nullptr; … … 558 577 TransientLocalStorageNamespace* StorageManager::getOrCreateTransientLocalStorageNamespace(uint64_t storageNamespaceID, WebCore::SecurityOriginData&& topLevelOrigin) 559 578 { 579 ASSERT(!RunLoop::isMain()); 560 580 if (!m_transientLocalStorageNamespaces.isValidKey({ storageNamespaceID, topLevelOrigin })) 561 581 return nullptr; -
trunk/Source/WebKit/NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp
r248422 r248452 37 37 : m_quotaInBytes(StorageManager::localStorageDatabaseQuotaInBytes) 38 38 { 39 ASSERT(!RunLoop::isMain()); 39 40 } 40 41 41 42 TransientLocalStorageNamespace::~TransientLocalStorageNamespace() 42 43 { 44 ASSERT(!RunLoop::isMain()); 43 45 } 44 46 45 47 Ref<StorageArea> TransientLocalStorageNamespace::getOrCreateStorageArea(SecurityOriginData&& securityOrigin) 46 48 { 49 ASSERT(!RunLoop::isMain()); 47 50 return *m_storageAreaMap.ensure(securityOrigin, [this, &securityOrigin]() mutable { 48 51 return StorageArea::create(nullptr, WTFMove(securityOrigin), m_quotaInBytes); … … 52 55 Vector<SecurityOriginData> TransientLocalStorageNamespace::origins() const 53 56 { 57 ASSERT(!RunLoop::isMain()); 54 58 Vector<SecurityOriginData> origins; 55 59 … … 64 68 void TransientLocalStorageNamespace::clearStorageAreasMatchingOrigin(const SecurityOriginData& securityOrigin) 65 69 { 70 ASSERT(!RunLoop::isMain()); 66 71 auto originAndStorageArea = m_storageAreaMap.find(securityOrigin); 67 72 if (originAndStorageArea != m_storageAreaMap.end()) … … 71 76 void TransientLocalStorageNamespace::clearAllStorageAreas() 72 77 { 78 ASSERT(!RunLoop::isMain()); 73 79 for (auto& storageArea : m_storageAreaMap.values()) 74 80 storageArea->clear();
Note:
See TracChangeset
for help on using the changeset viewer.