OLD | NEW |
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/extensions_quota_service.h" | 5 #include "chrome/browser/extensions/extensions_quota_service.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 DCHECK(CalledOnValidThread()); | 28 DCHECK(CalledOnValidThread()); |
29 purge_timer_.Stop(); | 29 purge_timer_.Stop(); |
30 Purge(); | 30 Purge(); |
31 } | 31 } |
32 | 32 |
33 bool ExtensionsQuotaService::Assess(const std::string& extension_id, | 33 bool ExtensionsQuotaService::Assess(const std::string& extension_id, |
34 ExtensionFunction* function, const ListValue* args, | 34 ExtensionFunction* function, const ListValue* args, |
35 const base::TimeTicks& event_time) { | 35 const base::TimeTicks& event_time) { |
36 DCHECK(CalledOnValidThread()); | 36 DCHECK(CalledOnValidThread()); |
37 | 37 |
| 38 if (function->ShouldSkipQuotaLimiting()) |
| 39 return true; |
| 40 |
38 // Lookup function list for extension. | 41 // Lookup function list for extension. |
39 FunctionHeuristicsMap& functions = function_heuristics_[extension_id]; | 42 FunctionHeuristicsMap& functions = function_heuristics_[extension_id]; |
40 | 43 |
41 // Lookup heuristics for function, create if necessary. | 44 // Lookup heuristics for function, create if necessary. |
42 QuotaLimitHeuristics& heuristics = functions[function->name()]; | 45 QuotaLimitHeuristics& heuristics = functions[function->name()]; |
43 if (heuristics.empty()) | 46 if (heuristics.empty()) |
44 function->GetQuotaLimitHeuristics(&heuristics); | 47 function->GetQuotaLimitHeuristics(&heuristics); |
45 | 48 |
46 if (heuristics.empty()) | 49 if (heuristics.empty()) |
47 return true; // No heuristic implies no limit. | 50 return true; // No heuristic implies no limit. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return false; | 160 return false; |
158 } | 161 } |
159 } | 162 } |
160 | 163 |
161 // We can go negative since we check has_tokens when we get to *next* bucket, | 164 // We can go negative since we check has_tokens when we get to *next* bucket, |
162 // and for the small interval all that matters is whether we used up all the | 165 // and for the small interval all that matters is whether we used up all the |
163 // tokens (which is true if num_tokens_ <= 0). | 166 // tokens (which is true if num_tokens_ <= 0). |
164 bucket->DeductToken(); | 167 bucket->DeductToken(); |
165 return true; | 168 return true; |
166 } | 169 } |
OLD | NEW |