- Revision
- 144103
- Author
- ander...@apple.com
- Date
- 2013-02-26 13:54:50 -0800 (Tue, 26 Feb 2013)
Log Message
StorageMap can just import an entire map of items at once
https://bugs.webkit.org/show_bug.cgi?id=110904
Reviewed by Beth Dakin.
Instead of iterating over the map inside StorageAreaSync, just pass it directly
(through StorageAreaImpl) to StorageMap and iterate over it there.
* storage/StorageAreaImpl.cpp:
(WebCore::StorageAreaImpl::importItems):
* storage/StorageAreaImpl.h:
(StorageAreaImpl):
* storage/StorageAreaSync.cpp:
(WebCore::StorageAreaSync::performImport):
* storage/StorageMap.cpp:
(WebCore::StorageMap::importItems):
* storage/StorageMap.h:
(StorageMap):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (144102 => 144103)
--- trunk/Source/WebCore/ChangeLog 2013-02-26 21:40:09 UTC (rev 144102)
+++ trunk/Source/WebCore/ChangeLog 2013-02-26 21:54:50 UTC (rev 144103)
@@ -1,3 +1,24 @@
+2013-02-26 Anders Carlsson <ander...@apple.com>
+
+ StorageMap can just import an entire map of items at once
+ https://bugs.webkit.org/show_bug.cgi?id=110904
+
+ Reviewed by Beth Dakin.
+
+ Instead of iterating over the map inside StorageAreaSync, just pass it directly
+ (through StorageAreaImpl) to StorageMap and iterate over it there.
+
+ * storage/StorageAreaImpl.cpp:
+ (WebCore::StorageAreaImpl::importItems):
+ * storage/StorageAreaImpl.h:
+ (StorageAreaImpl):
+ * storage/StorageAreaSync.cpp:
+ (WebCore::StorageAreaSync::performImport):
+ * storage/StorageMap.cpp:
+ (WebCore::StorageMap::importItems):
+ * storage/StorageMap.h:
+ (StorageMap):
+
2013-02-26 CHAUDHARY VINEET <rgf...@motorola.com>
[JSC] static methods with Callback should not have this pointer
Modified: trunk/Source/WebCore/storage/StorageAreaImpl.cpp (144102 => 144103)
--- trunk/Source/WebCore/storage/StorageAreaImpl.cpp 2013-02-26 21:40:09 UTC (rev 144102)
+++ trunk/Source/WebCore/storage/StorageAreaImpl.cpp 2013-02-26 21:54:50 UTC (rev 144103)
@@ -270,10 +270,11 @@
return m_storageMap->contains(key);
}
-void StorageAreaImpl::importItem(const String& key, const String& value)
+void StorageAreaImpl::importItems(const HashMap<String, String>& items)
{
ASSERT(!m_isShutdown);
- m_storageMap->importItem(key, value);
+
+ m_storageMap->importItems(items);
}
void StorageAreaImpl::close()
Modified: trunk/Source/WebCore/storage/StorageAreaImpl.h (144102 => 144103)
--- trunk/Source/WebCore/storage/StorageAreaImpl.h 2013-02-26 21:40:09 UTC (rev 144102)
+++ trunk/Source/WebCore/storage/StorageAreaImpl.h 2013-02-26 21:54:50 UTC (rev 144103)
@@ -29,6 +29,7 @@
#include "StorageArea.h"
#include "Timer.h"
+#include <wtf/HashMap.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
@@ -64,7 +65,7 @@
void close();
// Only called from a background thread.
- void importItem(const String& key, const String& value);
+ void importItems(const HashMap<String, String>& items);
// Used to clear a StorageArea and close db before backing db file is deleted.
void clearForOriginDeletion();
Modified: trunk/Source/WebCore/storage/StorageAreaSync.cpp (144102 => 144103)
--- trunk/Source/WebCore/storage/StorageAreaSync.cpp 2013-02-26 21:40:09 UTC (rev 144102)
+++ trunk/Source/WebCore/storage/StorageAreaSync.cpp 2013-02-26 21:54:50 UTC (rev 144103)
@@ -341,12 +341,8 @@
return;
}
- HashMap<String, String>::iterator it = itemMap.begin();
- HashMap<String, String>::iterator end = itemMap.end();
+ m_storageArea->importItems(itemMap);
- for (; it != end; ++it)
- m_storageArea->importItem(it->key, it->value);
-
markImported();
}
Modified: trunk/Source/WebCore/storage/StorageMap.cpp (144102 => 144103)
--- trunk/Source/WebCore/storage/StorageMap.cpp 2013-02-26 21:40:09 UTC (rev 144102)
+++ trunk/Source/WebCore/storage/StorageMap.cpp 2013-02-26 21:54:50 UTC (rev 144103)
@@ -167,17 +167,20 @@
return m_map.contains(key);
}
-void StorageMap::importItem(const String& key, const String& value)
+void StorageMap::importItems(const HashMap<String, String>& items)
{
- // Be sure to copy the keys/values as items imported on a background thread are destined
- // to cross a thread boundary
- HashMap<String, String>::AddResult result = m_map.add(key.isolatedCopy(), value.isolatedCopy());
- ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.
+ for (HashMap<String, String>::const_iterator it = items.begin(), end = items.end(); it != end; ++it) {
+ const String& key = it->key;
+ const String& value = it->value;
- ASSERT(m_currentLength + key.length() >= m_currentLength);
- m_currentLength += key.length();
- ASSERT(m_currentLength + value.length() >= m_currentLength);
- m_currentLength += value.length();
+ HashMap<String, String>::AddResult result = m_map.add(key, value);
+ ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.
+
+ ASSERT(m_currentLength + key.length() >= m_currentLength);
+ m_currentLength += key.length();
+ ASSERT(m_currentLength + value.length() >= m_currentLength);
+ m_currentLength += value.length();
+ }
}
}
Modified: trunk/Source/WebCore/storage/StorageMap.h (144102 => 144103)
--- trunk/Source/WebCore/storage/StorageMap.h 2013-02-26 21:40:09 UTC (rev 144102)
+++ trunk/Source/WebCore/storage/StorageMap.h 2013-02-26 21:54:50 UTC (rev 144103)
@@ -47,7 +47,7 @@
bool contains(const String& key) const;
- void importItem(const String& key, const String& value);
+ void importItems(const HashMap<String, String>&);
unsigned quota() const { return m_quotaSize; }