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

Side by Side Diff: chrome/browser/extensions/api/storage/storage_api.cc

Issue 12330089: JSON compiler to include "customBindings" in the function name. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/storage/storage_api.h" 5 #include "chrome/browser/extensions/api/storage/storage_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 heuristics->push_back( 155 heuristics->push_back(
156 new ExtensionsQuotaService::SustainedLimit( 156 new ExtensionsQuotaService::SustainedLimit(
157 base::TimeDelta::FromMinutes(10), 157 base::TimeDelta::FromMinutes(10),
158 shortLimitConfig, 158 shortLimitConfig,
159 new QuotaLimitHeuristic::SingletonBucketMapper(), 159 new QuotaLimitHeuristic::SingletonBucketMapper(),
160 "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE")); 160 "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE"));
161 }; 161 };
162 162
163 } // namespace 163 } // namespace
164 164
165 bool StorageGetFunction::RunWithStorage(ValueStore* storage) { 165 bool StorageStorageAreaGetFunction::RunWithStorage(ValueStore* storage) {
166 Value* input = NULL; 166 Value* input = NULL;
167 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); 167 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input));
168 168
169 switch (input->GetType()) { 169 switch (input->GetType()) {
170 case Value::TYPE_NULL: 170 case Value::TYPE_NULL:
171 return UseReadResult(storage->Get()); 171 return UseReadResult(storage->Get());
172 172
173 case Value::TYPE_STRING: { 173 case Value::TYPE_STRING: {
174 std::string as_string; 174 std::string as_string;
175 input->GetAsString(&as_string); 175 input->GetAsString(&as_string);
(...skipping 18 matching lines...) Expand all
194 return UseReadResult( 194 return UseReadResult(
195 ValueStore::MakeReadResult(with_default_values)); 195 ValueStore::MakeReadResult(with_default_values));
196 } 196 }
197 197
198 default: 198 default:
199 return UseReadResult( 199 return UseReadResult(
200 ValueStore::MakeReadResult(kUnsupportedArgumentType)); 200 ValueStore::MakeReadResult(kUnsupportedArgumentType));
201 } 201 }
202 } 202 }
203 203
204 bool StorageGetBytesInUseFunction::RunWithStorage(ValueStore* storage) { 204 bool StorageStorageAreaGetBytesInUseFunction::RunWithStorage(
205 ValueStore* storage) {
205 Value* input = NULL; 206 Value* input = NULL;
206 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); 207 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input));
207 208
208 size_t bytes_in_use = 0; 209 size_t bytes_in_use = 0;
209 210
210 switch (input->GetType()) { 211 switch (input->GetType()) {
211 case Value::TYPE_NULL: 212 case Value::TYPE_NULL:
212 bytes_in_use = storage->GetBytesInUse(); 213 bytes_in_use = storage->GetBytesInUse();
213 break; 214 break;
214 215
(...skipping 13 matching lines...) Expand all
228 229
229 default: 230 default:
230 error_ = kUnsupportedArgumentType; 231 error_ = kUnsupportedArgumentType;
231 return false; 232 return false;
232 } 233 }
233 234
234 SetResult(Value::CreateIntegerValue(bytes_in_use)); 235 SetResult(Value::CreateIntegerValue(bytes_in_use));
235 return true; 236 return true;
236 } 237 }
237 238
238 bool StorageSetFunction::RunWithStorage(ValueStore* storage) { 239 bool StorageStorageAreaSetFunction::RunWithStorage(ValueStore* storage) {
239 DictionaryValue* input = NULL; 240 DictionaryValue* input = NULL;
240 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input)); 241 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input));
241 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input)); 242 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input));
242 } 243 }
243 244
244 void StorageSetFunction::GetQuotaLimitHeuristics( 245 void StorageStorageAreaSetFunction::GetQuotaLimitHeuristics(
245 QuotaLimitHeuristics* heuristics) const { 246 QuotaLimitHeuristics* heuristics) const {
246 GetModificationQuotaLimitHeuristics(heuristics); 247 GetModificationQuotaLimitHeuristics(heuristics);
247 } 248 }
248 249
249 bool StorageRemoveFunction::RunWithStorage(ValueStore* storage) { 250 bool StorageStorageAreaRemoveFunction::RunWithStorage(ValueStore* storage) {
250 Value* input = NULL; 251 Value* input = NULL;
251 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); 252 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input));
252 253
253 switch (input->GetType()) { 254 switch (input->GetType()) {
254 case Value::TYPE_STRING: { 255 case Value::TYPE_STRING: {
255 std::string as_string; 256 std::string as_string;
256 input->GetAsString(&as_string); 257 input->GetAsString(&as_string);
257 return UseWriteResult(storage->Remove(as_string)); 258 return UseWriteResult(storage->Remove(as_string));
258 } 259 }
259 260
260 case Value::TYPE_LIST: { 261 case Value::TYPE_LIST: {
261 std::vector<std::string> as_string_list; 262 std::vector<std::string> as_string_list;
262 AddAllStringValues(*static_cast<ListValue*>(input), &as_string_list); 263 AddAllStringValues(*static_cast<ListValue*>(input), &as_string_list);
263 return UseWriteResult(storage->Remove(as_string_list)); 264 return UseWriteResult(storage->Remove(as_string_list));
264 } 265 }
265 266
266 default: 267 default:
267 return UseWriteResult( 268 return UseWriteResult(
268 ValueStore::MakeWriteResult(kUnsupportedArgumentType)); 269 ValueStore::MakeWriteResult(kUnsupportedArgumentType));
269 }; 270 };
270 } 271 }
271 272
272 void StorageRemoveFunction::GetQuotaLimitHeuristics( 273 void StorageStorageAreaRemoveFunction::GetQuotaLimitHeuristics(
273 QuotaLimitHeuristics* heuristics) const { 274 QuotaLimitHeuristics* heuristics) const {
274 GetModificationQuotaLimitHeuristics(heuristics); 275 GetModificationQuotaLimitHeuristics(heuristics);
275 } 276 }
276 277
277 bool StorageClearFunction::RunWithStorage(ValueStore* storage) { 278 bool StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) {
278 return UseWriteResult(storage->Clear()); 279 return UseWriteResult(storage->Clear());
279 } 280 }
280 281
281 void StorageClearFunction::GetQuotaLimitHeuristics( 282 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics(
282 QuotaLimitHeuristics* heuristics) const { 283 QuotaLimitHeuristics* heuristics) const {
283 GetModificationQuotaLimitHeuristics(heuristics); 284 GetModificationQuotaLimitHeuristics(heuristics);
284 } 285 }
285 286
286 } // namespace extensions 287 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/storage_api.h ('k') | chrome/common/extensions/api/content_settings.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698