Title: [149772] trunk/Source/WebKit2
- Revision
- 149772
- Author
- [email protected]
- Date
- 2013-05-08 15:34:02 -0700 (Wed, 08 May 2013)
Log Message
Apply remote changes to storage maps locally
https://bugs.webkit.org/show_bug.cgi?id=115825
Reviewed by Beth Dakin.
* WebProcess/Storage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::resetValues):
Clear the pending values map.
(WebKit::StorageAreaMap::didSetItem):
If we failed to set the item, forget everything we know about this storage map.
Otherwise, remove the pending item.
(WebKit::StorageAreaMap::didRemoveItem):
Remove the pending item.
(WebKit::StorageAreaMap::shouldApplyChangeForKey):
Helper function that returns whether a change for a given key should be applied.
(WebKit::StorageAreaMap::applyChange):
Apply the change. Currently only adds and removes are handled.
(WebKit::StorageAreaMap::dispatchStorageEvent):
Apply the change locally as well if needed.
* WebProcess/Storage/StorageAreaMap.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (149771 => 149772)
--- trunk/Source/WebKit2/ChangeLog 2013-05-08 22:26:42 UTC (rev 149771)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-08 22:34:02 UTC (rev 149772)
@@ -1,5 +1,34 @@
2013-05-08 Anders Carlsson <[email protected]>
+ Apply remote changes to storage maps locally
+ https://bugs.webkit.org/show_bug.cgi?id=115825
+
+ Reviewed by Beth Dakin.
+
+ * WebProcess/Storage/StorageAreaMap.cpp:
+ (WebKit::StorageAreaMap::resetValues):
+ Clear the pending values map.
+
+ (WebKit::StorageAreaMap::didSetItem):
+ If we failed to set the item, forget everything we know about this storage map.
+ Otherwise, remove the pending item.
+
+ (WebKit::StorageAreaMap::didRemoveItem):
+ Remove the pending item.
+
+ (WebKit::StorageAreaMap::shouldApplyChangeForKey):
+ Helper function that returns whether a change for a given key should be applied.
+
+ (WebKit::StorageAreaMap::applyChange):
+ Apply the change. Currently only adds and removes are handled.
+
+ (WebKit::StorageAreaMap::dispatchStorageEvent):
+ Apply the change locally as well if needed.
+
+ * WebProcess/Storage/StorageAreaMap.h:
+
+2013-05-08 Anders Carlsson <[email protected]>
+
Assert at compile time that we don't pass Objective-C object pointers to adoptCF
https://bugs.webkit.org/show_bug.cgi?id=115823
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp (149771 => 149772)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2013-05-08 22:26:42 UTC (rev 149771)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2013-05-08 22:34:02 UTC (rev 149772)
@@ -152,6 +152,7 @@
void StorageAreaMap::resetValues()
{
m_storageMap = nullptr;
+ m_pendingValueChanges.clear();
}
void StorageAreaMap::loadValuesIfNeeded()
@@ -171,12 +172,21 @@
void StorageAreaMap::didSetItem(const String& key, bool quotaError)
{
- // FIXME: Implement.
+ ASSERT(m_pendingValueChanges.contains(key));
+
+ if (quotaError) {
+ resetValues();
+ return;
+ }
+
+ m_pendingValueChanges.remove(key);
}
void StorageAreaMap::didRemoveItem(const String& key)
{
- // FIXME: Implement.
+ ASSERT(m_pendingValueChanges.contains(key));
+
+ m_pendingValueChanges.remove(key);
}
void StorageAreaMap::didClear()
@@ -184,8 +194,48 @@
// FIXME: Implement.
}
+bool StorageAreaMap::shouldApplyChangeForKey(const String& key) const
+{
+ // We have not yet loaded anything from this storage map.
+ if (!m_storageMap)
+ return false;
+
+ // Check if this storage area is currently waiting for the storage manager to update the given key.
+ // If that is the case, we don't want to apply any changes made by other storage areas, since
+ // our change was made last.
+ if (m_pendingValueChanges.contains(key))
+ return false;
+
+ return true;
+}
+
+void StorageAreaMap::applyChange(const String& key, const String& newValue)
+{
+ ASSERT(m_storageMap->hasOneRef());
+
+ // FIXME: Handle clear.
+ ASSERT(!key.isNull());
+
+ if (!shouldApplyChangeForKey(key))
+ return;
+
+ if (!newValue) {
+ // A null new value means that the item should be removed.
+ String oldValue;
+ m_storageMap->removeItem(key, oldValue);
+ return;
+ }
+
+ m_storageMap->setItemIgnoringQuota(key, newValue);
+}
+
void StorageAreaMap::dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
{
+ if (!sourceStorageAreaID) {
+ // This storage event originates from another process so we need to apply the change to our storage area map.
+ applyChange(key, newValue);
+ }
+
if (storageType() == SessionStorage)
dispatchSessionStorageEvent(sourceStorageAreaID, key, oldValue, newValue, urlString);
else
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h (149771 => 149772)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h 2013-05-08 22:26:42 UTC (rev 149771)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h 2013-05-08 22:34:02 UTC (rev 149772)
@@ -69,11 +69,14 @@
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();
+ bool shouldApplyChangeForKey(const String& key) const;
+ void applyChange(const String& key, const String& newValue);
+
+ void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString);
+
void dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString);
void dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes