From 2cfbe4c4ee8d3cf290fb44c490c92b670475cba7 Mon Sep 17 00:00:00 2001 From: "beidson@apple.com" Date: Tue, 6 May 2008 03:14:22 +0000 Subject: [PATCH] 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: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32897 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 15 +++++++++++++++ WebCore/storage/StorageMap.cpp | 10 ++++++++++ WebCore/storage/StorageMap.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 6270e2a8be9..08e06b90e7d 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 b134d70e8cb..880fc93b1c3 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 5cf2834409a..d5d00a9e137 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(); -- GitLab