Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_BROWSER_QUOTA_USAGE_OBSERVER_H_ | |
| 6 #define WEBKIT_BROWSER_QUOTA_USAGE_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/basic_types.h" | |
| 9 #include "url/gurl.h" | |
| 10 #include "webkit/browser/quota/quota_client.h" | |
| 11 #include "webkit/browser/quota/quota_types.h" | |
| 12 | |
| 13 namespace quota { | |
| 14 | |
| 15 // This interface is implemented by subsystems that wish to monitor the storage | |
| 16 // usage of origins. This is primarily used for origins that are granted | |
| 17 // unlimited storage. | |
| 18 class WEBKIT_STORAGE_BROWSER_EXPORT UsageObserver { | |
| 19 public: | |
| 20 struct WEBKIT_STORAGE_BROWSER_EXPORT Filter { | |
| 21 // The storage type to monitor. This must not be kStorageTypeUnknown. | |
| 22 StorageType storage_type; | |
| 23 | |
| 24 // The quota client to monitor. This can be kAllClientsMask to monitor the | |
| 25 // aggregated usage for the given storage type and origin. In this case, the | |
| 26 // threshold will apply to the accumulated total usage. | |
| 27 QuotaClient::ID client_id; | |
| 28 | |
| 29 // The origin to monitor usage for. Must be specified. | |
| 30 GURL origin; | |
| 31 | |
| 32 Filter(); | |
| 33 }; | |
| 34 | |
| 35 struct WEBKIT_STORAGE_BROWSER_EXPORT MonitorParams { | |
| 36 // Storage types and origin to monitor. | |
| 37 Filter filter; | |
| 38 | |
| 39 // When the usage exceeds this threshold, the observer will be notified. | |
| 40 int64 threshold; | |
|
tzik
2014/03/17 05:31:56
IMO, it's also desirable to get a notification on
| |
| 41 | |
| 42 // After usage has exceeded the threshold, the observer can receive further | |
| 43 // notifications when usage continues to increase. |increments| specifies | |
| 44 // when these further notifications should occur, or can be set to zero to | |
| 45 // disable them. | |
| 46 int64 increments; | |
|
tzik
2014/03/17 05:31:56
Can we start without |increments| for simpler impl
| |
| 47 | |
| 48 MonitorParams(); | |
| 49 }; | |
| 50 | |
| 51 struct WEBKIT_STORAGE_BROWSER_EXPORT Event { | |
| 52 // The storage types and origin monitored. | |
| 53 Filter filter; | |
| 54 | |
| 55 // The threshold that triggered this notification. Can be some |increment| | |
| 56 // above |threshold|. | |
| 57 int64 threshold; | |
| 58 | |
| 59 // The current usage corresponding to the filter. | |
| 60 int64 current_usage; | |
| 61 | |
| 62 Event(); | |
| 63 }; | |
| 64 | |
| 65 // Will be called when the usage exceeds a threshold set by the observer. | |
| 66 virtual void OnUsageThresholdExceeded(const Event& event) = 0; | |
| 67 | |
| 68 protected: | |
| 69 virtual ~UsageObserver() {} | |
| 70 }; | |
| 71 | |
| 72 } // namespace quota | |
| 73 | |
| 74 #endif // WEBKIT_BROWSER_QUOTA_USAGE_OBSERVER_H_ | |
| OLD | NEW |