Diff
Modified: trunk/Source/WebKit2/ChangeLog (144690 => 144691)
--- trunk/Source/WebKit2/ChangeLog 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/ChangeLog 2013-03-04 23:47:23 UTC (rev 144691)
@@ -1,3 +1,30 @@
+2013-03-04 Anders Carlsson <[email protected]>
+
+ More work on UI side storage
+ https://bugs.webkit.org/show_bug.cgi?id=111370
+
+ Reviewed by Andreas Kling.
+
+ Add a DispatchStorageEvent message and begin hooking it up.
+
+ * UIProcess/Storage/StorageManager.cpp:
+ (StorageManager::StorageArea):
+ (WebKit::StorageManager::StorageArea::setItem):
+ (WebKit):
+ (WebKit::StorageManager::StorageArea::dispatchEvents):
+ (WebKit::StorageManager::setItem):
+ (WebKit::StorageManager::findStorageArea):
+ * UIProcess/Storage/StorageManager.h:
+ (StorageManager):
+ * UIProcess/Storage/StorageManager.messages.in:
+ * WebProcess/Storage/StorageAreaProxy.cpp:
+ (WebKit::StorageAreaProxy::setItem):
+ (WebKit::StorageAreaProxy::dispatchStorageEvent):
+ (WebKit):
+ * WebProcess/Storage/StorageAreaProxy.h:
+ (StorageAreaProxy):
+ * WebProcess/Storage/StorageAreaProxy.messages.in:
+
2013-03-04 Jer Noble <[email protected]>
Unreviewed build fix: wrap references to PluginInfoStore with
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (144690 => 144691)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-03-04 23:47:23 UTC (rev 144691)
@@ -45,9 +45,13 @@
void addListener(CoreIPC::Connection*, uint64_t storageAreaID);
void removeListener(CoreIPC::Connection*, uint64_t storageAreaID);
+ bool setItem(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& value, const String& urlString);
+
private:
StorageArea();
+ void dispatchEvents(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
+
HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>> m_eventListeners;
};
@@ -77,6 +81,28 @@
m_eventListeners.remove(std::make_pair(connection, storageAreaID));
}
+bool StorageManager::StorageArea::setItem(CoreIPC::Connection* connection, uint64_t storageAreaID, const String& key, const String& value, const String& urlString)
+{
+ // FIXME: Actually set the item.
+
+ String oldValue;
+ dispatchEvents(connection, storageAreaID, key, oldValue, value, urlString);
+
+ return true;
+}
+
+void StorageManager::StorageArea::dispatchEvents(CoreIPC::Connection* connection, uint64_t storageAreaID, 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) {
+ if (it->first == connection && it->second == storageAreaID) {
+ // We don't want to dispatch events to the storage area that originated the event.
+ continue;
+ }
+
+ it->first->send(Messages::StorageAreaProxy::DispatchStorageEvent(key, oldValue, newValue, urlString), it->second);
+ }
+}
+
class StorageManager::SessionStorageNamespace : public ThreadSafeRefCounted<SessionStorageNamespace> {
public:
static PassRefPtr<SessionStorageNamespace> create(CoreIPC::Connection* allowedConnection);
@@ -231,12 +257,15 @@
// FIXME: Implement this.
}
-void StorageManager::setItem(CoreIPC::Connection* connection, uint64_t storageAreaID, const String& key, const String& value)
+void StorageManager::setItem(CoreIPC::Connection* connection, uint64_t storageAreaID, const String& key, const String& value, const String& urlString)
{
- // FIXME: Find the right storage area and set the item.
- // FIXME: Send out storage changed events.
+ StorageArea* storageArea = findStorageArea(connection, storageAreaID);
- bool quotaError = false;
+ // FIXME: This should be a message check.
+ ASSERT(storageArea);
+
+ bool quotaError = storageArea->setItem(connection, storageAreaID, key, value, urlString);
+
connection->send(Messages::StorageAreaProxy::DidSetItem(key, quotaError), storageAreaID);
}
@@ -272,4 +301,13 @@
sessionStorageNamespace->cloneTo(*newSessionStorageNamespace);
}
+StorageManager::StorageArea* StorageManager::findStorageArea(CoreIPC::Connection* connection, uint64_t storageAreaID) const
+{
+ std::pair<CoreIPC::Connection*, uint64_t> connectionAndStorageAreaIDPair(connection, storageAreaID);
+ if (!HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageAreaIDPair))
+ return 0;
+
+ return m_storageAreas.get(connectionAndStorageAreaIDPair).get();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h (144690 => 144691)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h 2013-03-04 23:47:23 UTC (rev 144691)
@@ -62,19 +62,21 @@
void createStorageArea(CoreIPC::Connection*, uint64_t storageAreaID, uint64_t storageNamespaceID, const SecurityOriginData&);
void destroyStorageArea(CoreIPC::Connection*, uint64_t storageAreaID);
void getValues(CoreIPC::Connection*, uint64_t storageAreaID, HashMap<String, String>& values);
- void setItem(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& value);
+ void setItem(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& value, const String& urlString);
void createSessionStorageNamespaceInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection);
void destroySessionStorageNamespaceInternal(uint64_t storageNamespaceID);
void setAllowedSessionStorageNamespaceConnectionInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection);
void cloneSessionStorageNamespaceInternal(uint64_t storageNamespaceID, uint64_t newStorageNamespaceID);
+ class StorageArea;
+ StorageArea* findStorageArea(CoreIPC::Connection*, uint64_t) const;
+
RefPtr<WorkQueue> m_queue;
class SessionStorageNamespace;
HashMap<uint64_t, RefPtr<SessionStorageNamespace> > m_sessionStorageNamespaces;
- class StorageArea;
HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> > m_storageAreas;
};
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in (144690 => 144691)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in 2013-03-04 23:47:23 UTC (rev 144691)
@@ -26,5 +26,5 @@
GetValues(uint64_t storageAreaID) -> (WTF::HashMap<WTF::String, WTF::String> values) WantsConnection
- SetItem(uint64_t storageAreaID, WTF::String key, WTF::String value) WantsConnection
+ SetItem(uint64_t storageAreaID, WTF::String key, WTF::String value, WTF::String urlString) WantsConnection
}
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.cpp (144690 => 144691)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.cpp 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.cpp 2013-03-04 23:47:23 UTC (rev 144691)
@@ -142,7 +142,7 @@
if (oldValue == value)
return;
- WebProcess::shared().connection()->send(Messages::StorageManager::SetItem(m_storageAreaID, key, value), 0);
+ WebProcess::shared().connection()->send(Messages::StorageManager::SetItem(m_storageAreaID, key, value, sourceFrame->document()->url()), 0);
}
void StorageAreaProxy::removeItem(const String& key, ExceptionCode&, Frame* sourceFrame)
@@ -204,6 +204,11 @@
// FIXME: Implement this.
}
+void StorageAreaProxy::dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, const String& urlString)
+{
+ // FIXME: Implement this.
+}
+
bool StorageAreaProxy::disabledByPrivateBrowsingInFrame(const Frame* sourceFrame) const
{
if (!sourceFrame->page()->settings()->privateBrowsingEnabled())
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.h (144690 => 144691)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.h 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.h 2013-03-04 23:47:23 UTC (rev 144691)
@@ -64,6 +64,7 @@
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
void didSetItem(const String& key, bool quotaError);
+ void dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, const String& urlString);
bool disabledByPrivateBrowsingInFrame(const WebCore::Frame* sourceFrame) const;
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.messages.in (144690 => 144691)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.messages.in 2013-03-04 23:45:59 UTC (rev 144690)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.messages.in 2013-03-04 23:47:23 UTC (rev 144691)
@@ -22,4 +22,6 @@
messages -> StorageAreaProxy {
DidSetItem(WTF::String key, bool quotaException)
+
+ DispatchStorageEvent(WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString)
}