| 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.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 public: | 24 public: |
| 25 DomStorageContextTest() | 25 DomStorageContextTest() |
| 26 : kOrigin(GURL("http://dom_storage/")), | 26 : kOrigin(GURL("http://dom_storage/")), |
| 27 kKey(ASCIIToUTF16("key")), | 27 kKey(ASCIIToUTF16("key")), |
| 28 kValue(ASCIIToUTF16("value")), | 28 kValue(ASCIIToUTF16("value")), |
| 29 kDontIncludeFileInfo(false), | 29 kDontIncludeFileInfo(false), |
| 30 kDoIncludeFileInfo(true) { | 30 kDoIncludeFileInfo(true) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 const GURL kOrigin; | 33 const GURL kOrigin; |
| 34 const string16 kKey; | 34 const base::string16 kKey; |
| 35 const string16 kValue; | 35 const base::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()); |
| 44 context_ = new DomStorageContext(temp_dir_.path(), | 44 context_ = new DomStorageContext(temp_dir_.path(), |
| 45 base::FilePath(), | 45 base::FilePath(), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 base::string16 kKey(ASCIIToUTF16("foo")); |
| 209 const string16 kValue(ASCIIToUTF16("bar")); | 209 const base::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()->RunUntilIdle(); | 217 MessageLoop::current()->RunUntilIdle(); |
| 218 context_ = new DomStorageContext(temp_dir_.path(), | 218 context_ = new DomStorageContext(temp_dir_.path(), |
| 219 temp_dir_.path(), | 219 temp_dir_.path(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()->RunUntilIdle(); | 259 MessageLoop::current()->RunUntilIdle(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace dom_storage | 262 } // namespace dom_storage |
| OLD | NEW |