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

Side by Side Diff: content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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_fake_backing_store.h" 10 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h"
11 #include "content/browser/indexed_db/mock_indexed_db_factory.h" 11 #include "content/browser/indexed_db/mock_indexed_db_factory.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 namespace { 16 namespace {
17 17
18 class RegistryTestMockFactory : public MockIndexedDBFactory { 18 class RegistryTestMockFactory : public MockIndexedDBFactory {
19 public: 19 public:
20 RegistryTestMockFactory() : duplicate_calls_(false) {} 20 RegistryTestMockFactory() : duplicate_calls_(false) {}
21 21
22 virtual void ReportOutstandingBlobs(const GURL& origin_url, 22 void ReportOutstandingBlobs(const GURL& origin_url,
23 bool blobs_outstanding) override { 23 bool blobs_outstanding) override {
24 if (blobs_outstanding) { 24 if (blobs_outstanding) {
25 if (origins_.count(origin_url)) { 25 if (origins_.count(origin_url)) {
26 duplicate_calls_ = true; 26 duplicate_calls_ = true;
27 } else { 27 } else {
28 origins_.insert(origin_url); 28 origins_.insert(origin_url);
29 } 29 }
30 } else { 30 } else {
31 if (!origins_.count(origin_url)) { 31 if (!origins_.count(origin_url)) {
32 duplicate_calls_ = true; 32 duplicate_calls_ = true;
33 } else { 33 } else {
34 origins_.erase(origin_url); 34 origins_.erase(origin_url);
35 } 35 }
36 } 36 }
37 } 37 }
38 38
39 bool CheckNoOriginsInUse() const { 39 bool CheckNoOriginsInUse() const {
40 return !duplicate_calls_ && !origins_.size(); 40 return !duplicate_calls_ && !origins_.size();
41 } 41 }
42 42
43 bool CheckSingleOriginInUse(const GURL& origin) const { 43 bool CheckSingleOriginInUse(const GURL& origin) const {
44 return !duplicate_calls_ && origins_.size() == 1 && origins_.count(origin); 44 return !duplicate_calls_ && origins_.size() == 1 && origins_.count(origin);
45 } 45 }
46 46
47 private: 47 private:
48 virtual ~RegistryTestMockFactory() {} 48 ~RegistryTestMockFactory() override {}
49 49
50 std::set<GURL> origins_; 50 std::set<GURL> origins_;
51 bool duplicate_calls_; 51 bool duplicate_calls_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(RegistryTestMockFactory); 53 DISALLOW_COPY_AND_ASSIGN(RegistryTestMockFactory);
54 }; 54 };
55 55
56 class MockIDBBackingStore : public IndexedDBFakeBackingStore { 56 class MockIDBBackingStore : public IndexedDBFakeBackingStore {
57 public: 57 public:
58 typedef std::pair<int64, int64> KeyPair; 58 typedef std::pair<int64, int64> KeyPair;
59 typedef std::set<KeyPair> KeyPairSet; 59 typedef std::set<KeyPair> KeyPairSet;
60 60
61 MockIDBBackingStore(IndexedDBFactory* factory, 61 MockIDBBackingStore(IndexedDBFactory* factory,
62 base::SequencedTaskRunner* task_runner) 62 base::SequencedTaskRunner* task_runner)
63 : IndexedDBFakeBackingStore(factory, task_runner), 63 : IndexedDBFakeBackingStore(factory, task_runner),
64 duplicate_calls_(false) {} 64 duplicate_calls_(false) {}
65 65
66 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) override { 66 void ReportBlobUnused(int64 database_id, int64 blob_key) override {
67 unused_blobs_.insert(std::make_pair(database_id, blob_key)); 67 unused_blobs_.insert(std::make_pair(database_id, blob_key));
68 } 68 }
69 69
70 bool CheckUnusedBlobsEmpty() const { 70 bool CheckUnusedBlobsEmpty() const {
71 return !duplicate_calls_ && !unused_blobs_.size(); 71 return !duplicate_calls_ && !unused_blobs_.size();
72 } 72 }
73 bool CheckSingleUnusedBlob(int64 database_id, int64 blob_key) const { 73 bool CheckSingleUnusedBlob(int64 database_id, int64 blob_key) const {
74 return !duplicate_calls_ && unused_blobs_.size() == 1 && 74 return !duplicate_calls_ && unused_blobs_.size() == 1 &&
75 unused_blobs_.count(std::make_pair(database_id, blob_key)); 75 unused_blobs_.count(std::make_pair(database_id, blob_key));
76 } 76 }
77 77
78 const KeyPairSet& unused_blobs() const { return unused_blobs_; } 78 const KeyPairSet& unused_blobs() const { return unused_blobs_; }
79 79
80 protected: 80 protected:
81 virtual ~MockIDBBackingStore() {} 81 ~MockIDBBackingStore() override {}
82 82
83 private: 83 private:
84 KeyPairSet unused_blobs_; 84 KeyPairSet unused_blobs_;
85 bool duplicate_calls_; 85 bool duplicate_calls_;
86 86
87 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore); 87 DISALLOW_COPY_AND_ASSIGN(MockIDBBackingStore);
88 }; 88 };
89 89
90 // Base class for our test fixtures. 90 // Base class for our test fixtures.
91 class IndexedDBActiveBlobRegistryTest : public testing::Test { 91 class IndexedDBActiveBlobRegistryTest : public testing::Test {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 RunUntilIdle(); 268 RunUntilIdle();
269 269
270 // Nothing changes. 270 // Nothing changes.
271 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url())); 271 EXPECT_TRUE(factory()->CheckSingleOriginInUse(backing_store()->origin_url()));
272 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty()); 272 EXPECT_TRUE(backing_store()->CheckUnusedBlobsEmpty());
273 } 273 }
274 274
275 } // namespace 275 } // namespace
276 276
277 } // namespace content 277 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/host_zoom_map_impl.h ('k') | content/browser/indexed_db/indexed_db_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698