| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 std::vector<std::string> GetKeys(const base::DictionaryValue& dict) { | 142 std::vector<std::string> GetKeys(const base::DictionaryValue& dict) { |
| 143 std::vector<std::string> keys; | 143 std::vector<std::string> keys; |
| 144 for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) { | 144 for (base::DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) { |
| 145 keys.push_back(it.key()); | 145 keys.push_back(it.key()); |
| 146 } | 146 } |
| 147 return keys; | 147 return keys; |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Creates quota heuristics for settings modification. | 150 // Creates quota heuristics for settings modification. |
| 151 void GetModificationQuotaLimitHeuristics(QuotaLimitHeuristics* heuristics) { | 151 void GetModificationQuotaLimitHeuristics(QuotaLimitHeuristics* heuristics) { |
| 152 QuotaLimitHeuristic::Config longLimitConfig = { | 152 // See storage.json for the current value of these limits. |
| 153 // See storage.json for current value. | 153 QuotaLimitHeuristic::Config short_limit_config = { |
| 154 core_api::storage::sync::MAX_WRITE_OPERATIONS_PER_HOUR, | 154 core_api::storage::sync::MAX_WRITE_OPERATIONS_PER_MINUTE, |
| 155 base::TimeDelta::FromHours(1) | 155 base::TimeDelta::FromMinutes(1)}; |
| 156 }; | 156 QuotaLimitHeuristic::Config long_limit_config = { |
| 157 core_api::storage::sync::MAX_WRITE_OPERATIONS_PER_HOUR, |
| 158 base::TimeDelta::FromHours(1)}; |
| 157 heuristics->push_back(new QuotaService::TimedLimit( | 159 heuristics->push_back(new QuotaService::TimedLimit( |
| 158 longLimitConfig, | 160 short_limit_config, new QuotaLimitHeuristic::SingletonBucketMapper(), |
| 159 new QuotaLimitHeuristic::SingletonBucketMapper(), | 161 "MAX_WRITE_OPERATIONS_PER_MINUTE")); |
| 162 heuristics->push_back(new QuotaService::TimedLimit( |
| 163 long_limit_config, new QuotaLimitHeuristic::SingletonBucketMapper(), |
| 160 "MAX_WRITE_OPERATIONS_PER_HOUR")); | 164 "MAX_WRITE_OPERATIONS_PER_HOUR")); |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 } // namespace | 167 } // namespace |
| 164 | 168 |
| 165 ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage( | 169 ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage( |
| 166 ValueStore* storage) { | 170 ValueStore* storage) { |
| 167 base::Value* input = NULL; | 171 base::Value* input = NULL; |
| 168 if (!args_->Get(0, &input)) | 172 if (!args_->Get(0, &input)) |
| 169 return BadMessage(); | 173 return BadMessage(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) { | 292 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) { |
| 289 return UseWriteResult(storage->Clear(), storage); | 293 return UseWriteResult(storage->Clear(), storage); |
| 290 } | 294 } |
| 291 | 295 |
| 292 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics( | 296 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics( |
| 293 QuotaLimitHeuristics* heuristics) const { | 297 QuotaLimitHeuristics* heuristics) const { |
| 294 GetModificationQuotaLimitHeuristics(heuristics); | 298 GetModificationQuotaLimitHeuristics(heuristics); |
| 295 } | 299 } |
| 296 | 300 |
| 297 } // namespace extensions | 301 } // namespace extensions |
| OLD | NEW |