OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/threading/sequenced_worker_pool.h" | 11 #include "base/threading/sequenced_worker_pool.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "content/browser/dom_storage/dom_storage_area.h" |
| 14 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 15 #include "content/browser/dom_storage/dom_storage_namespace.h" |
| 16 #include "content/browser/dom_storage/dom_storage_task_runner.h" |
| 17 #include "content/public/browser/local_storage_usage_info.h" |
| 18 #include "content/public/browser/session_storage_usage_info.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "webkit/browser/dom_storage/dom_storage_area.h" | |
15 #include "webkit/browser/dom_storage/dom_storage_context.h" | |
16 #include "webkit/browser/dom_storage/dom_storage_namespace.h" | |
17 #include "webkit/browser/dom_storage/dom_storage_task_runner.h" | |
18 #include "webkit/browser/quota/mock_special_storage_policy.h" | 20 #include "webkit/browser/quota/mock_special_storage_policy.h" |
19 #include "webkit/common/dom_storage/dom_storage_types.h" | |
20 | 21 |
21 namespace dom_storage { | 22 namespace content { |
22 | 23 |
23 class DomStorageContextTest : public testing::Test { | 24 class DOMStorageContextImplTest : public testing::Test { |
24 public: | 25 public: |
25 DomStorageContextTest() | 26 DOMStorageContextImplTest() |
26 : kOrigin(GURL("http://dom_storage/")), | 27 : kOrigin(GURL("http://dom_storage/")), |
27 kKey(ASCIIToUTF16("key")), | 28 kKey(ASCIIToUTF16("key")), |
28 kValue(ASCIIToUTF16("value")), | 29 kValue(ASCIIToUTF16("value")), |
29 kDontIncludeFileInfo(false), | 30 kDontIncludeFileInfo(false), |
30 kDoIncludeFileInfo(true) { | 31 kDoIncludeFileInfo(true) { |
31 } | 32 } |
32 | 33 |
33 const GURL kOrigin; | 34 const GURL kOrigin; |
34 const base::string16 kKey; | 35 const base::string16 kKey; |
35 const base::string16 kValue; | 36 const base::string16 kValue; |
36 const bool kDontIncludeFileInfo; | 37 const bool kDontIncludeFileInfo; |
37 const bool kDoIncludeFileInfo; | 38 const bool kDoIncludeFileInfo; |
38 | 39 |
39 virtual void SetUp() { | 40 virtual void SetUp() { |
40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 41 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
41 storage_policy_ = new quota::MockSpecialStoragePolicy; | 42 storage_policy_ = new quota::MockSpecialStoragePolicy; |
42 task_runner_ = | 43 task_runner_ = |
43 new MockDomStorageTaskRunner(base::MessageLoopProxy::current().get()); | 44 new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()); |
44 context_ = new DomStorageContext(temp_dir_.path(), | 45 context_ = new DOMStorageContextImpl(temp_dir_.path(), |
45 base::FilePath(), | 46 base::FilePath(), |
46 storage_policy_.get(), | 47 storage_policy_.get(), |
47 task_runner_.get()); | 48 task_runner_.get()); |
48 } | 49 } |
49 | 50 |
50 virtual void TearDown() { | 51 virtual void TearDown() { |
51 base::MessageLoop::current()->RunUntilIdle(); | 52 base::MessageLoop::current()->RunUntilIdle(); |
52 } | 53 } |
53 | 54 |
54 void VerifySingleOriginRemains(const GURL& origin) { | 55 void VerifySingleOriginRemains(const GURL& origin) { |
55 // Use a new instance to examine the contexts of temp_dir_. | 56 // Use a new instance to examine the contexts of temp_dir_. |
56 scoped_refptr<DomStorageContext> context = | 57 scoped_refptr<DOMStorageContextImpl> context = |
57 new DomStorageContext(temp_dir_.path(), base::FilePath(), NULL, NULL); | 58 new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(), |
| 59 NULL, NULL); |
58 std::vector<LocalStorageUsageInfo> infos; | 60 std::vector<LocalStorageUsageInfo> infos; |
59 context->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); | 61 context->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); |
60 ASSERT_EQ(1u, infos.size()); | 62 ASSERT_EQ(1u, infos.size()); |
61 EXPECT_EQ(origin, infos[0].origin); | 63 EXPECT_EQ(origin, infos[0].origin); |
62 } | 64 } |
63 | 65 |
64 protected: | 66 protected: |
65 base::MessageLoop message_loop_; | 67 base::MessageLoop message_loop_; |
66 base::ScopedTempDir temp_dir_; | 68 base::ScopedTempDir temp_dir_; |
67 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_; | 69 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_; |
68 scoped_refptr<MockDomStorageTaskRunner> task_runner_; | 70 scoped_refptr<MockDOMStorageTaskRunner> task_runner_; |
69 scoped_refptr<DomStorageContext> context_; | 71 scoped_refptr<DOMStorageContextImpl> context_; |
70 DISALLOW_COPY_AND_ASSIGN(DomStorageContextTest); | 72 DISALLOW_COPY_AND_ASSIGN(DOMStorageContextImplTest); |
71 }; | 73 }; |
72 | 74 |
73 TEST_F(DomStorageContextTest, Basics) { | 75 TEST_F(DOMStorageContextImplTest, Basics) { |
74 // This test doesn't do much, checks that the constructor | 76 // This test doesn't do much, checks that the constructor |
75 // initializes members properly and that invoking methods | 77 // initializes members properly and that invoking methods |
76 // on a newly created object w/o any data on disk do no harm. | 78 // on a newly created object w/o any data on disk do no harm. |
77 EXPECT_EQ(temp_dir_.path(), context_->localstorage_directory()); | 79 EXPECT_EQ(temp_dir_.path(), context_->localstorage_directory()); |
78 EXPECT_EQ(base::FilePath(), context_->sessionstorage_directory()); | 80 EXPECT_EQ(base::FilePath(), context_->sessionstorage_directory()); |
79 EXPECT_EQ(storage_policy_.get(), context_->special_storage_policy_.get()); | 81 EXPECT_EQ(storage_policy_.get(), context_->special_storage_policy_.get()); |
80 context_->PurgeMemory(); | 82 context_->PurgeMemory(); |
81 context_->DeleteLocalStorage(GURL("http://chromium.org/")); | 83 context_->DeleteLocalStorage(GURL("http://chromium.org/")); |
82 const int kFirstSessionStorageNamespaceId = 1; | 84 const int kFirstSessionStorageNamespaceId = 1; |
83 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)); | 85 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)); |
84 EXPECT_FALSE(context_->GetStorageNamespace(kFirstSessionStorageNamespaceId)); | 86 EXPECT_FALSE(context_->GetStorageNamespace(kFirstSessionStorageNamespaceId)); |
85 EXPECT_EQ(kFirstSessionStorageNamespaceId, context_->AllocateSessionId()); | 87 EXPECT_EQ(kFirstSessionStorageNamespaceId, context_->AllocateSessionId()); |
86 std::vector<LocalStorageUsageInfo> infos; | 88 std::vector<LocalStorageUsageInfo> infos; |
87 context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); | 89 context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); |
88 EXPECT_TRUE(infos.empty()); | 90 EXPECT_TRUE(infos.empty()); |
89 context_->Shutdown(); | 91 context_->Shutdown(); |
90 } | 92 } |
91 | 93 |
92 TEST_F(DomStorageContextTest, UsageInfo) { | 94 TEST_F(DOMStorageContextImplTest, UsageInfo) { |
93 // Should be empty initially | 95 // Should be empty initially |
94 std::vector<LocalStorageUsageInfo> infos; | 96 std::vector<LocalStorageUsageInfo> infos; |
95 context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); | 97 context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); |
96 EXPECT_TRUE(infos.empty()); | 98 EXPECT_TRUE(infos.empty()); |
97 context_->GetLocalStorageUsage(&infos, kDoIncludeFileInfo); | 99 context_->GetLocalStorageUsage(&infos, kDoIncludeFileInfo); |
98 EXPECT_TRUE(infos.empty()); | 100 EXPECT_TRUE(infos.empty()); |
99 | 101 |
100 // Put some data into local storage and shutdown the context | 102 // Put some data into local storage and shutdown the context |
101 // to ensure data is written to disk. | 103 // to ensure data is written to disk. |
102 base::NullableString16 old_value; | 104 base::NullableString16 old_value; |
103 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 105 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
104 OpenStorageArea(kOrigin)->SetItem(kKey, kValue, &old_value)); | 106 OpenStorageArea(kOrigin)->SetItem(kKey, kValue, &old_value)); |
105 context_->Shutdown(); | 107 context_->Shutdown(); |
106 context_ = NULL; | 108 context_ = NULL; |
107 base::MessageLoop::current()->RunUntilIdle(); | 109 base::MessageLoop::current()->RunUntilIdle(); |
108 | 110 |
109 // Create a new context that points to the same directory, see that | 111 // Create a new context that points to the same directory, see that |
110 // it knows about the origin that we stored data for. | 112 // it knows about the origin that we stored data for. |
111 context_ = new DomStorageContext(temp_dir_.path(), base::FilePath(), NULL, NUL
L); | 113 context_ = new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(), |
| 114 NULL, NULL); |
112 context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); | 115 context_->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); |
113 EXPECT_EQ(1u, infos.size()); | 116 EXPECT_EQ(1u, infos.size()); |
114 EXPECT_EQ(kOrigin, infos[0].origin); | 117 EXPECT_EQ(kOrigin, infos[0].origin); |
115 EXPECT_EQ(0u, infos[0].data_size); | 118 EXPECT_EQ(0u, infos[0].data_size); |
116 EXPECT_EQ(base::Time(), infos[0].last_modified); | 119 EXPECT_EQ(base::Time(), infos[0].last_modified); |
117 infos.clear(); | 120 infos.clear(); |
118 context_->GetLocalStorageUsage(&infos, kDoIncludeFileInfo); | 121 context_->GetLocalStorageUsage(&infos, kDoIncludeFileInfo); |
119 EXPECT_EQ(1u, infos.size()); | 122 EXPECT_EQ(1u, infos.size()); |
120 EXPECT_EQ(kOrigin, infos[0].origin); | 123 EXPECT_EQ(kOrigin, infos[0].origin); |
121 EXPECT_NE(0u, infos[0].data_size); | 124 EXPECT_NE(0u, infos[0].data_size); |
122 EXPECT_NE(base::Time(), infos[0].last_modified); | 125 EXPECT_NE(base::Time(), infos[0].last_modified); |
123 } | 126 } |
124 | 127 |
125 TEST_F(DomStorageContextTest, SessionOnly) { | 128 TEST_F(DOMStorageContextImplTest, SessionOnly) { |
126 const GURL kSessionOnlyOrigin("http://www.sessiononly.com/"); | 129 const GURL kSessionOnlyOrigin("http://www.sessiononly.com/"); |
127 storage_policy_->AddSessionOnly(kSessionOnlyOrigin); | 130 storage_policy_->AddSessionOnly(kSessionOnlyOrigin); |
128 | 131 |
129 // Store data for a normal and a session-only origin and then | 132 // Store data for a normal and a session-only origin and then |
130 // invoke Shutdown() which should delete data for session-only | 133 // invoke Shutdown() which should delete data for session-only |
131 // origins. | 134 // origins. |
132 base::NullableString16 old_value; | 135 base::NullableString16 old_value; |
133 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 136 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
134 OpenStorageArea(kOrigin)->SetItem(kKey, kValue, &old_value)); | 137 OpenStorageArea(kOrigin)->SetItem(kKey, kValue, &old_value)); |
135 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 138 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
136 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); | 139 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); |
137 context_->Shutdown(); | 140 context_->Shutdown(); |
138 context_ = NULL; | 141 context_ = NULL; |
139 base::MessageLoop::current()->RunUntilIdle(); | 142 base::MessageLoop::current()->RunUntilIdle(); |
140 | 143 |
141 // Verify that the session-only origin data is gone. | 144 // Verify that the session-only origin data is gone. |
142 VerifySingleOriginRemains(kOrigin); | 145 VerifySingleOriginRemains(kOrigin); |
143 } | 146 } |
144 | 147 |
145 TEST_F(DomStorageContextTest, SetForceKeepSessionState) { | 148 TEST_F(DOMStorageContextImplTest, SetForceKeepSessionState) { |
146 const GURL kSessionOnlyOrigin("http://www.sessiononly.com/"); | 149 const GURL kSessionOnlyOrigin("http://www.sessiononly.com/"); |
147 storage_policy_->AddSessionOnly(kSessionOnlyOrigin); | 150 storage_policy_->AddSessionOnly(kSessionOnlyOrigin); |
148 | 151 |
149 // Store data for a session-only origin, setup to save session data, then | 152 // Store data for a session-only origin, setup to save session data, then |
150 // shutdown. | 153 // shutdown. |
151 base::NullableString16 old_value; | 154 base::NullableString16 old_value; |
152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 155 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
153 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); | 156 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); |
154 context_->SetForceKeepSessionState(); // Should override clear behavior. | 157 context_->SetForceKeepSessionState(); // Should override clear behavior. |
155 context_->Shutdown(); | 158 context_->Shutdown(); |
156 context_ = NULL; | 159 context_ = NULL; |
157 base::MessageLoop::current()->RunUntilIdle(); | 160 base::MessageLoop::current()->RunUntilIdle(); |
158 | 161 |
159 VerifySingleOriginRemains(kSessionOnlyOrigin); | 162 VerifySingleOriginRemains(kSessionOnlyOrigin); |
160 } | 163 } |
161 | 164 |
162 TEST_F(DomStorageContextTest, PersistentIds) { | 165 TEST_F(DOMStorageContextImplTest, PersistentIds) { |
163 const int kFirstSessionStorageNamespaceId = 1; | 166 const int kFirstSessionStorageNamespaceId = 1; |
164 const std::string kPersistentId = "persistent"; | 167 const std::string kPersistentId = "persistent"; |
165 context_->CreateSessionNamespace(kFirstSessionStorageNamespaceId, | 168 context_->CreateSessionNamespace(kFirstSessionStorageNamespaceId, |
166 kPersistentId); | 169 kPersistentId); |
167 DomStorageNamespace* dom_namespace = | 170 DOMStorageNamespace* dom_namespace = |
168 context_->GetStorageNamespace(kFirstSessionStorageNamespaceId); | 171 context_->GetStorageNamespace(kFirstSessionStorageNamespaceId); |
169 ASSERT_TRUE(dom_namespace); | 172 ASSERT_TRUE(dom_namespace); |
170 EXPECT_EQ(kPersistentId, dom_namespace->persistent_namespace_id()); | 173 EXPECT_EQ(kPersistentId, dom_namespace->persistent_namespace_id()); |
171 // Verify that the areas inherit the persistent ID. | 174 // Verify that the areas inherit the persistent ID. |
172 DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin); | 175 DOMStorageArea* area = dom_namespace->OpenStorageArea(kOrigin); |
173 EXPECT_EQ(kPersistentId, area->persistent_namespace_id_); | 176 EXPECT_EQ(kPersistentId, area->persistent_namespace_id_); |
174 | 177 |
175 // Verify that the persistent IDs are handled correctly when cloning. | 178 // Verify that the persistent IDs are handled correctly when cloning. |
176 const int kClonedSessionStorageNamespaceId = 2; | 179 const int kClonedSessionStorageNamespaceId = 2; |
177 const std::string kClonedPersistentId = "cloned"; | 180 const std::string kClonedPersistentId = "cloned"; |
178 context_->CloneSessionNamespace(kFirstSessionStorageNamespaceId, | 181 context_->CloneSessionNamespace(kFirstSessionStorageNamespaceId, |
179 kClonedSessionStorageNamespaceId, | 182 kClonedSessionStorageNamespaceId, |
180 kClonedPersistentId); | 183 kClonedPersistentId); |
181 DomStorageNamespace* cloned_dom_namespace = | 184 DOMStorageNamespace* cloned_dom_namespace = |
182 context_->GetStorageNamespace(kClonedSessionStorageNamespaceId); | 185 context_->GetStorageNamespace(kClonedSessionStorageNamespaceId); |
183 ASSERT_TRUE(dom_namespace); | 186 ASSERT_TRUE(dom_namespace); |
184 EXPECT_EQ(kClonedPersistentId, | 187 EXPECT_EQ(kClonedPersistentId, |
185 cloned_dom_namespace->persistent_namespace_id()); | 188 cloned_dom_namespace->persistent_namespace_id()); |
186 // Verify that the areas inherit the persistent ID. | 189 // Verify that the areas inherit the persistent ID. |
187 DomStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin); | 190 DOMStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin); |
188 EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_); | 191 EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_); |
189 } | 192 } |
190 | 193 |
191 TEST_F(DomStorageContextTest, DeleteSessionStorage) { | 194 TEST_F(DOMStorageContextImplTest, DeleteSessionStorage) { |
192 // Create a DomStorageContext which will save sessionStorage on disk. | 195 // Create a DOMStorageContextImpl which will save sessionStorage on disk. |
193 context_ = new DomStorageContext(temp_dir_.path(), | 196 context_ = new DOMStorageContextImpl(temp_dir_.path(), |
194 temp_dir_.path(), | 197 temp_dir_.path(), |
195 storage_policy_.get(), | 198 storage_policy_.get(), |
196 task_runner_.get()); | 199 task_runner_.get()); |
197 context_->SetSaveSessionStorageOnDisk(); | 200 context_->SetSaveSessionStorageOnDisk(); |
198 ASSERT_EQ(temp_dir_.path(), context_->sessionstorage_directory()); | 201 ASSERT_EQ(temp_dir_.path(), context_->sessionstorage_directory()); |
199 | 202 |
200 // Write data. | 203 // Write data. |
201 const int kSessionStorageNamespaceId = 1; | 204 const int kSessionStorageNamespaceId = 1; |
202 const std::string kPersistentId = "persistent"; | 205 const std::string kPersistentId = "persistent"; |
203 context_->CreateSessionNamespace(kSessionStorageNamespaceId, | 206 context_->CreateSessionNamespace(kSessionStorageNamespaceId, |
204 kPersistentId); | 207 kPersistentId); |
205 DomStorageNamespace* dom_namespace = | 208 DOMStorageNamespace* dom_namespace = |
206 context_->GetStorageNamespace(kSessionStorageNamespaceId); | 209 context_->GetStorageNamespace(kSessionStorageNamespaceId); |
207 DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin); | 210 DOMStorageArea* area = dom_namespace->OpenStorageArea(kOrigin); |
208 const base::string16 kKey(ASCIIToUTF16("foo")); | 211 const base::string16 kKey(ASCIIToUTF16("foo")); |
209 const base::string16 kValue(ASCIIToUTF16("bar")); | 212 const base::string16 kValue(ASCIIToUTF16("bar")); |
210 base::NullableString16 old_nullable_value; | 213 base::NullableString16 old_nullable_value; |
211 area->SetItem(kKey, kValue, &old_nullable_value); | 214 area->SetItem(kKey, kValue, &old_nullable_value); |
212 dom_namespace->CloseStorageArea(area); | 215 dom_namespace->CloseStorageArea(area); |
213 | 216 |
214 // Destroy and recreate the DomStorageContext. | 217 // Destroy and recreate the DOMStorageContextImpl. |
215 context_->Shutdown(); | 218 context_->Shutdown(); |
216 context_ = NULL; | 219 context_ = NULL; |
217 base::MessageLoop::current()->RunUntilIdle(); | 220 base::MessageLoop::current()->RunUntilIdle(); |
218 context_ = new DomStorageContext( | 221 context_ = new DOMStorageContextImpl( |
219 temp_dir_.path(), temp_dir_.path(), | 222 temp_dir_.path(), temp_dir_.path(), |
220 storage_policy_.get(), task_runner_.get()); | 223 storage_policy_.get(), task_runner_.get()); |
221 context_->SetSaveSessionStorageOnDisk(); | 224 context_->SetSaveSessionStorageOnDisk(); |
222 | 225 |
223 // Read the data back. | 226 // Read the data back. |
224 context_->CreateSessionNamespace(kSessionStorageNamespaceId, | 227 context_->CreateSessionNamespace(kSessionStorageNamespaceId, |
225 kPersistentId); | 228 kPersistentId); |
226 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId); | 229 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId); |
227 area = dom_namespace->OpenStorageArea(kOrigin); | 230 area = dom_namespace->OpenStorageArea(kOrigin); |
228 base::NullableString16 read_value; | 231 base::NullableString16 read_value; |
229 read_value = area->GetItem(kKey); | 232 read_value = area->GetItem(kKey); |
230 EXPECT_EQ(kValue, read_value.string()); | 233 EXPECT_EQ(kValue, read_value.string()); |
231 dom_namespace->CloseStorageArea(area); | 234 dom_namespace->CloseStorageArea(area); |
232 | 235 |
233 SessionStorageUsageInfo info; | 236 SessionStorageUsageInfo info; |
234 info.origin = kOrigin; | 237 info.origin = kOrigin; |
235 info.persistent_namespace_id = kPersistentId; | 238 info.persistent_namespace_id = kPersistentId; |
236 context_->DeleteSessionStorage(info); | 239 context_->DeleteSessionStorage(info); |
237 | 240 |
238 // Destroy and recreate again. | 241 // Destroy and recreate again. |
239 context_->Shutdown(); | 242 context_->Shutdown(); |
240 context_ = NULL; | 243 context_ = NULL; |
241 base::MessageLoop::current()->RunUntilIdle(); | 244 base::MessageLoop::current()->RunUntilIdle(); |
242 context_ = new DomStorageContext( | 245 context_ = new DOMStorageContextImpl( |
243 temp_dir_.path(), temp_dir_.path(), | 246 temp_dir_.path(), temp_dir_.path(), |
244 storage_policy_.get(), task_runner_.get()); | 247 storage_policy_.get(), task_runner_.get()); |
245 context_->SetSaveSessionStorageOnDisk(); | 248 context_->SetSaveSessionStorageOnDisk(); |
246 | 249 |
247 // Now there should be no data. | 250 // Now there should be no data. |
248 context_->CreateSessionNamespace(kSessionStorageNamespaceId, | 251 context_->CreateSessionNamespace(kSessionStorageNamespaceId, |
249 kPersistentId); | 252 kPersistentId); |
250 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId); | 253 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId); |
251 area = dom_namespace->OpenStorageArea(kOrigin); | 254 area = dom_namespace->OpenStorageArea(kOrigin); |
252 read_value = area->GetItem(kKey); | 255 read_value = area->GetItem(kKey); |
253 EXPECT_TRUE(read_value.is_null()); | 256 EXPECT_TRUE(read_value.is_null()); |
254 dom_namespace->CloseStorageArea(area); | 257 dom_namespace->CloseStorageArea(area); |
255 context_->Shutdown(); | 258 context_->Shutdown(); |
256 context_ = NULL; | 259 context_ = NULL; |
257 base::MessageLoop::current()->RunUntilIdle(); | 260 base::MessageLoop::current()->RunUntilIdle(); |
258 } | 261 } |
259 | 262 |
260 } // namespace dom_storage | 263 } // namespace content |
OLD | NEW |