Changeset 148250 in webkit
- Timestamp:
- Apr 11, 2013 4:55:03 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r148249 r148250 1 2013-04-11 Anders Carlsson <andersca@apple.com> 2 3 Add support for clearing storage areas 4 https://bugs.webkit.org/show_bug.cgi?id=114479 5 6 Reviewed by Beth Dakin. 7 8 * UIProcess/Storage/StorageManager.cpp: 9 (WebKit::StorageManager::StorageArea::StorageArea): 10 Store the quota size so we can recreate the underlying StorageMap when clearing. 11 12 (WebKit::StorageManager::StorageArea::clear): 13 Create a new storage map and dispatch events. 14 15 (WebKit::StorageManager::clear): 16 Find the right storage area and call clear. 17 18 * UIProcess/Storage/StorageManager.messages.in: 19 Add Clear message. 20 21 * WebProcess/Storage/StorageAreaImpl.cpp: 22 (WebKit::StorageAreaImpl::clear): 23 Call the storage map. 24 25 * WebProcess/Storage/StorageAreaMap.cpp: 26 (WebKit::StorageAreaMap::clear): 27 Reset the cached values and send a clear message. 28 29 (WebKit::StorageAreaMap::resetValues): 30 New helper function. 31 32 (WebKit::StorageAreaMap::didClear): 33 New stub. 34 35 * WebProcess/Storage/StorageAreaMap.messages.in: 36 Add DidClear message. 37 1 38 2013-04-11 Beth Dakin <bdakin@apple.com> 2 39 -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp
r148245 r148250 49 49 void setItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException); 50 50 void removeItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& urlString); 51 void clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString); 51 52 52 53 const HashMap<String, String>& items() const { return m_storageMap->items(); } … … 57 58 void dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const; 58 59 60 unsigned m_quotaInBytes; 59 61 RefPtr<StorageMap> m_storageMap; 60 62 HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> > m_eventListeners; … … 67 69 68 70 StorageManager::StorageArea::StorageArea(unsigned quotaInBytes) 69 : m_storageMap(StorageMap::create(quotaInBytes)) 71 : m_quotaInBytes(quotaInBytes) 72 , m_storageMap(StorageMap::create(m_quotaInBytes)) 70 73 { 71 74 } … … 108 111 109 112 dispatchEvents(sourceConnection, sourceStorageAreaID, key, oldValue, String(), urlString); 113 } 114 115 void StorageManager::StorageArea::clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString) 116 { 117 if (!m_storageMap->length()) 118 return; 119 120 m_storageMap = StorageMap::create(m_quotaInBytes); 121 122 dispatchEvents(sourceConnection, sourceStorageAreaID, String(), String(), String(), urlString); 110 123 } 111 124 … … 302 315 storageArea->removeItem(connection, sourceStorageAreaID, key, urlString); 303 316 connection->send(Messages::StorageAreaMap::DidRemoveItem(key), storageMapID); 317 } 318 319 void StorageManager::clear(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& urlString) 320 { 321 StorageArea* storageArea = findStorageArea(connection, storageMapID); 322 323 // FIXME: This should be a message check. 324 ASSERT(storageArea); 325 326 storageArea->clear(connection, sourceStorageAreaID, urlString); 327 connection->send(Messages::StorageAreaMap::DidClear(), storageMapID); 304 328 } 305 329 -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h
r148245 r148250 65 65 void setItem(CoreIPC::Connection*, uint64_t storageAreaID, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString); 66 66 void removeItem(CoreIPC::Connection*, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& key, const String& urlString); 67 void clear(CoreIPC::Connection*, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& urlString); 67 68 68 69 void createSessionStorageNamespaceInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection, unsigned quotaInBytes); -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in
r148245 r148250 29 29 SetItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String value, WTF::String urlString) WantsConnection 30 30 RemoveItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String urlString) WantsConnection 31 Clear(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String urlString) WantsConnection 31 32 } -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp
r148245 r148250 142 142 } 143 143 144 void StorageAreaImpl::clear(ExceptionCode&, Frame* sourceFrame) 144 void StorageAreaImpl::clear(ExceptionCode& ec, Frame* sourceFrame) 145 { 146 ec = 0; 147 if (!canAccessStorage(sourceFrame)) { 148 ec = SECURITY_ERR; 149 return; 150 } 151 152 if (disabledByPrivateBrowsingInFrame(sourceFrame)) 153 return; 154 155 m_storageAreaMap->clear(sourceFrame, this); 156 } 157 158 bool StorageAreaImpl::contains(const String& key, ExceptionCode& ec, Frame* sourceFrame) 159 { 160 ec = 0; 161 if (!canAccessStorage(sourceFrame)) { 162 ec = SECURITY_ERR; 163 return false; 164 } 165 if (disabledByPrivateBrowsingInFrame(sourceFrame)) 166 return false; 167 168 return m_storageAreaMap->contains(key); 169 } 170 171 bool StorageAreaImpl::canAccessStorage(Frame* frame) 172 { 173 return frame && frame->page(); 174 } 175 176 size_t StorageAreaImpl::memoryBytesUsedByCache() 177 { 178 return 0; 179 } 180 181 void StorageAreaImpl::incrementAccessCount() 182 { 183 // Storage access is handled in the UI process, so there's nothing to do here. 184 } 185 186 void StorageAreaImpl::decrementAccessCount() 187 { 188 // Storage access is handled in the UI process, so there's nothing to do here. 189 } 190 191 void StorageAreaImpl::closeDatabaseIfIdle() 145 192 { 146 193 // FIXME: Implement this. 147 194 ASSERT_NOT_REACHED(); 148 UNUSED_PARAM(sourceFrame);149 }150 151 bool StorageAreaImpl::contains(const String& key, ExceptionCode& ec, Frame* sourceFrame)152 {153 ec = 0;154 if (!canAccessStorage(sourceFrame)) {155 ec = SECURITY_ERR;156 return false;157 }158 if (disabledByPrivateBrowsingInFrame(sourceFrame))159 return false;160 161 return m_storageAreaMap->contains(key);162 }163 164 bool StorageAreaImpl::canAccessStorage(Frame* frame)165 {166 return frame && frame->page();167 }168 169 size_t StorageAreaImpl::memoryBytesUsedByCache()170 {171 return 0;172 }173 174 void StorageAreaImpl::incrementAccessCount()175 {176 // Storage access is handled in the UI process, so there's nothing to do here.177 }178 179 void StorageAreaImpl::decrementAccessCount()180 {181 // Storage access is handled in the UI process, so there's nothing to do here.182 }183 184 void StorageAreaImpl::closeDatabaseIfIdle()185 {186 // FIXME: Implement this.187 ASSERT_NOT_REACHED();188 195 } 189 196 -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp
r148245 r148250 137 137 } 138 138 139 void StorageAreaMap::clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea) 140 { 141 resetValues(); 142 143 m_storageMap = StorageMap::create(m_quotaInBytes); 144 WebProcess::shared().connection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), sourceFrame->document()->url()), 0); 145 } 146 139 147 bool StorageAreaMap::contains(const String& key) 140 148 { … … 142 150 143 151 return m_storageMap->contains(key); 152 } 153 154 void StorageAreaMap::resetValues() 155 { 156 m_storageMap = nullptr; 144 157 } 145 158 … … 169 182 } 170 183 184 void StorageAreaMap::didClear() 185 { 186 // FIXME: Implement. 187 } 188 171 189 void StorageAreaMap::dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) 172 190 { -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h
r148245 r148250 57 57 void setItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException); 58 58 void removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key); 59 void clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea); 59 60 bool contains(const String& key); 60 61 … … 67 68 void didSetItem(const String& key, bool quotaError); 68 69 void didRemoveItem(const String& key); 70 void didClear(); 69 71 70 72 void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString); 71 73 74 void resetValues(); 72 75 void loadValuesIfNeeded(); 73 76 -
trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in
r148245 r148250 24 24 DidSetItem(WTF::String key, bool quotaException) 25 25 DidRemoveItem(WTF::String key) 26 DidClear() 26 27 27 28 DispatchStorageEvent(uint64_t sourceStorageAreaID, WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString)
Note: See TracChangeset
for help on using the changeset viewer.