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

Side by Side Diff: extensions/browser/quota_service.h

Issue 685603003: Remove the extension QuotaService::SustainedLimit and its last client, the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fullstop Created 6 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
« no previous file with comments | « extensions/browser/api/storage/storage_api.cc ('k') | extensions/browser/quota_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // The QuotaService uses heuristics to limit abusive requests 5 // The QuotaService uses heuristics to limit abusive requests
6 // made by extensions. In this model 'items' (e.g individual bookmarks) are 6 // made by extensions. In this model 'items' (e.g individual bookmarks) are
7 // represented by a 'Bucket' that holds state for that item for one single 7 // represented by a 'Bucket' that holds state for that item for one single
8 // interval of time. The interval of time is defined as 'how long we need to 8 // interval of time. The interval of time is defined as 'how long we need to
9 // watch an item (for a particular heuristic) before making a decision about 9 // watch an item (for a particular heuristic) before making a decision about
10 // quota violations'. A heuristic is two functions: one mapping input 10 // quota violations'. A heuristic is two functions: one mapping input
(...skipping 27 matching lines...) Expand all
38 // 38 //
39 // The QuotaService needs to live entirely on one thread, i.e. be created, 39 // The QuotaService needs to live entirely on one thread, i.e. be created,
40 // called and destroyed on the same thread, due to its use of a RepeatingTimer. 40 // called and destroyed on the same thread, due to its use of a RepeatingTimer.
41 // It is not a KeyedService because instances exist on both the UI 41 // It is not a KeyedService because instances exist on both the UI
42 // and IO threads. 42 // and IO threads.
43 class QuotaService : public base::NonThreadSafe { 43 class QuotaService : public base::NonThreadSafe {
44 public: 44 public:
45 // Some concrete heuristics (declared below) that ExtensionFunctions can 45 // Some concrete heuristics (declared below) that ExtensionFunctions can
46 // use to help the service make decisions about quota violations. 46 // use to help the service make decisions about quota violations.
47 class TimedLimit; 47 class TimedLimit;
48 class SustainedLimit;
49 48
50 QuotaService(); 49 QuotaService();
51 virtual ~QuotaService(); 50 virtual ~QuotaService();
52 51
53 // Decide whether the invocation of |function| with argument |args| by the 52 // Decide whether the invocation of |function| with argument |args| by the
54 // extension specified by |extension_id| results in a quota limit violation. 53 // extension specified by |extension_id| results in a quota limit violation.
55 // Returns an error message representing the failure if quota was exceeded, 54 // Returns an error message representing the failure if quota was exceeded,
56 // or empty-string if the request is fine and can proceed. 55 // or empty-string if the request is fine and can proceed.
57 std::string Assess(const std::string& extension_id, 56 std::string Assess(const std::string& extension_id,
58 ExtensionFunction* function, 57 ExtensionFunction* function,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 208
210 // A simple per-item heuristic to limit the number of events that can occur in 209 // A simple per-item heuristic to limit the number of events that can occur in
211 // a given period of time; e.g "no more than 100 events in an hour". 210 // a given period of time; e.g "no more than 100 events in an hour".
212 class QuotaService::TimedLimit : public QuotaLimitHeuristic { 211 class QuotaService::TimedLimit : public QuotaLimitHeuristic {
213 public: 212 public:
214 TimedLimit(const Config& config, BucketMapper* map, const std::string& name) 213 TimedLimit(const Config& config, BucketMapper* map, const std::string& name)
215 : QuotaLimitHeuristic(config, map, name) {} 214 : QuotaLimitHeuristic(config, map, name) {}
216 bool Apply(Bucket* bucket, const base::TimeTicks& event_time) override; 215 bool Apply(Bucket* bucket, const base::TimeTicks& event_time) override;
217 }; 216 };
218 217
219 // A per-item heuristic to limit the number of events that can occur in a
220 // period of time over a sustained longer interval. E.g "no more than two
221 // events per minute, sustained over 10 minutes".
222 class QuotaService::SustainedLimit : public QuotaLimitHeuristic {
223 public:
224 SustainedLimit(const base::TimeDelta& sustain,
225 const Config& config,
226 BucketMapper* map,
227 const std::string& name);
228 bool Apply(Bucket* bucket, const base::TimeTicks& event_time) override;
229
230 private:
231 // Specifies how long exhaustion of buckets is allowed to continue before
232 // denying requests.
233 const int64 repeat_exhaustion_allowance_;
234 int64 num_available_repeat_exhaustions_;
235 };
236
237 } // namespace extensions 218 } // namespace extensions
238 219
239 #endif // EXTENSIONS_BROWSER_QUOTA_SERVICE_H_ 220 #endif // EXTENSIONS_BROWSER_QUOTA_SERVICE_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/storage/storage_api.cc ('k') | extensions/browser/quota_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698