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_STORAGE_OBSERVER_H_ |
| 6 #define WEBKIT_BROWSER_QUOTA_STORAGE_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 storage |
| 16 // events, such as changes in quota or usage. |
| 17 class WEBKIT_STORAGE_BROWSER_EXPORT StorageObserver { |
| 18 public: |
| 19 struct WEBKIT_STORAGE_BROWSER_EXPORT Filter { |
| 20 // The storage type to monitor. This must not be kStorageTypeUnknown. |
| 21 StorageType storage_type; |
| 22 |
| 23 // The quota client to monitor. This can be kAllClientsMask to monitor the |
| 24 // aggregated quota and usage for the given storage type and origin. |
| 25 QuotaClient::ID client_id; |
| 26 |
| 27 // The origin to monitor usage for. Must be specified. |
| 28 GURL origin; |
| 29 |
| 30 Filter(); |
| 31 }; |
| 32 |
| 33 struct WEBKIT_STORAGE_BROWSER_EXPORT MonitorParams { |
| 34 // Storage types and origin to monitor. |
| 35 Filter filter; |
| 36 |
| 37 // The rate (in seconds) at which storage events will be fired. |
| 38 // Events will be fired at approximately this rate, or when a storage status |
| 39 // change has been detected, whichever is the least frequent. |
| 40 int rate; |
| 41 |
| 42 MonitorParams(); |
| 43 }; |
| 44 |
| 45 struct WEBKIT_STORAGE_BROWSER_EXPORT Event { |
| 46 // The storage types and origin monitored. |
| 47 Filter filter; |
| 48 |
| 49 // The current usage corresponding to the filter. |
| 50 int64 usage; |
| 51 |
| 52 // The quota corresponding to the filter. |
| 53 int64 quota; |
| 54 |
| 55 Event(); |
| 56 }; |
| 57 |
| 58 // Will be called when a storage event occurs. |
| 59 virtual void OnStorageEvent(const Event& event) = 0; |
| 60 |
| 61 protected: |
| 62 virtual ~StorageObserver() {} |
| 63 }; |
| 64 |
| 65 } // namespace quota |
| 66 |
| 67 #endif // WEBKIT_BROWSER_QUOTA_STORAGE_OBSERVER_H_ |
OLD | NEW |