diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 6270e2a8be99a48df52e7d12b71c5240dae26be2..08e06b90e7dec047f055ca2ddcf2234d10524625 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2008-05-05 Brady Eidson + + Reviewed by Mitz Pettel RTL + + Preparation for upcoming work making LocalStorage persistent. + + StorageMaps normally have copy-on-write semantics to help support SessionStorage. + For LocalStorage, we never want this behavior. When we forcefully import items into + a StorageMap from the LocalStorage background thread, this new import method will be used. + + * storage/StorageMap.cpp: + (WebCore::StorageMap::importItem): Add a deep-copy of the item to the map without worrying + about copy-on-write. + * storage/StorageMap.h: + 2008-05-05 Kevin McCullough Reviewed by Tim. diff --git a/WebCore/storage/StorageMap.cpp b/WebCore/storage/StorageMap.cpp index b134d70e8cbfb7ff5e5ce19cf0b1d9777ffbd3fa..880fc93b1c3ccdbc34e7bdf49db3879c112a470a 100644 --- a/WebCore/storage/StorageMap.cpp +++ b/WebCore/storage/StorageMap.cpp @@ -145,4 +145,14 @@ bool StorageMap::contains(const String& key) const return m_map.contains(key); } +void StorageMap::importItem(const String& key, const String& value) const +{ + // Be sure to copy the keys/values as items imported on a background thread are destined + // to cross a thread boundary + pair::iterator, bool> result = m_map.add(key.copy(), String()); + + if (result.second) + result.first->second = value.copy(); +} + } diff --git a/WebCore/storage/StorageMap.h b/WebCore/storage/StorageMap.h index 5cf2834409ad03397cbe76d658fd8f1133172020..d5d00a9e1375eb01e7a79c115b6729f902e35e09 100644 --- a/WebCore/storage/StorageMap.h +++ b/WebCore/storage/StorageMap.h @@ -47,6 +47,8 @@ namespace WebCore { bool contains(const String& key) const; + void importItem(const String& key, const String& value) const; + private: StorageMap(); PassRefPtr copy();