| 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 // 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 21 matching lines...) Expand all Loading... |
| 32 class QuotaLimitHeuristic; | 32 class QuotaLimitHeuristic; |
| 33 class TestResetQuotaFunction; | 33 class TestResetQuotaFunction; |
| 34 | 34 |
| 35 typedef std::list<QuotaLimitHeuristic*> QuotaLimitHeuristics; | 35 typedef std::list<QuotaLimitHeuristic*> QuotaLimitHeuristics; |
| 36 | 36 |
| 37 // The QuotaService takes care that calls to certain extension | 37 // The QuotaService takes care that calls to certain extension |
| 38 // functions do not exceed predefined quotas. | 38 // functions do not exceed predefined quotas. |
| 39 // | 39 // |
| 40 // The QuotaService needs to live entirely on one thread, i.e. be created, | 40 // The QuotaService needs to live entirely on one thread, i.e. be created, |
| 41 // called and destroyed on the same thread, due to its use of a RepeatingTimer. | 41 // called and destroyed on the same thread, due to its use of a RepeatingTimer. |
| 42 // It is not a BrowserContextKeyedService because instances exist on both the UI | 42 // It is not a KeyedService because instances exist on both the UI |
| 43 // and IO threads. | 43 // and IO threads. |
| 44 class QuotaService : public base::NonThreadSafe { | 44 class QuotaService : public base::NonThreadSafe { |
| 45 public: | 45 public: |
| 46 // Some concrete heuristics (declared below) that ExtensionFunctions can | 46 // Some concrete heuristics (declared below) that ExtensionFunctions can |
| 47 // use to help the service make decisions about quota violations. | 47 // use to help the service make decisions about quota violations. |
| 48 class TimedLimit; | 48 class TimedLimit; |
| 49 class SustainedLimit; | 49 class SustainedLimit; |
| 50 | 50 |
| 51 QuotaService(); | 51 QuotaService(); |
| 52 virtual ~QuotaService(); | 52 virtual ~QuotaService(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 private: | 234 private: |
| 235 // Specifies how long exhaustion of buckets is allowed to continue before | 235 // Specifies how long exhaustion of buckets is allowed to continue before |
| 236 // denying requests. | 236 // denying requests. |
| 237 const int64 repeat_exhaustion_allowance_; | 237 const int64 repeat_exhaustion_allowance_; |
| 238 int64 num_available_repeat_exhaustions_; | 238 int64 num_available_repeat_exhaustions_; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 } // namespace extensions | 241 } // namespace extensions |
| 242 | 242 |
| 243 #endif // EXTENSIONS_BROWSER_QUOTA_SERVICE_H_ | 243 #endif // EXTENSIONS_BROWSER_QUOTA_SERVICE_H_ |
| OLD | NEW |