OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
5 #include "base/bind.h" | 8 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
8 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
10 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
12 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
14 #include "base/time/time.h" | 18 #include "base/time/time.h" |
15 #include "content/browser/dom_storage/dom_storage_area.h" | 19 #include "content/browser/dom_storage/dom_storage_area.h" |
16 #include "content/browser/dom_storage/dom_storage_database.h" | 20 #include "content/browser/dom_storage/dom_storage_database.h" |
17 #include "content/browser/dom_storage/dom_storage_database_adapter.h" | 21 #include "content/browser/dom_storage/dom_storage_database_adapter.h" |
18 #include "content/browser/dom_storage/dom_storage_task_runner.h" | 22 #include "content/browser/dom_storage/dom_storage_task_runner.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_FALSE(area->map_.get()); | 136 EXPECT_FALSE(area->map_.get()); |
133 EXPECT_EQ(0u, area->Length()); | 137 EXPECT_EQ(0u, area->Length()); |
134 EXPECT_TRUE(area->Key(0).is_null()); | 138 EXPECT_TRUE(area->Key(0).is_null()); |
135 EXPECT_TRUE(area->GetItem(kKey).is_null()); | 139 EXPECT_TRUE(area->GetItem(kKey).is_null()); |
136 EXPECT_FALSE(area->SetItem(kKey, kValue, &old_nullable_value)); | 140 EXPECT_FALSE(area->SetItem(kKey, kValue, &old_nullable_value)); |
137 EXPECT_FALSE(area->RemoveItem(kKey, &old_value)); | 141 EXPECT_FALSE(area->RemoveItem(kKey, &old_value)); |
138 EXPECT_FALSE(area->Clear()); | 142 EXPECT_FALSE(area->Clear()); |
139 } | 143 } |
140 | 144 |
141 TEST_F(DOMStorageAreaTest, BackingDatabaseOpened) { | 145 TEST_F(DOMStorageAreaTest, BackingDatabaseOpened) { |
142 const int64 kSessionStorageNamespaceId = kLocalStorageNamespaceId + 1; | 146 const int64_t kSessionStorageNamespaceId = kLocalStorageNamespaceId + 1; |
143 base::ScopedTempDir temp_dir; | 147 base::ScopedTempDir temp_dir; |
144 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 148 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
145 const base::FilePath kExpectedOriginFilePath = temp_dir.path().Append( | 149 const base::FilePath kExpectedOriginFilePath = temp_dir.path().Append( |
146 DOMStorageArea::DatabaseFileNameFromOrigin(kOrigin)); | 150 DOMStorageArea::DatabaseFileNameFromOrigin(kOrigin)); |
147 | 151 |
148 // No directory, backing should be null. | 152 // No directory, backing should be null. |
149 { | 153 { |
150 scoped_refptr<DOMStorageArea> area( | 154 scoped_refptr<DOMStorageArea> area( |
151 new DOMStorageArea(kOrigin, base::FilePath(), NULL)); | 155 new DOMStorageArea(kOrigin, base::FilePath(), NULL)); |
152 EXPECT_EQ(NULL, area->backing_.get()); | 156 EXPECT_EQ(NULL, area->backing_.get()); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 base::TimeDelta::FromMilliseconds(750))); | 529 base::TimeDelta::FromMilliseconds(750))); |
526 EXPECT_EQ(base::TimeDelta(), | 530 EXPECT_EQ(base::TimeDelta(), |
527 rate_limiter.ComputeDelayNeeded( | 531 rate_limiter.ComputeDelayNeeded( |
528 base::TimeDelta::FromMilliseconds(1500))); | 532 base::TimeDelta::FromMilliseconds(1500))); |
529 EXPECT_EQ(base::TimeDelta(), | 533 EXPECT_EQ(base::TimeDelta(), |
530 rate_limiter.ComputeDelayNeeded( | 534 rate_limiter.ComputeDelayNeeded( |
531 base::TimeDelta::FromDays(1))); | 535 base::TimeDelta::FromDays(1))); |
532 } | 536 } |
533 | 537 |
534 } // namespace content | 538 } // namespace content |
OLD | NEW |