OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const std::string error_; | 82 const std::string error_; |
83 | 83 |
84 private: | 84 private: |
85 friend class base::RefCountedThreadSafe<Inner>; | 85 friend class base::RefCountedThreadSafe<Inner>; |
86 virtual ~Inner(); | 86 virtual ~Inner(); |
87 }; | 87 }; |
88 | 88 |
89 scoped_refptr<Inner> inner_; | 89 scoped_refptr<Inner> inner_; |
90 }; | 90 }; |
91 | 91 |
| 92 // Options for write operations. |
| 93 enum WriteOptions { |
| 94 // Callers should usually use this. |
| 95 DEFAULTS, |
| 96 |
| 97 // Ignore restrictions, such as quota. It is still possible for the |
| 98 // operation to fail, such as on hard drive failure or if the storage area |
| 99 // is configured to fail. |
| 100 FORCE |
| 101 }; |
| 102 |
92 virtual ~SettingsStorage() {} | 103 virtual ~SettingsStorage() {} |
93 | 104 |
94 // Gets a single value from storage. | 105 // Gets a single value from storage. |
95 virtual ReadResult Get(const std::string& key) = 0; | 106 virtual ReadResult Get(const std::string& key) = 0; |
96 | 107 |
97 // Gets multiple values from storage. | 108 // Gets multiple values from storage. |
98 virtual ReadResult Get(const std::vector<std::string>& keys) = 0; | 109 virtual ReadResult Get(const std::vector<std::string>& keys) = 0; |
99 | 110 |
100 // Gets all values from storage. | 111 // Gets all values from storage. |
101 virtual ReadResult Get() = 0; | 112 virtual ReadResult Get() = 0; |
102 | 113 |
103 // Sets a single key to a new value. | 114 // Sets a single key to a new value. |
104 virtual WriteResult Set(const std::string& key, const Value& value) = 0; | 115 virtual WriteResult Set( |
| 116 WriteOptions options, const std::string& key, const Value& value) = 0; |
105 | 117 |
106 // Sets multiple keys to new values. | 118 // Sets multiple keys to new values. |
107 virtual WriteResult Set(const DictionaryValue& values) = 0; | 119 virtual WriteResult Set( |
| 120 WriteOptions options, const DictionaryValue& values) = 0; |
108 | 121 |
109 // Removes a key from the storage. | 122 // Removes a key from the storage. |
110 virtual WriteResult Remove(const std::string& key) = 0; | 123 virtual WriteResult Remove(const std::string& key) = 0; |
111 | 124 |
112 // Removes multiple keys from the storage. | 125 // Removes multiple keys from the storage. |
113 virtual WriteResult Remove(const std::vector<std::string>& keys) = 0; | 126 virtual WriteResult Remove(const std::vector<std::string>& keys) = 0; |
114 | 127 |
115 // Clears the storage. | 128 // Clears the storage. |
116 virtual WriteResult Clear() = 0; | 129 virtual WriteResult Clear() = 0; |
117 }; | 130 }; |
118 | 131 |
119 } // namespace extensions | 132 } // namespace extensions |
120 | 133 |
121 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_H_ | 134 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_H_ |
OLD | NEW |