Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: webkit/dom_storage/dom_storage_context_unittest.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 22 matching lines...) Expand all
33 const GURL kOrigin; 33 const GURL kOrigin;
34 const string16 kKey; 34 const string16 kKey;
35 const string16 kValue; 35 const string16 kValue;
36 const bool kDontIncludeFileInfo; 36 const bool kDontIncludeFileInfo;
37 const bool kDoIncludeFileInfo; 37 const bool kDoIncludeFileInfo;
38 38
39 virtual void SetUp() { 39 virtual void SetUp() {
40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
41 storage_policy_ = new quota::MockSpecialStoragePolicy; 41 storage_policy_ = new quota::MockSpecialStoragePolicy;
42 task_runner_ = new MockDomStorageTaskRunner( 42 task_runner_ = new MockDomStorageTaskRunner(
43 base::MessageLoopProxy::current()); 43 base::MessageLoopProxy::current().get());
44 context_ = new DomStorageContext(temp_dir_.path(), 44 context_ = new DomStorageContext(temp_dir_.path(),
45 FilePath(), 45 FilePath(),
46 storage_policy_, 46 storage_policy_.get(),
47 task_runner_); 47 task_runner_.get());
48 } 48 }
49 49
50 virtual void TearDown() { 50 virtual void TearDown() {
51 MessageLoop::current()->RunAllPending(); 51 MessageLoop::current()->RunAllPending();
52 } 52 }
53 53
54 void VerifySingleOriginRemains(const GURL& origin) { 54 void VerifySingleOriginRemains(const GURL& origin) {
55 // Use a new instance to examine the contexts of temp_dir_. 55 // Use a new instance to examine the contexts of temp_dir_.
56 scoped_refptr<DomStorageContext> context = 56 scoped_refptr<DomStorageContext> context =
57 new DomStorageContext(temp_dir_.path(), FilePath(), NULL, NULL); 57 new DomStorageContext(temp_dir_.path(), FilePath(), NULL, NULL);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 cloned_dom_namespace->persistent_namespace_id()); 185 cloned_dom_namespace->persistent_namespace_id());
186 // Verify that the areas inherit the persistent ID. 186 // Verify that the areas inherit the persistent ID.
187 DomStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin); 187 DomStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin);
188 EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_); 188 EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_);
189 } 189 }
190 190
191 TEST_F(DomStorageContextTest, DeleteSessionStorage) { 191 TEST_F(DomStorageContextTest, DeleteSessionStorage) {
192 // Create a DomStorageContext which will save sessionStorage on disk. 192 // Create a DomStorageContext which will save sessionStorage on disk.
193 context_ = new DomStorageContext(temp_dir_.path(), 193 context_ = new DomStorageContext(temp_dir_.path(),
194 temp_dir_.path(), 194 temp_dir_.path(),
195 storage_policy_, 195 storage_policy_.get(),
196 task_runner_); 196 task_runner_.get());
197 context_->SetSaveSessionStorageOnDisk(); 197 context_->SetSaveSessionStorageOnDisk();
198 ASSERT_EQ(temp_dir_.path(), context_->sessionstorage_directory()); 198 ASSERT_EQ(temp_dir_.path(), context_->sessionstorage_directory());
199 199
200 // Write data. 200 // Write data.
201 const int kSessionStorageNamespaceId = 1; 201 const int kSessionStorageNamespaceId = 1;
202 const std::string kPersistentId = "persistent"; 202 const std::string kPersistentId = "persistent";
203 context_->CreateSessionNamespace(kSessionStorageNamespaceId, 203 context_->CreateSessionNamespace(kSessionStorageNamespaceId,
204 kPersistentId); 204 kPersistentId);
205 DomStorageNamespace* dom_namespace = 205 DomStorageNamespace* dom_namespace =
206 context_->GetStorageNamespace(kSessionStorageNamespaceId); 206 context_->GetStorageNamespace(kSessionStorageNamespaceId);
207 DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin); 207 DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin);
208 const string16 kKey(ASCIIToUTF16("foo")); 208 const string16 kKey(ASCIIToUTF16("foo"));
209 const string16 kValue(ASCIIToUTF16("bar")); 209 const string16 kValue(ASCIIToUTF16("bar"));
210 NullableString16 old_nullable_value; 210 NullableString16 old_nullable_value;
211 area->SetItem(kKey, kValue, &old_nullable_value); 211 area->SetItem(kKey, kValue, &old_nullable_value);
212 dom_namespace->CloseStorageArea(area); 212 dom_namespace->CloseStorageArea(area);
213 213
214 // Destroy and recreate the DomStorageContext. 214 // Destroy and recreate the DomStorageContext.
215 context_->Shutdown(); 215 context_->Shutdown();
216 context_ = NULL; 216 context_ = NULL;
217 MessageLoop::current()->RunAllPending(); 217 MessageLoop::current()->RunAllPending();
218 context_ = new DomStorageContext(temp_dir_.path(), 218 context_ = new DomStorageContext(temp_dir_.path(),
219 temp_dir_.path(), 219 temp_dir_.path(),
220 storage_policy_, 220 storage_policy_.get(),
221 task_runner_); 221 task_runner_.get());
222 context_->SetSaveSessionStorageOnDisk(); 222 context_->SetSaveSessionStorageOnDisk();
223 223
224 // Read the data back. 224 // Read the data back.
225 context_->CreateSessionNamespace(kSessionStorageNamespaceId, 225 context_->CreateSessionNamespace(kSessionStorageNamespaceId,
226 kPersistentId); 226 kPersistentId);
227 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId); 227 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId);
228 area = dom_namespace->OpenStorageArea(kOrigin); 228 area = dom_namespace->OpenStorageArea(kOrigin);
229 NullableString16 read_value; 229 NullableString16 read_value;
230 read_value = area->GetItem(kKey); 230 read_value = area->GetItem(kKey);
231 EXPECT_EQ(kValue, read_value.string()); 231 EXPECT_EQ(kValue, read_value.string());
232 dom_namespace->CloseStorageArea(area); 232 dom_namespace->CloseStorageArea(area);
233 233
234 DomStorageContext::SessionStorageUsageInfo info; 234 DomStorageContext::SessionStorageUsageInfo info;
235 info.origin = kOrigin; 235 info.origin = kOrigin;
236 info.persistent_namespace_id = kPersistentId; 236 info.persistent_namespace_id = kPersistentId;
237 context_->DeleteSessionStorage(info); 237 context_->DeleteSessionStorage(info);
238 238
239 // Destroy and recreate again. 239 // Destroy and recreate again.
240 context_->Shutdown(); 240 context_->Shutdown();
241 context_ = NULL; 241 context_ = NULL;
242 MessageLoop::current()->RunAllPending(); 242 MessageLoop::current()->RunAllPending();
243 context_ = new DomStorageContext(temp_dir_.path(), 243 context_ = new DomStorageContext(temp_dir_.path(),
244 temp_dir_.path(), 244 temp_dir_.path(),
245 storage_policy_, 245 storage_policy_.get(),
246 task_runner_); 246 task_runner_.get());
247 context_->SetSaveSessionStorageOnDisk(); 247 context_->SetSaveSessionStorageOnDisk();
248 248
249 // Now there should be no data. 249 // Now there should be no data.
250 context_->CreateSessionNamespace(kSessionStorageNamespaceId, 250 context_->CreateSessionNamespace(kSessionStorageNamespaceId,
251 kPersistentId); 251 kPersistentId);
252 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId); 252 dom_namespace = context_->GetStorageNamespace(kSessionStorageNamespaceId);
253 area = dom_namespace->OpenStorageArea(kOrigin); 253 area = dom_namespace->OpenStorageArea(kOrigin);
254 read_value = area->GetItem(kKey); 254 read_value = area->GetItem(kKey);
255 EXPECT_TRUE(read_value.is_null()); 255 EXPECT_TRUE(read_value.is_null());
256 dom_namespace->CloseStorageArea(area); 256 dom_namespace->CloseStorageArea(area);
257 context_->Shutdown(); 257 context_->Shutdown();
258 context_ = NULL; 258 context_ = NULL;
259 MessageLoop::current()->RunAllPending(); 259 MessageLoop::current()->RunAllPending();
260 } 260 }
261 261
262 } // namespace dom_storage 262 } // namespace dom_storage
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_cached_area_unittest.cc ('k') | webkit/fileapi/file_system_file_stream_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698