| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/quota_service.h" | 5 #include "extensions/browser/quota_service.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "extensions/browser/extension_function.h" | 9 #include "extensions/browser/extension_function.h" |
| 10 #include "extensions/common/error_utils.h" | 10 #include "extensions/common/error_utils.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 | 85 |
| 86 QuotaService::ScopedDisablePurgeForTesting::~ScopedDisablePurgeForTesting() { | 86 QuotaService::ScopedDisablePurgeForTesting::~ScopedDisablePurgeForTesting() { |
| 87 DCHECK(g_purge_disabled_for_testing); | 87 DCHECK(g_purge_disabled_for_testing); |
| 88 g_purge_disabled_for_testing = false; | 88 g_purge_disabled_for_testing = false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void QuotaService::PurgeFunctionHeuristicsMap(FunctionHeuristicsMap* map) { | 91 void QuotaService::PurgeFunctionHeuristicsMap(FunctionHeuristicsMap* map) { |
| 92 FunctionHeuristicsMap::iterator heuristics = map->begin(); | 92 FunctionHeuristicsMap::iterator heuristics = map->begin(); |
| 93 while (heuristics != map->end()) { | 93 while (heuristics != map->end()) { |
| 94 STLDeleteElements(&heuristics->second); | 94 base::STLDeleteElements(&heuristics->second); |
| 95 map->erase(heuristics++); | 95 map->erase(heuristics++); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 void QuotaService::Purge() { | 99 void QuotaService::Purge() { |
| 100 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
| 101 std::map<std::string, FunctionHeuristicsMap>::iterator it = | 101 std::map<std::string, FunctionHeuristicsMap>::iterator it = |
| 102 function_heuristics_.begin(); | 102 function_heuristics_.begin(); |
| 103 for (; it != function_heuristics_.end(); function_heuristics_.erase(it++)) | 103 for (; it != function_heuristics_.end(); function_heuristics_.erase(it++)) |
| 104 PurgeFunctionHeuristicsMap(&it->second); | 104 PurgeFunctionHeuristicsMap(&it->second); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 bool QuotaService::TimedLimit::Apply(Bucket* bucket, | 143 bool QuotaService::TimedLimit::Apply(Bucket* bucket, |
| 144 const base::TimeTicks& event_time) { | 144 const base::TimeTicks& event_time) { |
| 145 if (event_time > bucket->expiration()) | 145 if (event_time > bucket->expiration()) |
| 146 bucket->Reset(config(), event_time); | 146 bucket->Reset(config(), event_time); |
| 147 | 147 |
| 148 return bucket->DeductToken(); | 148 return bucket->DeductToken(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace extensions | 151 } // namespace extensions |
| OLD | NEW |