Diff
Modified: trunk/Source/WebKit2/ChangeLog (148249 => 148250)
--- trunk/Source/WebKit2/ChangeLog 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-11 23:55:03 UTC (rev 148250)
@@ -1,3 +1,40 @@
+2013-04-11 Anders Carlsson <[email protected]>
+
+ Add support for clearing storage areas
+ https://bugs.webkit.org/show_bug.cgi?id=114479
+
+ Reviewed by Beth Dakin.
+
+ * UIProcess/Storage/StorageManager.cpp:
+ (WebKit::StorageManager::StorageArea::StorageArea):
+ Store the quota size so we can recreate the underlying StorageMap when clearing.
+
+ (WebKit::StorageManager::StorageArea::clear):
+ Create a new storage map and dispatch events.
+
+ (WebKit::StorageManager::clear):
+ Find the right storage area and call clear.
+
+ * UIProcess/Storage/StorageManager.messages.in:
+ Add Clear message.
+
+ * WebProcess/Storage/StorageAreaImpl.cpp:
+ (WebKit::StorageAreaImpl::clear):
+ Call the storage map.
+
+ * WebProcess/Storage/StorageAreaMap.cpp:
+ (WebKit::StorageAreaMap::clear):
+ Reset the cached values and send a clear message.
+
+ (WebKit::StorageAreaMap::resetValues):
+ New helper function.
+
+ (WebKit::StorageAreaMap::didClear):
+ New stub.
+
+ * WebProcess/Storage/StorageAreaMap.messages.in:
+ Add DidClear message.
+
2013-04-11 Beth Dakin <[email protected]>
WebKit should set the header and footer layers' contentsScale when the device
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (148249 => 148250)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-04-11 23:55:03 UTC (rev 148250)
@@ -48,6 +48,7 @@
void setItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException);
void removeItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& urlString);
+ void clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString);
const HashMap<String, String>& items() const { return m_storageMap->items(); }
@@ -56,6 +57,7 @@
void dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
+ unsigned m_quotaInBytes;
RefPtr<StorageMap> m_storageMap;
HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> > m_eventListeners;
};
@@ -66,7 +68,8 @@
}
StorageManager::StorageArea::StorageArea(unsigned quotaInBytes)
- : m_storageMap(StorageMap::create(quotaInBytes))
+ : m_quotaInBytes(quotaInBytes)
+ , m_storageMap(StorageMap::create(m_quotaInBytes))
{
}
@@ -109,6 +112,16 @@
dispatchEvents(sourceConnection, sourceStorageAreaID, key, oldValue, String(), urlString);
}
+void StorageManager::StorageArea::clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString)
+{
+ if (!m_storageMap->length())
+ return;
+
+ m_storageMap = StorageMap::create(m_quotaInBytes);
+
+ dispatchEvents(sourceConnection, sourceStorageAreaID, String(), String(), String(), urlString);
+}
+
void StorageManager::StorageArea::dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const
{
for (HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> >::const_iterator it = m_eventListeners.begin(), end = m_eventListeners.end(); it != end; ++it) {
@@ -303,6 +316,17 @@
connection->send(Messages::StorageAreaMap::DidRemoveItem(key), storageMapID);
}
+void StorageManager::clear(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& urlString)
+{
+ StorageArea* storageArea = findStorageArea(connection, storageMapID);
+
+ // FIXME: This should be a message check.
+ ASSERT(storageArea);
+
+ storageArea->clear(connection, sourceStorageAreaID, urlString);
+ connection->send(Messages::StorageAreaMap::DidClear(), storageMapID);
+}
+
void StorageManager::createSessionStorageNamespaceInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection, unsigned quotaInBytes)
{
ASSERT(!m_sessionStorageNamespaces.contains(storageNamespaceID));
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h (148249 => 148250)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h 2013-04-11 23:55:03 UTC (rev 148250)
@@ -64,6 +64,7 @@
void getValues(CoreIPC::Connection*, uint64_t storageMapID, HashMap<String, String>& values);
void setItem(CoreIPC::Connection*, uint64_t storageAreaID, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString);
void removeItem(CoreIPC::Connection*, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& key, const String& urlString);
+ void clear(CoreIPC::Connection*, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& urlString);
void createSessionStorageNamespaceInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection, unsigned quotaInBytes);
void destroySessionStorageNamespaceInternal(uint64_t storageNamespaceID);
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in (148249 => 148250)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in 2013-04-11 23:55:03 UTC (rev 148250)
@@ -28,4 +28,5 @@
SetItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String value, WTF::String urlString) WantsConnection
RemoveItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String urlString) WantsConnection
+ Clear(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String urlString) WantsConnection
}
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp (148249 => 148250)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp 2013-04-11 23:55:03 UTC (rev 148250)
@@ -141,11 +141,18 @@
m_storageAreaMap->removeItem(sourceFrame, this, key);
}
-void StorageAreaImpl::clear(ExceptionCode&, Frame* sourceFrame)
+void StorageAreaImpl::clear(ExceptionCode& ec, Frame* sourceFrame)
{
- // FIXME: Implement this.
- ASSERT_NOT_REACHED();
- UNUSED_PARAM(sourceFrame);
+ ec = 0;
+ if (!canAccessStorage(sourceFrame)) {
+ ec = SECURITY_ERR;
+ return;
+ }
+
+ if (disabledByPrivateBrowsingInFrame(sourceFrame))
+ return;
+
+ m_storageAreaMap->clear(sourceFrame, this);
}
bool StorageAreaImpl::contains(const String& key, ExceptionCode& ec, Frame* sourceFrame)
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp (148249 => 148250)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2013-04-11 23:55:03 UTC (rev 148250)
@@ -136,6 +136,14 @@
WebProcess::shared().connection()->send(Messages::StorageManager::RemoveItem(m_storageMapID, sourceArea->storageAreaID(), key, sourceFrame->document()->url()), 0);
}
+void StorageAreaMap::clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea)
+{
+ resetValues();
+
+ m_storageMap = StorageMap::create(m_quotaInBytes);
+ WebProcess::shared().connection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), sourceFrame->document()->url()), 0);
+}
+
bool StorageAreaMap::contains(const String& key)
{
loadValuesIfNeeded();
@@ -143,6 +151,11 @@
return m_storageMap->contains(key);
}
+void StorageAreaMap::resetValues()
+{
+ m_storageMap = nullptr;
+}
+
void StorageAreaMap::loadValuesIfNeeded()
{
if (m_storageMap)
@@ -168,6 +181,11 @@
// FIXME: Implement.
}
+void StorageAreaMap::didClear()
+{
+ // FIXME: Implement.
+}
+
void StorageAreaMap::dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
{
if (storageType() == SessionStorage)
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h (148249 => 148250)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h 2013-04-11 23:55:03 UTC (rev 148250)
@@ -56,6 +56,7 @@
String item(const String& key);
void setItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException);
void removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key);
+ void clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea);
bool contains(const String& key);
private:
@@ -66,9 +67,11 @@
void didSetItem(const String& key, bool quotaError);
void didRemoveItem(const String& key);
+ void didClear();
void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString);
+ void resetValues();
void loadValuesIfNeeded();
void dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString);
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in (148249 => 148250)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in 2013-04-11 23:51:51 UTC (rev 148249)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in 2013-04-11 23:55:03 UTC (rev 148250)
@@ -23,6 +23,7 @@
messages -> StorageAreaMap {
DidSetItem(WTF::String key, bool quotaException)
DidRemoveItem(WTF::String key)
+ DidClear()
DispatchStorageEvent(uint64_t sourceStorageAreaID, WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString)
}