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_STORAGE_OBSERVER_H_ | |
| 6 #define WEBKIT_BROWSER_QUOTA_STORAGE_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "url/gurl.h" | |
| 10 #include "webkit/browser/quota/quota_client.h" | |
| 11 #include "webkit/common/quota/quota_types.h" | |
| 12 | |
| 13 namespace quota { | |
| 14 | |
| 15 // This interface is implemented by observers 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 or | |
| 21 // kStorageTypeQuotaNotManaged. | |
| 22 StorageType storage_type; | |
| 23 | |
| 24 // The origin to monitor usage for. Must be specified. | |
| 25 GURL origin; | |
| 26 | |
| 27 Filter(); | |
| 28 Filter(StorageType storage_type, const GURL& origin); | |
| 29 bool operator==(const Filter& other) const; | |
| 30 }; | |
| 31 | |
| 32 struct WEBKIT_STORAGE_BROWSER_EXPORT MonitorParams { | |
| 33 // Storage type and origin to monitor. | |
| 34 Filter filter; | |
| 35 | |
| 36 // The rate (in seconds) at which storage events will be fired. | |
| 37 // Events will be fired at approximately this rate, or when a storage status | |
| 38 // change has been detected, whichever is the least frequent. | |
| 39 int rate; | |
|
tzik
2014/03/31 06:54:16
Could you change this to TimeDelta?
| |
| 40 | |
| 41 // If set to true, the observer will be dispatched an event when added. | |
| 42 bool dispatch_initial_state; | |
| 43 | |
| 44 MonitorParams(); | |
| 45 MonitorParams(StorageType storage_type, | |
| 46 const GURL& origin, | |
| 47 int rate, | |
| 48 bool get_initial_state); | |
| 49 MonitorParams(const Filter& filter, | |
| 50 int rate, | |
| 51 bool get_initial_state); | |
| 52 }; | |
| 53 | |
| 54 struct WEBKIT_STORAGE_BROWSER_EXPORT Event { | |
| 55 // The storage type and origin monitored. | |
| 56 Filter filter; | |
| 57 | |
| 58 // The current usage corresponding to the filter. | |
| 59 int64 usage; | |
| 60 | |
| 61 // The quota corresponding to the filter. | |
| 62 int64 quota; | |
| 63 | |
| 64 Event(); | |
| 65 Event(const Filter& filter, int64 usage, int64 quota); | |
| 66 bool operator==(const Event& other) const; | |
| 67 }; | |
| 68 | |
| 69 // Will be called on the IO thread when a storage event occurs. | |
| 70 virtual void OnStorageEvent(const Event& event) = 0; | |
| 71 | |
| 72 protected: | |
| 73 virtual ~StorageObserver() {} | |
| 74 }; | |
| 75 | |
| 76 } // namespace quota | |
| 77 | |
| 78 #endif // WEBKIT_BROWSER_QUOTA_STORAGE_OBSERVER_H_ | |
| OLD | NEW |