| 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 #include "extensions/browser/api/storage/storage_api.h" | 5 #include "extensions/browser/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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 void GetModificationQuotaLimitHeuristics(QuotaLimitHeuristics* heuristics) { | 151 void GetModificationQuotaLimitHeuristics(QuotaLimitHeuristics* heuristics) { |
| 152 QuotaLimitHeuristic::Config longLimitConfig = { | 152 QuotaLimitHeuristic::Config longLimitConfig = { |
| 153 // See storage.json for current value. | 153 // See storage.json for current value. |
| 154 core_api::storage::sync::MAX_WRITE_OPERATIONS_PER_HOUR, | 154 core_api::storage::sync::MAX_WRITE_OPERATIONS_PER_HOUR, |
| 155 base::TimeDelta::FromHours(1) | 155 base::TimeDelta::FromHours(1) |
| 156 }; | 156 }; |
| 157 heuristics->push_back(new QuotaService::TimedLimit( | 157 heuristics->push_back(new QuotaService::TimedLimit( |
| 158 longLimitConfig, | 158 longLimitConfig, |
| 159 new QuotaLimitHeuristic::SingletonBucketMapper(), | 159 new QuotaLimitHeuristic::SingletonBucketMapper(), |
| 160 "MAX_WRITE_OPERATIONS_PER_HOUR")); | 160 "MAX_WRITE_OPERATIONS_PER_HOUR")); |
| 161 | |
| 162 // A max of 10 operations per minute, sustained over 10 minutes. | |
| 163 QuotaLimitHeuristic::Config shortLimitConfig = { | |
| 164 // See storage.json for current value. | |
| 165 core_api::storage::sync::MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE, | |
| 166 base::TimeDelta::FromMinutes(1) | |
| 167 }; | |
| 168 heuristics->push_back(new QuotaService::SustainedLimit( | |
| 169 base::TimeDelta::FromMinutes(10), | |
| 170 shortLimitConfig, | |
| 171 new QuotaLimitHeuristic::SingletonBucketMapper(), | |
| 172 "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE")); | |
| 173 }; | 161 }; |
| 174 | 162 |
| 175 } // namespace | 163 } // namespace |
| 176 | 164 |
| 177 ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage( | 165 ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage( |
| 178 ValueStore* storage) { | 166 ValueStore* storage) { |
| 179 base::Value* input = NULL; | 167 base::Value* input = NULL; |
| 180 if (!args_->Get(0, &input)) | 168 if (!args_->Get(0, &input)) |
| 181 return BadMessage(); | 169 return BadMessage(); |
| 182 | 170 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) { | 288 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) { |
| 301 return UseWriteResult(storage->Clear(), storage); | 289 return UseWriteResult(storage->Clear(), storage); |
| 302 } | 290 } |
| 303 | 291 |
| 304 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics( | 292 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics( |
| 305 QuotaLimitHeuristics* heuristics) const { | 293 QuotaLimitHeuristics* heuristics) const { |
| 306 GetModificationQuotaLimitHeuristics(heuristics); | 294 GetModificationQuotaLimitHeuristics(heuristics); |
| 307 } | 295 } |
| 308 | 296 |
| 309 } // namespace extensions | 297 } // namespace extensions |
| OLD | NEW |