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

Side by Side Diff: chrome/browser/extensions/extensions_quota_service.cc

Issue 11312228: Move extension_error_utils.* and url_pattern_set.* into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hate Created 8 years, 1 month 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
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/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 #include "chrome/common/extensions/extension_error_utils.h" 10 #include "extensions/common/error_utils.h"
11 11
12 namespace { 12 namespace {
13 13
14 // If the browser stays open long enough, we reset state once a day. 14 // If the browser stays open long enough, we reset state once a day.
15 // Whatever this value is, it should be an order of magnitude longer than 15 // Whatever this value is, it should be an order of magnitude longer than
16 // the longest interval in any of the QuotaLimitHeuristics in use. 16 // the longest interval in any of the QuotaLimitHeuristics in use.
17 const int kPurgeIntervalInDays = 1; 17 const int kPurgeIntervalInDays = 1;
18 18
19 const char kOverQuotaError[] = "This request exceeds the * quota."; 19 const char kOverQuotaError[] = "This request exceeds the * quota.";
20 20
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 for (BucketList::iterator i = buckets.begin(); i != buckets.end(); ++i) { 126 for (BucketList::iterator i = buckets.begin(); i != buckets.end(); ++i) {
127 if ((*i)->expiration().is_null()) // A brand new bucket. 127 if ((*i)->expiration().is_null()) // A brand new bucket.
128 (*i)->Reset(config_, event_time); 128 (*i)->Reset(config_, event_time);
129 if (!Apply(*i, event_time)) 129 if (!Apply(*i, event_time))
130 return false; // It only takes one to spoil it for everyone. 130 return false; // It only takes one to spoil it for everyone.
131 } 131 }
132 return true; 132 return true;
133 } 133 }
134 134
135 std::string QuotaLimitHeuristic::GetError() const { 135 std::string QuotaLimitHeuristic::GetError() const {
136 return ExtensionErrorUtils::FormatErrorMessage(kOverQuotaError, name_); 136 return extensions::ErrorUtils::FormatErrorMessage(kOverQuotaError, name_);
137 } 137 }
138 138
139 ExtensionsQuotaService::SustainedLimit::SustainedLimit( 139 ExtensionsQuotaService::SustainedLimit::SustainedLimit(
140 const base::TimeDelta& sustain, 140 const base::TimeDelta& sustain,
141 const Config& config, 141 const Config& config,
142 BucketMapper* map, 142 BucketMapper* map,
143 const std::string& name) 143 const std::string& name)
144 : QuotaLimitHeuristic(config, map, name), 144 : QuotaLimitHeuristic(config, map, name),
145 repeat_exhaustion_allowance_(sustain.InSeconds() / 145 repeat_exhaustion_allowance_(sustain.InSeconds() /
146 config.refill_interval.InSeconds()), 146 config.refill_interval.InSeconds()),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return false; 182 return false;
183 } 183 }
184 } 184 }
185 185
186 // We can go negative since we check has_tokens when we get to *next* bucket, 186 // We can go negative since we check has_tokens when we get to *next* bucket,
187 // and for the small interval all that matters is whether we used up all the 187 // and for the small interval all that matters is whether we used up all the
188 // tokens (which is true if num_tokens_ <= 0). 188 // tokens (which is true if num_tokens_ <= 0).
189 bucket->DeductToken(); 189 bucket->DeductToken();
190 return true; 190 return true;
191 } 191 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/menu_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698