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

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

Issue 602883003: Replacing the OVERRIDE with override and FINAL with final in content/browser/indexed_db (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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 <string> 5 #include <string>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" 8 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h"
9 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" 9 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
10 #include "content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h " 10 #include "content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h "
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 : LevelDBTransaction(db), 47 : LevelDBTransaction(db),
48 fail_method_(fail_method), 48 fail_method_(fail_method),
49 fail_on_call_num_(fail_on_call_num), 49 fail_on_call_num_(fail_on_call_num),
50 current_call_num_(0) { 50 current_call_num_(0) {
51 DCHECK(fail_method != FAIL_METHOD_NOTHING); 51 DCHECK(fail_method != FAIL_METHOD_NOTHING);
52 DCHECK_GT(fail_on_call_num, 0); 52 DCHECK_GT(fail_on_call_num, 0);
53 } 53 }
54 54
55 virtual leveldb::Status Get(const base::StringPiece& key, 55 virtual leveldb::Status Get(const base::StringPiece& key,
56 std::string* value, 56 std::string* value,
57 bool* found) OVERRIDE { 57 bool* found) override {
58 if (fail_method_ != FAIL_METHOD_GET || 58 if (fail_method_ != FAIL_METHOD_GET ||
59 ++current_call_num_ != fail_on_call_num_) 59 ++current_call_num_ != fail_on_call_num_)
60 return LevelDBTransaction::Get(key, value, found); 60 return LevelDBTransaction::Get(key, value, found);
61 61
62 *found = false; 62 *found = false;
63 return leveldb::Status::Corruption("Corrupted for the test"); 63 return leveldb::Status::Corruption("Corrupted for the test");
64 } 64 }
65 65
66 virtual leveldb::Status Commit() OVERRIDE { 66 virtual leveldb::Status Commit() override {
67 if (fail_method_ != FAIL_METHOD_COMMIT || 67 if (fail_method_ != FAIL_METHOD_COMMIT ||
68 ++current_call_num_ != fail_on_call_num_) 68 ++current_call_num_ != fail_on_call_num_)
69 return LevelDBTransaction::Commit(); 69 return LevelDBTransaction::Commit();
70 70
71 return leveldb::Status::Corruption("Corrupted for the test"); 71 return leveldb::Status::Corruption("Corrupted for the test");
72 } 72 }
73 73
74 private: 74 private:
75 virtual ~LevelDBTestTansaction() {} 75 virtual ~LevelDBTestTansaction() {}
76 76
77 FailMethod fail_method_; 77 FailMethod fail_method_;
78 int fail_on_call_num_; 78 int fail_on_call_num_;
79 int current_call_num_; 79 int current_call_num_;
80 }; 80 };
81 81
82 class LevelDBTraceTansaction : public LevelDBTransaction { 82 class LevelDBTraceTansaction : public LevelDBTransaction {
83 public: 83 public:
84 LevelDBTraceTansaction(LevelDBDatabase* db, int tx_num) 84 LevelDBTraceTansaction(LevelDBDatabase* db, int tx_num)
85 : LevelDBTransaction(db), 85 : LevelDBTransaction(db),
86 commit_tracer_(s_class_name, "Commit", tx_num), 86 commit_tracer_(s_class_name, "Commit", tx_num),
87 get_tracer_(s_class_name, "Get", tx_num) {} 87 get_tracer_(s_class_name, "Get", tx_num) {}
88 88
89 virtual leveldb::Status Get(const base::StringPiece& key, 89 virtual leveldb::Status Get(const base::StringPiece& key,
90 std::string* value, 90 std::string* value,
91 bool* found) OVERRIDE { 91 bool* found) override {
92 get_tracer_.log_call(); 92 get_tracer_.log_call();
93 return LevelDBTransaction::Get(key, value, found); 93 return LevelDBTransaction::Get(key, value, found);
94 } 94 }
95 95
96 virtual leveldb::Status Commit() OVERRIDE { 96 virtual leveldb::Status Commit() override {
97 commit_tracer_.log_call(); 97 commit_tracer_.log_call();
98 return LevelDBTransaction::Commit(); 98 return LevelDBTransaction::Commit();
99 } 99 }
100 100
101 private: 101 private:
102 static const std::string s_class_name; 102 static const std::string s_class_name;
103 103
104 virtual ~LevelDBTraceTansaction() {} 104 virtual ~LevelDBTraceTansaction() {}
105 105
106 FunctionTracer commit_tracer_; 106 FunctionTracer commit_tracer_;
(...skipping 11 matching lines...) Expand all
118 seek_tracer_(s_class_name, "Seek", inst_num), 118 seek_tracer_(s_class_name, "Seek", inst_num),
119 next_tracer_(s_class_name, "Next", inst_num), 119 next_tracer_(s_class_name, "Next", inst_num),
120 prev_tracer_(s_class_name, "Prev", inst_num), 120 prev_tracer_(s_class_name, "Prev", inst_num),
121 key_tracer_(s_class_name, "Key", inst_num), 121 key_tracer_(s_class_name, "Key", inst_num),
122 value_tracer_(s_class_name, "Value", inst_num) {} 122 value_tracer_(s_class_name, "Value", inst_num) {}
123 virtual ~LevelDBTraceIteratorImpl() {} 123 virtual ~LevelDBTraceIteratorImpl() {}
124 124
125 private: 125 private:
126 static const std::string s_class_name; 126 static const std::string s_class_name;
127 127
128 virtual bool IsValid() const OVERRIDE { 128 virtual bool IsValid() const override {
129 is_valid_tracer_.log_call(); 129 is_valid_tracer_.log_call();
130 return LevelDBIteratorImpl::IsValid(); 130 return LevelDBIteratorImpl::IsValid();
131 } 131 }
132 virtual leveldb::Status SeekToLast() OVERRIDE { 132 virtual leveldb::Status SeekToLast() override {
133 seek_to_last_tracer_.log_call(); 133 seek_to_last_tracer_.log_call();
134 return LevelDBIteratorImpl::SeekToLast(); 134 return LevelDBIteratorImpl::SeekToLast();
135 } 135 }
136 virtual leveldb::Status Seek(const base::StringPiece& target) OVERRIDE { 136 virtual leveldb::Status Seek(const base::StringPiece& target) override {
137 seek_tracer_.log_call(); 137 seek_tracer_.log_call();
138 return LevelDBIteratorImpl::Seek(target); 138 return LevelDBIteratorImpl::Seek(target);
139 } 139 }
140 virtual leveldb::Status Next() OVERRIDE { 140 virtual leveldb::Status Next() override {
141 next_tracer_.log_call(); 141 next_tracer_.log_call();
142 return LevelDBIteratorImpl::Next(); 142 return LevelDBIteratorImpl::Next();
143 } 143 }
144 virtual leveldb::Status Prev() OVERRIDE { 144 virtual leveldb::Status Prev() override {
145 prev_tracer_.log_call(); 145 prev_tracer_.log_call();
146 return LevelDBIteratorImpl::Prev(); 146 return LevelDBIteratorImpl::Prev();
147 } 147 }
148 virtual base::StringPiece Key() const OVERRIDE { 148 virtual base::StringPiece Key() const override {
149 key_tracer_.log_call(); 149 key_tracer_.log_call();
150 return LevelDBIteratorImpl::Key(); 150 return LevelDBIteratorImpl::Key();
151 } 151 }
152 virtual base::StringPiece Value() const OVERRIDE { 152 virtual base::StringPiece Value() const override {
153 value_tracer_.log_call(); 153 value_tracer_.log_call();
154 return LevelDBIteratorImpl::Value(); 154 return LevelDBIteratorImpl::Value();
155 } 155 }
156 156
157 mutable FunctionTracer is_valid_tracer_; 157 mutable FunctionTracer is_valid_tracer_;
158 mutable FunctionTracer seek_to_last_tracer_; 158 mutable FunctionTracer seek_to_last_tracer_;
159 mutable FunctionTracer seek_tracer_; 159 mutable FunctionTracer seek_tracer_;
160 mutable FunctionTracer next_tracer_; 160 mutable FunctionTracer next_tracer_;
161 mutable FunctionTracer prev_tracer_; 161 mutable FunctionTracer prev_tracer_;
162 mutable FunctionTracer key_tracer_; 162 mutable FunctionTracer key_tracer_;
163 mutable FunctionTracer value_tracer_; 163 mutable FunctionTracer value_tracer_;
164 }; 164 };
165 165
166 const std::string LevelDBTraceIteratorImpl::s_class_name = "LevelDBIterator"; 166 const std::string LevelDBTraceIteratorImpl::s_class_name = "LevelDBIterator";
167 167
168 class LevelDBTestIteratorImpl : public content::LevelDBIteratorImpl { 168 class LevelDBTestIteratorImpl : public content::LevelDBIteratorImpl {
169 public: 169 public:
170 LevelDBTestIteratorImpl(scoped_ptr<leveldb::Iterator> iterator, 170 LevelDBTestIteratorImpl(scoped_ptr<leveldb::Iterator> iterator,
171 FailMethod fail_method, 171 FailMethod fail_method,
172 int fail_on_call_num) 172 int fail_on_call_num)
173 : LevelDBIteratorImpl(iterator.Pass()), 173 : LevelDBIteratorImpl(iterator.Pass()),
174 fail_method_(fail_method), 174 fail_method_(fail_method),
175 fail_on_call_num_(fail_on_call_num), 175 fail_on_call_num_(fail_on_call_num),
176 current_call_num_(0) {} 176 current_call_num_(0) {}
177 virtual ~LevelDBTestIteratorImpl() {} 177 virtual ~LevelDBTestIteratorImpl() {}
178 178
179 private: 179 private:
180 virtual leveldb::Status Seek(const base::StringPiece& target) OVERRIDE { 180 virtual leveldb::Status Seek(const base::StringPiece& target) override {
181 if (fail_method_ != FAIL_METHOD_SEEK || 181 if (fail_method_ != FAIL_METHOD_SEEK ||
182 ++current_call_num_ != fail_on_call_num_) 182 ++current_call_num_ != fail_on_call_num_)
183 return LevelDBIteratorImpl::Seek(target); 183 return LevelDBIteratorImpl::Seek(target);
184 return leveldb::Status::Corruption("Corrupted for test"); 184 return leveldb::Status::Corruption("Corrupted for test");
185 } 185 }
186 186
187 FailMethod fail_method_; 187 FailMethod fail_method_;
188 int fail_on_call_num_; 188 int fail_on_call_num_;
189 int current_call_num_; 189 int current_call_num_;
190 }; 190 };
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 void MockBrowserTestIndexedDBClassFactory::Reset() { 262 void MockBrowserTestIndexedDBClassFactory::Reset() {
263 failure_class_ = FAIL_CLASS_NOTHING; 263 failure_class_ = FAIL_CLASS_NOTHING;
264 failure_method_ = FAIL_METHOD_NOTHING; 264 failure_method_ = FAIL_METHOD_NOTHING;
265 instance_count_.clear(); 265 instance_count_.clear();
266 fail_on_instance_num_.clear(); 266 fail_on_instance_num_.clear();
267 fail_on_call_num_.clear(); 267 fail_on_call_num_.clear();
268 } 268 }
269 269
270 } // namespace content 270 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698