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 #ifndef EXTENSIONS_BROWSER_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ |
6 #define EXTENSIONS_BROWSER_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ | 6 #define EXTENSIONS_BROWSER_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_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 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 // A ValueStore decorator which makes calls through |Set| ignore quota. | 13 // A ValueStore decorator which makes calls through |Set| ignore quota. |
14 // "Weak" because ownership of the delegate isn't taken; this is designed to be | 14 // "Weak" because ownership of the delegate isn't taken; this is designed to be |
15 // temporarily attached to storage areas. | 15 // temporarily attached to storage areas. |
16 class WeakUnlimitedSettingsStorage : public ValueStore { | 16 class WeakUnlimitedSettingsStorage : public ValueStore { |
17 public: | 17 public: |
18 // Ownership of |delegate| NOT taken. | 18 // Ownership of |delegate| NOT taken. |
19 explicit WeakUnlimitedSettingsStorage(ValueStore* delegate); | 19 explicit WeakUnlimitedSettingsStorage(ValueStore* delegate); |
20 | 20 |
21 virtual ~WeakUnlimitedSettingsStorage(); | 21 ~WeakUnlimitedSettingsStorage() override; |
22 | 22 |
23 // ValueStore implementation. | 23 // ValueStore implementation. |
24 virtual size_t GetBytesInUse(const std::string& key) override; | 24 size_t GetBytesInUse(const std::string& key) override; |
25 virtual size_t GetBytesInUse(const std::vector<std::string>& keys) override; | 25 size_t GetBytesInUse(const std::vector<std::string>& keys) override; |
26 virtual size_t GetBytesInUse() override; | 26 size_t GetBytesInUse() override; |
27 virtual ReadResult Get(const std::string& key) override; | 27 ReadResult Get(const std::string& key) override; |
28 virtual ReadResult Get(const std::vector<std::string>& keys) override; | 28 ReadResult Get(const std::vector<std::string>& keys) override; |
29 virtual ReadResult Get() override; | 29 ReadResult Get() override; |
30 virtual WriteResult Set( | 30 WriteResult Set(WriteOptions options, |
31 WriteOptions options, | 31 const std::string& key, |
32 const std::string& key, | 32 const base::Value& value) override; |
33 const base::Value& value) override; | 33 WriteResult Set(WriteOptions options, |
34 virtual WriteResult Set( | 34 const base::DictionaryValue& values) override; |
35 WriteOptions options, const base::DictionaryValue& values) override; | 35 WriteResult Remove(const std::string& key) override; |
36 virtual WriteResult Remove(const std::string& key) override; | 36 WriteResult Remove(const std::vector<std::string>& keys) override; |
37 virtual WriteResult Remove(const std::vector<std::string>& keys) override; | 37 WriteResult Clear() override; |
38 virtual WriteResult Clear() override; | 38 bool Restore() override; |
39 virtual bool Restore() override; | 39 bool RestoreKey(const std::string& key) override; |
40 virtual bool RestoreKey(const std::string& key) override; | |
41 | 40 |
42 private: | 41 private: |
43 // The delegate storage area, NOT OWNED. | 42 // The delegate storage area, NOT OWNED. |
44 ValueStore* const delegate_; | 43 ValueStore* const delegate_; |
45 | 44 |
46 DISALLOW_COPY_AND_ASSIGN(WeakUnlimitedSettingsStorage); | 45 DISALLOW_COPY_AND_ASSIGN(WeakUnlimitedSettingsStorage); |
47 }; | 46 }; |
48 | 47 |
49 } // namespace extensions | 48 } // namespace extensions |
50 | 49 |
51 #endif // EXTENSIONS_BROWSER_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ | 50 #endif // EXTENSIONS_BROWSER_API_STORAGE_WEAK_UNLIMITED_SETTINGS_STORAGE_H_ |
OLD | NEW |