Title: [149618] trunk/Source/WebKit2
- Revision
- 149618
- Author
- [email protected]
- Date
- 2013-05-06 11:38:44 -0700 (Mon, 06 May 2013)
Log Message
Handle removeItem and clear in LocalStorageDatabase
https://bugs.webkit.org/show_bug.cgi?id=115664
Reviewed by Darin Adler.
* UIProcess/Storage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::removeItem):
Call itemDidChange with a null value, indicating that we want to remove this item.
(WebKit::LocalStorageDatabase::clear):
Clear items, set m_shouldClearItems and schedule a database update.
(WebKit::LocalStorageDatabase::updateDatabase):
If m_shouldClearItems is true, clear all items.
* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::StorageArea::removeItem):
Call through to the local storage database.
(WebKit::StorageManager::StorageArea::clear):
Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (149617 => 149618)
--- trunk/Source/WebKit2/ChangeLog 2013-05-06 18:13:35 UTC (rev 149617)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-06 18:38:44 UTC (rev 149618)
@@ -1,5 +1,29 @@
2013-05-06 Anders Carlsson <[email protected]>
+ Handle removeItem and clear in LocalStorageDatabase
+ https://bugs.webkit.org/show_bug.cgi?id=115664
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/Storage/LocalStorageDatabase.cpp:
+ (WebKit::LocalStorageDatabase::removeItem):
+ Call itemDidChange with a null value, indicating that we want to remove this item.
+
+ (WebKit::LocalStorageDatabase::clear):
+ Clear items, set m_shouldClearItems and schedule a database update.
+
+ (WebKit::LocalStorageDatabase::updateDatabase):
+ If m_shouldClearItems is true, clear all items.
+
+ * UIProcess/Storage/StorageManager.cpp:
+ (WebKit::StorageManager::StorageArea::removeItem):
+ Call through to the local storage database.
+
+ (WebKit::StorageManager::StorageArea::clear):
+ Ditto.
+
+2013-05-06 Anders Carlsson <[email protected]>
+
Write storage changes to disk
https://bugs.webkit.org/show_bug.cgi?id=115660
Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp (149617 => 149618)
--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2013-05-06 18:13:35 UTC (rev 149617)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2013-05-06 18:38:44 UTC (rev 149618)
@@ -54,6 +54,7 @@
, m_failedToOpenDatabase(false)
, m_didImportItems(false)
, m_didScheduleDatabaseUpdate(false)
+ , m_shouldClearItems(false)
{
}
@@ -189,6 +190,19 @@
itemDidChange(key, value);
}
+void LocalStorageDatabase::removeItem(const String& key)
+{
+ itemDidChange(key, String());
+}
+
+void LocalStorageDatabase::clear()
+{
+ m_changedItems.clear();
+ m_shouldClearItems = true;
+
+ scheduleDatabaseUpdate();
+}
+
void LocalStorageDatabase::itemDidChange(const String& key, const String& value)
{
m_changedItems.set(key, value);
@@ -210,8 +224,22 @@
m_didScheduleDatabaseUpdate = false;
- // FIXME: Handle clearing.
+ if (m_shouldClearItems) {
+ m_shouldClearItems = false;
+ SQLiteStatement clearStatement(m_database, "DELETE FROM ItemTable");
+ if (clearStatement.prepare() != SQLResultOk) {
+ LOG_ERROR("Failed to prepare clear statement - cannot write to local storage database");
+ return;
+ }
+
+ int result = clearStatement.step();
+ if (result != SQLResultDone) {
+ LOG_ERROR("Failed to clear all items in the local storage database - %i", result);
+ return;
+ }
+ }
+
HashMap<String, String> changedItems;
if (m_changedItems.size() > maximumItemsToUpdate) {
for (int i = 0; i < maximumItemsToUpdate; ++i) {
Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h (149617 => 149618)
--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h 2013-05-06 18:13:35 UTC (rev 149617)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h 2013-05-06 18:38:44 UTC (rev 149618)
@@ -49,6 +49,8 @@
void importItems(WebCore::StorageMap&);
void setItem(const String& key, const String& value);
+ void removeItem(const String& key);
+ void clear();
private:
LocalStorageDatabase(const String& databaseFilename, PassRefPtr<WorkQueue>);
@@ -75,6 +77,7 @@
bool m_didImportItems;
bool m_didScheduleDatabaseUpdate;
+ bool m_shouldClearItems;
HashMap<String, String> m_changedItems;
};
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (149617 => 149618)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-05-06 18:13:35 UTC (rev 149617)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-05-06 18:38:44 UTC (rev 149618)
@@ -174,6 +174,9 @@
if (oldValue.isNull())
return;
+ if (m_localStorageDatabase)
+ m_localStorageDatabase->removeItem(key);
+
dispatchEvents(sourceConnection, sourceStorageAreaID, key, oldValue, String(), urlString);
}
@@ -186,6 +189,9 @@
m_storageMap = StorageMap::create(m_quotaInBytes);
+ if (m_localStorageDatabase)
+ m_localStorageDatabase->clear();
+
dispatchEvents(sourceConnection, sourceStorageAreaID, String(), String(), String(), urlString);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes