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

Side by Side Diff: chrome/browser/extensions/settings/settings_api.cc

Issue 10266006: Define the storage API throttling constants in storage.json so that they are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/storage.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/settings/settings_api.h" 5 #include "chrome/browser/extensions/settings/settings_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extensions_quota_service.h" 10 #include "chrome/browser/extensions/extensions_quota_service.h"
11 #include "chrome/browser/extensions/settings/settings_api.h" 11 #include "chrome/browser/extensions/settings/settings_api.h"
12 #include "chrome/browser/extensions/settings/settings_frontend.h" 12 #include "chrome/browser/extensions/settings/settings_frontend.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/extensions/api/storage.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 namespace { 21 namespace {
21 const char* kUnsupportedArgumentType = "Unsupported argument type"; 22 const char* kUnsupportedArgumentType = "Unsupported argument type";
22 } // namespace 23 } // namespace
23 24
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 for (DictionaryValue::key_iterator it = dict.begin_keys(); 112 for (DictionaryValue::key_iterator it = dict.begin_keys();
112 it != dict.end_keys(); ++it) { 113 it != dict.end_keys(); ++it) {
113 keys.push_back(*it); 114 keys.push_back(*it);
114 } 115 }
115 return keys; 116 return keys;
116 } 117 }
117 118
118 // Creates quota heuristics for settings modification. 119 // Creates quota heuristics for settings modification.
119 static void GetModificationQuotaLimitHeuristics( 120 static void GetModificationQuotaLimitHeuristics(
120 QuotaLimitHeuristics* heuristics) { 121 QuotaLimitHeuristics* heuristics) {
121 // A max of 1000 operations per hour.
122 QuotaLimitHeuristic::Config longLimitConfig = { 122 QuotaLimitHeuristic::Config longLimitConfig = {
123 1000, 123 // See storage.json for current value.
124 base::TimeDelta::FromHours(1) 124 api::storage::sync::MAX_WRITE_OPERATIONS_PER_HOUR,
125 base::TimeDelta::FromHours(1)
125 }; 126 };
126 heuristics->push_back( 127 heuristics->push_back(
127 new ExtensionsQuotaService::TimedLimit( 128 new ExtensionsQuotaService::TimedLimit(
128 longLimitConfig, new QuotaLimitHeuristic::SingletonBucketMapper())); 129 longLimitConfig, new QuotaLimitHeuristic::SingletonBucketMapper()));
129 130
130 // A max of 10 operations per minute, sustained over 10 minutes. 131 // A max of 10 operations per minute, sustained over 10 minutes.
131 QuotaLimitHeuristic::Config shortLimitConfig = { 132 QuotaLimitHeuristic::Config shortLimitConfig = {
132 10, 133 // See storage.json for current value.
133 base::TimeDelta::FromMinutes(1) 134 api::storage::sync::MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE,
135 base::TimeDelta::FromMinutes(1)
134 }; 136 };
135 heuristics->push_back( 137 heuristics->push_back(
136 new ExtensionsQuotaService::SustainedLimit( 138 new ExtensionsQuotaService::SustainedLimit(
137 base::TimeDelta::FromMinutes(10), 139 base::TimeDelta::FromMinutes(10),
138 shortLimitConfig, 140 shortLimitConfig,
139 new QuotaLimitHeuristic::SingletonBucketMapper())); 141 new QuotaLimitHeuristic::SingletonBucketMapper()));
140 }; 142 };
141 143
142 } // namespace 144 } // namespace
143 145
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
263 return UseWriteResult(storage->Clear()); 265 return UseWriteResult(storage->Clear());
264 } 266 }
265 267
266 void ClearSettingsFunction::GetQuotaLimitHeuristics( 268 void ClearSettingsFunction::GetQuotaLimitHeuristics(
267 QuotaLimitHeuristics* heuristics) const { 269 QuotaLimitHeuristics* heuristics) const {
268 GetModificationQuotaLimitHeuristics(heuristics); 270 GetModificationQuotaLimitHeuristics(heuristics);
269 } 271 }
270 272
271 } // namespace extensions 273 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/storage.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698