| 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/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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> | 152 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)-> |
| 153 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); | 153 OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value)); |
| 154 context_->SetForceKeepSessionState(); // Should override clear behavior. | 154 context_->SetForceKeepSessionState(); // Should override clear behavior. |
| 155 context_->Shutdown(); | 155 context_->Shutdown(); |
| 156 context_ = NULL; | 156 context_ = NULL; |
| 157 MessageLoop::current()->RunAllPending(); | 157 MessageLoop::current()->RunAllPending(); |
| 158 | 158 |
| 159 VerifySingleOriginRemains(kSessionOnlyOrigin); | 159 VerifySingleOriginRemains(kSessionOnlyOrigin); |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST_F(DomStorageContextTest, PersistentIds) { |
| 163 const int kFirstSessionStorageNamespaceId = 1; |
| 164 const std::string kPersistentId = "persistent"; |
| 165 context_->CreateSessionNamespace(kFirstSessionStorageNamespaceId, |
| 166 kPersistentId); |
| 167 DomStorageNamespace* dom_namespace = |
| 168 context_->GetStorageNamespace(kFirstSessionStorageNamespaceId); |
| 169 ASSERT_TRUE(dom_namespace); |
| 170 EXPECT_EQ(kPersistentId, dom_namespace->persistent_namespace_id()); |
| 171 // Verify that the areas inherit the persistent ID. |
| 172 DomStorageArea* area = dom_namespace->OpenStorageArea(kOrigin); |
| 173 EXPECT_EQ(kPersistentId, area->persistent_namespace_id_); |
| 174 |
| 175 // Verify that the persistent IDs are handled correctly when cloning. |
| 176 const int kClonedSessionStorageNamespaceId = 2; |
| 177 const std::string kClonedPersistentId = "cloned"; |
| 178 context_->CloneSessionNamespace(kFirstSessionStorageNamespaceId, |
| 179 kClonedSessionStorageNamespaceId, |
| 180 kClonedPersistentId); |
| 181 DomStorageNamespace* cloned_dom_namespace = |
| 182 context_->GetStorageNamespace(kClonedSessionStorageNamespaceId); |
| 183 ASSERT_TRUE(dom_namespace); |
| 184 EXPECT_EQ(kClonedPersistentId, |
| 185 cloned_dom_namespace->persistent_namespace_id()); |
| 186 // Verify that the areas inherit the persistent ID. |
| 187 DomStorageArea* cloned_area = cloned_dom_namespace->OpenStorageArea(kOrigin); |
| 188 EXPECT_EQ(kClonedPersistentId, cloned_area->persistent_namespace_id_); |
| 189 } |
| 190 |
| 162 } // namespace dom_storage | 191 } // namespace dom_storage |
| OLD | NEW |