OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" | 8 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" |
9 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 9 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
10 #include "content/browser/indexed_db/indexed_db_factory.h" | 10 #include "content/browser/indexed_db/indexed_db_factory.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 bool CheckSingleOriginInUse(const GURL& origin) const { | 42 bool CheckSingleOriginInUse(const GURL& origin) const { |
43 return !duplicate_calls_ && origins_.size() == 1 && origins_.count(origin); | 43 return !duplicate_calls_ && origins_.size() == 1 && origins_.count(origin); |
44 } | 44 } |
45 | 45 |
46 protected: | 46 protected: |
47 virtual ~MockIDBFactory() {} | 47 virtual ~MockIDBFactory() {} |
48 | 48 |
49 private: | 49 private: |
50 std::set<GURL> origins_; | 50 std::set<GURL> origins_; |
51 bool duplicate_calls_; | 51 bool duplicate_calls_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(MockIDBFactory); |
52 }; | 54 }; |
53 | 55 |
54 class MockIDBBackingStore : public IndexedDBFakeBackingStore { | 56 class MockIDBBackingStore : public IndexedDBFakeBackingStore { |
55 public: | 57 public: |
56 MockIDBBackingStore(IndexedDBFactory* factory, base::TaskRunner* task_runner) | 58 MockIDBBackingStore(IndexedDBFactory* factory, base::TaskRunner* task_runner) |
57 : IndexedDBFakeBackingStore(factory, task_runner), | 59 : IndexedDBFakeBackingStore(factory, task_runner), |
58 duplicate_calls_(false) {} | 60 duplicate_calls_(false) {} |
59 | 61 |
60 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) OVERRIDE { | 62 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) OVERRIDE { |
61 unused_blobs_.insert(std::make_pair(database_id, blob_key)); | 63 unused_blobs_.insert(std::make_pair(database_id, blob_key)); |
(...skipping 10 matching lines...) Expand all Loading... |
72 } | 74 } |
73 | 75 |
74 const KeyPairSet& unused_blobs() const { return unused_blobs_; } | 76 const KeyPairSet& unused_blobs() const { return unused_blobs_; } |
75 | 77 |
76 protected: | 78 protected: |
77 virtual ~MockIDBBackingStore() {} | 79 virtual ~MockIDBBackingStore() {} |
78 | 80 |
79 private: | 81 private: |
80 KeyPairSet unused_blobs_; | 82 KeyPairSet unused_blobs_; |
81 bool duplicate_calls_; | 83 bool duplicate_calls_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore); |
82 }; | 86 }; |
83 | 87 |
84 // Base class for our test fixtures. | 88 // Base class for our test fixtures. |
85 class IndexedDBActiveBlobRegistryTest : public testing::Test { | 89 class IndexedDBActiveBlobRegistryTest : public testing::Test { |
86 public: | 90 public: |
87 IndexedDBActiveBlobRegistryTest() | 91 IndexedDBActiveBlobRegistryTest() |
88 : task_runner_(new base::TestSimpleTaskRunner), | 92 : task_runner_(new base::TestSimpleTaskRunner), |
89 factory_(new MockIDBFactory), | 93 factory_(new MockIDBFactory), |
90 backing_store_(new MockIDBBackingStore(factory_, task_runner_)), | 94 backing_store_(new MockIDBBackingStore(factory_, task_runner_)), |
91 registry_(new IndexedDBActiveBlobRegistry(backing_store_.get())) {} | 95 registry_(new IndexedDBActiveBlobRegistry(backing_store_.get())) {} |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 RunUntilIdle(); | 265 RunUntilIdle(); |
262 | 266 |
263 // Nothing changes. | 267 // Nothing changes. |
264 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url())); | 268 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url())); |
265 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty()); | 269 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty()); |
266 } | 270 } |
267 | 271 |
268 } // namespace | 272 } // namespace |
269 | 273 |
270 } // namespace content | 274 } // namespace content |
OLD | NEW |