- Revision
- 149777
- Author
- [email protected]
- Date
- 2013-05-08 16:31:38 -0700 (Wed, 08 May 2013)
Log Message
Don't apply changes while we're clearing the database
https://bugs.webkit.org/show_bug.cgi?id=115826
Reviewed by Darin Adler.
* UIProcess/Storage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::openDatabase):
Only call didOpenDatabaseWithOrigin if we actually did open the database.
(WebKit::LocalStorageDatabase::updateDatabaseWithChangedItems):
Create the database if needed.
* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::getValues):
Send back a DidGetValues message.
* WebProcess/Storage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::StorageAreaMap):
Initialize m_hasPendingClear.
(WebKit::StorageAreaMap::clear):
Set m_hasPendingClear to true.
(WebKit::StorageAreaMap::resetValues):
Set m_hasPendingClear back to false.
(WebKit::StorageAreaMap::loadValuesIfNeeded):
Set m_hasPendingClear to true so we'll ignore any changes that are already part of the returned items.
(WebKit::StorageAreaMap::didGetValues):
Set m_hasPendingClear back to false.
(WebKit::StorageAreaMap::didClear):
Set m_hasPendingClear back to false.
(WebKit::StorageAreaMap::applyChange):
Don't apply the change if m_hasPendingClear is true.
* WebProcess/Storage/StorageAreaMap.messages.in:
Add DidGetValues message.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (149776 => 149777)
--- trunk/Source/WebKit2/ChangeLog 2013-05-08 23:15:11 UTC (rev 149776)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-08 23:31:38 UTC (rev 149777)
@@ -1,3 +1,46 @@
+2013-05-08 Anders Carlsson <[email protected]>
+
+ Don't apply changes while we're clearing the database
+ https://bugs.webkit.org/show_bug.cgi?id=115826
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/Storage/LocalStorageDatabase.cpp:
+ (WebKit::LocalStorageDatabase::openDatabase):
+ Only call didOpenDatabaseWithOrigin if we actually did open the database.
+
+ (WebKit::LocalStorageDatabase::updateDatabaseWithChangedItems):
+ Create the database if needed.
+
+ * UIProcess/Storage/StorageManager.cpp:
+ (WebKit::StorageManager::getValues):
+ Send back a DidGetValues message.
+
+ * WebProcess/Storage/StorageAreaMap.cpp:
+ (WebKit::StorageAreaMap::StorageAreaMap):
+ Initialize m_hasPendingClear.
+
+ (WebKit::StorageAreaMap::clear):
+ Set m_hasPendingClear to true.
+
+ (WebKit::StorageAreaMap::resetValues):
+ Set m_hasPendingClear back to false.
+
+ (WebKit::StorageAreaMap::loadValuesIfNeeded):
+ Set m_hasPendingClear to true so we'll ignore any changes that are already part of the returned items.
+
+ (WebKit::StorageAreaMap::didGetValues):
+ Set m_hasPendingClear back to false.
+
+ (WebKit::StorageAreaMap::didClear):
+ Set m_hasPendingClear back to false.
+
+ (WebKit::StorageAreaMap::applyChange):
+ Don't apply the change if m_hasPendingClear is true.
+
+ * WebProcess/Storage/StorageAreaMap.messages.in:
+ Add DidGetValues message.
+
2013-05-08 Andy Estes <[email protected]>
[WebKit2] REGRESSION (Custom Protocols): Reproducible crash when navigating to URL with an invalid scheme
Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp (149776 => 149777)
--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2013-05-08 23:15:11 UTC (rev 149776)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2013-05-08 23:31:38 UTC (rev 149777)
@@ -78,7 +78,8 @@
return;
}
- m_tracker->didOpenDatabaseWithOrigin(m_securityOrigin.get());
+ if (m_database.isOpen())
+ m_tracker->didOpenDatabaseWithOrigin(m_securityOrigin.get());
}
bool LocalStorageDatabase::tryToOpenDatabase(DatabaseOpeningStrategy openingStrategy)
@@ -274,6 +275,11 @@
void LocalStorageDatabase::updateDatabaseWithChangedItems(const HashMap<String, String>& changedItems)
{
+ if (!m_database.isOpen())
+ openDatabase(CreateIfNonExistent);
+ if (!m_database.isOpen())
+ return;
+
if (m_shouldClearItems) {
m_shouldClearItems = false;
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (149776 => 149777)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-05-08 23:15:11 UTC (rev 149776)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-05-08 23:31:38 UTC (rev 149777)
@@ -451,6 +451,8 @@
ASSERT(storageArea);
values = storageArea->items();
+
+ connection->send(Messages::StorageAreaMap::DidGetValues(), storageMapID);
}
void StorageManager::setItem(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString)
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp (149776 => 149777)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2013-05-08 23:15:11 UTC (rev 149776)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp 2013-05-08 23:31:38 UTC (rev 149777)
@@ -63,6 +63,7 @@
, m_storageNamespaceID(storageNamespace->storageNamespaceID())
, m_quotaInBytes(storageNamespace->quotaInBytes())
, m_securityOrigin(securityOrigin)
+ , m_hasPendingClear(false)
{
if (m_storageType == LocalStorage)
WebProcess::shared().connection()->send(Messages::StorageManager::CreateLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin.get())), 0);
@@ -138,6 +139,7 @@
{
resetValues();
+ m_hasPendingClear = true;
m_storageMap = StorageMap::create(m_quotaInBytes);
WebProcess::shared().connection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), sourceFrame->document()->url()), 0);
}
@@ -153,6 +155,7 @@
{
m_storageMap = nullptr;
m_pendingValueChanges.clear();
+ m_hasPendingClear = false;
}
void StorageAreaMap::loadValuesIfNeeded()
@@ -168,8 +171,17 @@
m_storageMap = StorageMap::create(m_quotaInBytes);
m_storageMap->importItems(values);
+
+ // We want to ignore all changes until we get the DidGetValues message, so treat this as a pending clear.
+ m_hasPendingClear = true;
}
+void StorageAreaMap::didGetValues()
+{
+ ASSERT(m_hasPendingClear);
+ m_hasPendingClear = false;
+}
+
void StorageAreaMap::didSetItem(const String& key, bool quotaError)
{
ASSERT(m_pendingValueChanges.contains(key));
@@ -191,7 +203,8 @@
void StorageAreaMap::didClear()
{
- // FIXME: Implement.
+ ASSERT(m_hasPendingClear);
+ m_hasPendingClear = false;
}
bool StorageAreaMap::shouldApplyChangeForKey(const String& key) const
@@ -213,6 +226,10 @@
{
ASSERT(m_storageMap->hasOneRef());
+ // There's a clear pending, we don't want any changes until we've gotten the DidClear message.
+ if (m_hasPendingClear)
+ return;
+
// FIXME: Handle clear.
ASSERT(!key.isNull());
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h (149776 => 149777)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h 2013-05-08 23:15:11 UTC (rev 149776)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h 2013-05-08 23:31:38 UTC (rev 149777)
@@ -65,6 +65,7 @@
// CoreIPC::MessageReceiver
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
+ void didGetValues();
void didSetItem(const String& key, bool quotaError);
void didRemoveItem(const String& key);
void didClear();
@@ -88,6 +89,7 @@
RefPtr<WebCore::SecurityOrigin> m_securityOrigin;
RefPtr<WebCore::StorageMap> m_storageMap;
+ bool m_hasPendingClear;
HashCountedSet<String> m_pendingValueChanges;
};
Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in (149776 => 149777)
--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in 2013-05-08 23:15:11 UTC (rev 149776)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in 2013-05-08 23:31:38 UTC (rev 149777)
@@ -21,6 +21,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> StorageAreaMap {
+ DidGetValues()
DidSetItem(WTF::String key, bool quotaException)
DidRemoveItem(WTF::String key)
DidClear()