OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 10 matching lines...) Expand all Loading... | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "StorageNamespaceImpl.h" | 27 #include "StorageNamespaceImpl.h" |
28 | 28 |
29 #if ENABLE(DOM_STORAGE) | 29 #if ENABLE(DOM_STORAGE) |
30 | 30 |
31 #include "StorageAreaImpl.h" | |
31 #include <wtf/StdLibExtras.h> | 32 #include <wtf/StdLibExtras.h> |
32 | 33 |
33 namespace WebCore { | 34 namespace WebCore { |
34 | 35 |
35 typedef HashMap<String, StorageNamespace*> LocalStorageNamespaceMap; | 36 typedef HashMap<String, StorageNamespace*> LocalStorageNamespaceMap; |
36 | 37 |
37 static LocalStorageNamespaceMap& localStorageNamespaceMap() | 38 static LocalStorageNamespaceMap& localStorageNamespaceMap() |
38 { | 39 { |
39 DEFINE_STATIC_LOCAL(LocalStorageNamespaceMap, localStorageNamespaceMap, ()); | 40 DEFINE_STATIC_LOCAL(LocalStorageNamespaceMap, localStorageNamespaceMap, ()); |
40 return localStorageNamespaceMap; | 41 return localStorageNamespaceMap; |
michaeln
2009/07/14 19:02:05
So... incognito vs regular local storage will be d
jorlow
2009/07/14 19:12:50
Yup.
| |
41 } | 42 } |
42 | 43 |
43 PassRefPtr<StorageNamespace> StorageNamespaceImpl::localStorageNamespace(const S tring& path) | 44 PassRefPtr<StorageNamespace> StorageNamespaceImpl::localStorageNamespace(const S tring& path) |
44 { | 45 { |
45 const String lookupPath = path.isNull() ? String("") : path; | 46 const String lookupPath = path.isNull() ? String("") : path; |
46 LocalStorageNamespaceMap::iterator it = localStorageNamespaceMap().find(look upPath); | 47 LocalStorageNamespaceMap::iterator it = localStorageNamespaceMap().find(look upPath); |
47 if (it == localStorageNamespaceMap().end()) { | 48 if (it == localStorageNamespaceMap().end()) { |
48 RefPtr<StorageNamespace> storageNamespace = adoptRef(new StorageNamespac eImpl(LocalStorage, lookupPath)); | 49 RefPtr<StorageNamespace> storageNamespace = adoptRef(new StorageNamespac eImpl(LocalStorage, lookupPath)); |
49 localStorageNamespaceMap().set(lookupPath, storageNamespace.get()); | 50 localStorageNamespaceMap().set(lookupPath, storageNamespace.get()); |
50 return storageNamespace.release(); | 51 return storageNamespace.release(); |
(...skipping 27 matching lines...) Expand all Loading... | |
78 ASSERT(localStorageNamespaceMap().get(m_path) == this); | 79 ASSERT(localStorageNamespaceMap().get(m_path) == this); |
79 localStorageNamespaceMap().remove(m_path); | 80 localStorageNamespaceMap().remove(m_path); |
80 } | 81 } |
81 } | 82 } |
82 | 83 |
83 PassRefPtr<StorageNamespace> StorageNamespaceImpl::copy() | 84 PassRefPtr<StorageNamespace> StorageNamespaceImpl::copy() |
84 { | 85 { |
85 ASSERT(isMainThread()); | 86 ASSERT(isMainThread()); |
86 ASSERT(!m_isShutdown); | 87 ASSERT(!m_isShutdown); |
87 | 88 |
88 StorageNamespaceImpl* newNamespace = new StorageNamespaceImpl(m_storageType, m_path); | 89 StorageNamespaceImpl* newNamespace = new StorageNamespaceImpl(m_storageType, m_path); |
michaeln
2009/07/14 19:02:05
I think this method is not valid to call on 'local
jorlow
2009/07/14 19:12:50
Makes sense.
| |
89 | 90 |
90 StorageAreaMap::iterator end = m_storageAreaMap.end(); | 91 StorageAreaMap::iterator end = m_storageAreaMap.end(); |
91 for (StorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i) { | 92 for (StorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i) { |
92 RefPtr<StorageArea> areaCopy = i->second->copy(i->first.get()); | 93 RefPtr<StorageArea> areaCopy = i->second->copy(i->first.get()); |
93 newNamespace->m_storageAreaMap.set(i->first, areaCopy.release()); | 94 newNamespace->m_storageAreaMap.set(i->first, areaCopy.release()); |
94 } | 95 } |
95 | 96 |
96 return adoptRef(newNamespace); | 97 return adoptRef(newNamespace); |
97 } | 98 } |
98 | 99 |
99 PassRefPtr<StorageArea> StorageNamespaceImpl::storageArea(SecurityOrigin* origin ) | 100 PassRefPtr<StorageArea> StorageNamespaceImpl::storageArea(SecurityOrigin* origin ) |
100 { | 101 { |
101 ASSERT(isMainThread()); | 102 ASSERT(isMainThread()); |
102 ASSERT(!m_isShutdown); | 103 ASSERT(!m_isShutdown); |
103 | 104 |
104 RefPtr<StorageArea> storageArea; | 105 RefPtr<StorageArea> storageArea; |
105 if (storageArea = m_storageAreaMap.get(origin)) | 106 if (storageArea = m_storageAreaMap.get(origin)) |
106 return storageArea.release(); | 107 return storageArea.release(); |
107 | 108 |
108 storageArea = StorageArea::create(m_storageType, origin, m_syncManager); | 109 storageArea = StorageAreaImpl::create(m_storageType, origin, m_syncManager); |
109 m_storageAreaMap.set(origin, storageArea); | 110 m_storageAreaMap.set(origin, storageArea); |
110 return storageArea.release(); | 111 return storageArea.release(); |
111 } | 112 } |
112 | 113 |
113 void StorageNamespaceImpl::close() | 114 void StorageNamespaceImpl::close() |
114 { | 115 { |
115 ASSERT(isMainThread()); | 116 ASSERT(isMainThread()); |
116 ASSERT(!m_isShutdown); | 117 ASSERT(!m_isShutdown); |
117 | 118 |
118 StorageAreaMap::iterator end = m_storageAreaMap.end(); | 119 StorageAreaMap::iterator end = m_storageAreaMap.end(); |
119 for (StorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it ) | 120 for (StorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it ) |
120 it->second->close(); | 121 it->second->close(); |
121 | 122 |
122 #ifndef NDEBUG | 123 #ifndef NDEBUG |
123 m_isShutdown = true; | 124 m_isShutdown = true; |
124 #endif | 125 #endif |
125 } | 126 } |
126 | 127 |
127 } // namespace WebCore | 128 } // namespace WebCore |
128 | 129 |
129 #endif // ENABLE(DOM_STORAGE) | 130 #endif // ENABLE(DOM_STORAGE) |
OLD | NEW |