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_STORAGE_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_STORAGE_STORAGE_API_H_ |
6 #define EXTENSIONS_BROWSER_API_STORAGE_STORAGE_API_H_ | 6 #define EXTENSIONS_BROWSER_API_STORAGE_STORAGE_API_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "extensions/browser/api/storage/settings_namespace.h" | 10 #include "extensions/browser/api/storage/settings_namespace.h" |
11 #include "extensions/browser/api/storage/settings_observer.h" | 11 #include "extensions/browser/api/storage/settings_observer.h" |
12 #include "extensions/browser/extension_function.h" | 12 #include "extensions/browser/extension_function.h" |
13 #include "extensions/browser/value_store/value_store.h" | 13 #include "extensions/browser/value_store/value_store.h" |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 | 16 |
17 // Superclass of all settings functions. | 17 // Superclass of all settings functions. |
18 class SettingsFunction : public UIThreadExtensionFunction { | 18 class SettingsFunction : public UIThreadExtensionFunction { |
19 protected: | 19 protected: |
20 SettingsFunction(); | 20 SettingsFunction(); |
21 virtual ~SettingsFunction(); | 21 virtual ~SettingsFunction(); |
22 | 22 |
23 // ExtensionFunction: | 23 // ExtensionFunction: |
24 virtual bool ShouldSkipQuotaLimiting() const OVERRIDE; | 24 virtual bool ShouldSkipQuotaLimiting() const override; |
25 virtual ResponseAction Run() OVERRIDE; | 25 virtual ResponseAction Run() override; |
26 | 26 |
27 // Extension settings function implementations should do their work here. | 27 // Extension settings function implementations should do their work here. |
28 // The StorageFrontend makes sure this is posted to the appropriate thread. | 28 // The StorageFrontend makes sure this is posted to the appropriate thread. |
29 virtual ResponseValue RunWithStorage(ValueStore* storage) = 0; | 29 virtual ResponseValue RunWithStorage(ValueStore* storage) = 0; |
30 | 30 |
31 // Handles the |result| of a read function. | 31 // Handles the |result| of a read function. |
32 // - If the result succeeded, this will set |result_| and return. | 32 // - If the result succeeded, this will set |result_| and return. |
33 // - If |result| failed with a ValueStore::CORRUPTION error, this will call | 33 // - If |result| failed with a ValueStore::CORRUPTION error, this will call |
34 // RestoreStorageAndRetry(), and return that result. | 34 // RestoreStorageAndRetry(), and return that result. |
35 // - If the |result| failed with a different error, this will set |error_| | 35 // - If the |result| failed with a different error, this will set |error_| |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 }; | 73 }; |
74 | 74 |
75 class StorageStorageAreaGetFunction : public SettingsFunction { | 75 class StorageStorageAreaGetFunction : public SettingsFunction { |
76 public: | 76 public: |
77 DECLARE_EXTENSION_FUNCTION("storage.get", STORAGE_GET) | 77 DECLARE_EXTENSION_FUNCTION("storage.get", STORAGE_GET) |
78 | 78 |
79 protected: | 79 protected: |
80 virtual ~StorageStorageAreaGetFunction() {} | 80 virtual ~StorageStorageAreaGetFunction() {} |
81 | 81 |
82 // SettingsFunction: | 82 // SettingsFunction: |
83 virtual ResponseValue RunWithStorage(ValueStore* storage) OVERRIDE; | 83 virtual ResponseValue RunWithStorage(ValueStore* storage) override; |
84 }; | 84 }; |
85 | 85 |
86 class StorageStorageAreaSetFunction : public SettingsFunction { | 86 class StorageStorageAreaSetFunction : public SettingsFunction { |
87 public: | 87 public: |
88 DECLARE_EXTENSION_FUNCTION("storage.set", STORAGE_SET) | 88 DECLARE_EXTENSION_FUNCTION("storage.set", STORAGE_SET) |
89 | 89 |
90 protected: | 90 protected: |
91 virtual ~StorageStorageAreaSetFunction() {} | 91 virtual ~StorageStorageAreaSetFunction() {} |
92 | 92 |
93 // SettingsFunction: | 93 // SettingsFunction: |
94 virtual ResponseValue RunWithStorage(ValueStore* storage) OVERRIDE; | 94 virtual ResponseValue RunWithStorage(ValueStore* storage) override; |
95 | 95 |
96 // ExtensionFunction: | 96 // ExtensionFunction: |
97 virtual void GetQuotaLimitHeuristics( | 97 virtual void GetQuotaLimitHeuristics( |
98 QuotaLimitHeuristics* heuristics) const OVERRIDE; | 98 QuotaLimitHeuristics* heuristics) const override; |
99 }; | 99 }; |
100 | 100 |
101 class StorageStorageAreaRemoveFunction : public SettingsFunction { | 101 class StorageStorageAreaRemoveFunction : public SettingsFunction { |
102 public: | 102 public: |
103 DECLARE_EXTENSION_FUNCTION("storage.remove", STORAGE_REMOVE) | 103 DECLARE_EXTENSION_FUNCTION("storage.remove", STORAGE_REMOVE) |
104 | 104 |
105 protected: | 105 protected: |
106 virtual ~StorageStorageAreaRemoveFunction() {} | 106 virtual ~StorageStorageAreaRemoveFunction() {} |
107 | 107 |
108 // SettingsFunction: | 108 // SettingsFunction: |
109 virtual ResponseValue RunWithStorage(ValueStore* storage) OVERRIDE; | 109 virtual ResponseValue RunWithStorage(ValueStore* storage) override; |
110 | 110 |
111 // ExtensionFunction: | 111 // ExtensionFunction: |
112 virtual void GetQuotaLimitHeuristics( | 112 virtual void GetQuotaLimitHeuristics( |
113 QuotaLimitHeuristics* heuristics) const OVERRIDE; | 113 QuotaLimitHeuristics* heuristics) const override; |
114 }; | 114 }; |
115 | 115 |
116 class StorageStorageAreaClearFunction : public SettingsFunction { | 116 class StorageStorageAreaClearFunction : public SettingsFunction { |
117 public: | 117 public: |
118 DECLARE_EXTENSION_FUNCTION("storage.clear", STORAGE_CLEAR) | 118 DECLARE_EXTENSION_FUNCTION("storage.clear", STORAGE_CLEAR) |
119 | 119 |
120 protected: | 120 protected: |
121 virtual ~StorageStorageAreaClearFunction() {} | 121 virtual ~StorageStorageAreaClearFunction() {} |
122 | 122 |
123 // SettingsFunction: | 123 // SettingsFunction: |
124 virtual ResponseValue RunWithStorage(ValueStore* storage) OVERRIDE; | 124 virtual ResponseValue RunWithStorage(ValueStore* storage) override; |
125 | 125 |
126 // ExtensionFunction: | 126 // ExtensionFunction: |
127 virtual void GetQuotaLimitHeuristics( | 127 virtual void GetQuotaLimitHeuristics( |
128 QuotaLimitHeuristics* heuristics) const OVERRIDE; | 128 QuotaLimitHeuristics* heuristics) const override; |
129 }; | 129 }; |
130 | 130 |
131 class StorageStorageAreaGetBytesInUseFunction : public SettingsFunction { | 131 class StorageStorageAreaGetBytesInUseFunction : public SettingsFunction { |
132 public: | 132 public: |
133 DECLARE_EXTENSION_FUNCTION("storage.getBytesInUse", STORAGE_GETBYTESINUSE) | 133 DECLARE_EXTENSION_FUNCTION("storage.getBytesInUse", STORAGE_GETBYTESINUSE) |
134 | 134 |
135 protected: | 135 protected: |
136 virtual ~StorageStorageAreaGetBytesInUseFunction() {} | 136 virtual ~StorageStorageAreaGetBytesInUseFunction() {} |
137 | 137 |
138 // SettingsFunction: | 138 // SettingsFunction: |
139 virtual ResponseValue RunWithStorage(ValueStore* storage) OVERRIDE; | 139 virtual ResponseValue RunWithStorage(ValueStore* storage) override; |
140 }; | 140 }; |
141 | 141 |
142 } // namespace extensions | 142 } // namespace extensions |
143 | 143 |
144 #endif // EXTENSIONS_BROWSER_API_STORAGE_STORAGE_API_H_ | 144 #endif // EXTENSIONS_BROWSER_API_STORAGE_STORAGE_API_H_ |
OLD | NEW |