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

Side by Side Diff: extensions/browser/value_store/testing_value_store.h

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (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 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_TESTING_VALUE_STORE_H_ 5 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_TESTING_VALUE_STORE_H_
6 #define EXTENSIONS_BROWSER_VALUE_STORE_TESTING_VALUE_STORE_H_ 6 #define EXTENSIONS_BROWSER_VALUE_STORE_TESTING_VALUE_STORE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "extensions/browser/value_store/value_store.h" 9 #include "extensions/browser/value_store/value_store.h"
10 10
11 // ValueStore for testing, with an in-memory storage but the ability to 11 // ValueStore for testing, with an in-memory storage but the ability to
12 // optionally fail all operations. 12 // optionally fail all operations.
13 class TestingValueStore : public ValueStore { 13 class TestingValueStore : public ValueStore {
14 public: 14 public:
15 TestingValueStore(); 15 TestingValueStore();
16 virtual ~TestingValueStore(); 16 ~TestingValueStore() override;
17 17
18 // Sets the error code for requests. If OK, errors won't be thrown. 18 // Sets the error code for requests. If OK, errors won't be thrown.
19 // Defaults to OK. 19 // Defaults to OK.
20 void set_error_code(ErrorCode error_code) { error_code_ = error_code; } 20 void set_error_code(ErrorCode error_code) { error_code_ = error_code; }
21 21
22 // Accessors for the number of reads/writes done by this value store. Each 22 // Accessors for the number of reads/writes done by this value store. Each
23 // Get* operation (except for the BytesInUse ones) counts as one read, and 23 // Get* operation (except for the BytesInUse ones) counts as one read, and
24 // each Set*/Remove/Clear operation counts as one write. This is useful in 24 // each Set*/Remove/Clear operation counts as one write. This is useful in
25 // tests seeking to assert that some number of reads/writes to their 25 // tests seeking to assert that some number of reads/writes to their
26 // underlying value store have (or have not) happened. 26 // underlying value store have (or have not) happened.
27 int read_count() { return read_count_; } 27 int read_count() { return read_count_; }
28 int write_count() { return write_count_; } 28 int write_count() { return write_count_; }
29 29
30 // ValueStore implementation. 30 // ValueStore implementation.
31 virtual size_t GetBytesInUse(const std::string& key) override; 31 size_t GetBytesInUse(const std::string& key) override;
32 virtual size_t GetBytesInUse(const std::vector<std::string>& keys) override; 32 size_t GetBytesInUse(const std::vector<std::string>& keys) override;
33 virtual size_t GetBytesInUse() override; 33 size_t GetBytesInUse() override;
34 virtual ReadResult Get(const std::string& key) override; 34 ReadResult Get(const std::string& key) override;
35 virtual ReadResult Get(const std::vector<std::string>& keys) override; 35 ReadResult Get(const std::vector<std::string>& keys) override;
36 virtual ReadResult Get() override; 36 ReadResult Get() override;
37 virtual WriteResult Set( 37 WriteResult Set(WriteOptions options,
38 WriteOptions options, 38 const std::string& key,
39 const std::string& key, 39 const base::Value& value) override;
40 const base::Value& value) override; 40 WriteResult Set(WriteOptions options,
41 virtual WriteResult Set( 41 const base::DictionaryValue& values) override;
42 WriteOptions options, const base::DictionaryValue& values) override; 42 WriteResult Remove(const std::string& key) override;
43 virtual WriteResult Remove(const std::string& key) override; 43 WriteResult Remove(const std::vector<std::string>& keys) override;
44 virtual WriteResult Remove(const std::vector<std::string>& keys) override; 44 WriteResult Clear() override;
45 virtual WriteResult Clear() override;
46 // TestingValueStores can't get corrupted (they're all in-memory), so these 45 // TestingValueStores can't get corrupted (they're all in-memory), so these
47 // just return true. 46 // just return true.
48 virtual bool Restore() override; 47 bool Restore() override;
49 virtual bool RestoreKey(const std::string& key) override; 48 bool RestoreKey(const std::string& key) override;
50 49
51 private: 50 private:
52 scoped_ptr<ValueStore::Error> TestingError(); 51 scoped_ptr<ValueStore::Error> TestingError();
53 52
54 base::DictionaryValue storage_; 53 base::DictionaryValue storage_;
55 int read_count_; 54 int read_count_;
56 int write_count_; 55 int write_count_;
57 ErrorCode error_code_; 56 ErrorCode error_code_;
58 57
59 DISALLOW_COPY_AND_ASSIGN(TestingValueStore); 58 DISALLOW_COPY_AND_ASSIGN(TestingValueStore);
60 }; 59 };
61 60
62 #endif // EXTENSIONS_BROWSER_VALUE_STORE_TESTING_VALUE_STORE_H_ 61 #endif // EXTENSIONS_BROWSER_VALUE_STORE_TESTING_VALUE_STORE_H_
OLDNEW
« no previous file with comments | « extensions/browser/value_store/leveldb_value_store.h ('k') | extensions/browser/view_type_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698