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

Unified Diff: webkit/browser/quota/usage_observer.h

Issue 196573024: Proposal: Provide the ability to monitor the usage of origins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/browser/quota/quota_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/quota/usage_observer.h
diff --git a/webkit/browser/quota/usage_observer.h b/webkit/browser/quota/usage_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5b8bfeb98ff09daefef8b647c1afc524c295aeb
--- /dev/null
+++ b/webkit/browser/quota/usage_observer.h
@@ -0,0 +1,74 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_BROWSER_QUOTA_USAGE_OBSERVER_H_
+#define WEBKIT_BROWSER_QUOTA_USAGE_OBSERVER_H_
+
+#include "base/basic_types.h"
+#include "url/gurl.h"
+#include "webkit/browser/quota/quota_client.h"
+#include "webkit/browser/quota/quota_types.h"
+
+namespace quota {
+
+// This interface is implemented by subsystems that wish to monitor the storage
+// usage of origins. This is primarily used for origins that are granted
+// unlimited storage.
+class WEBKIT_STORAGE_BROWSER_EXPORT UsageObserver {
+ public:
+ struct WEBKIT_STORAGE_BROWSER_EXPORT Filter {
+ // The storage type to monitor. This must not be kStorageTypeUnknown.
+ StorageType storage_type;
+
+ // The quota client to monitor. This can be kAllClientsMask to monitor the
+ // aggregated usage for the given storage type and origin. In this case, the
+ // threshold will apply to the accumulated total usage.
+ QuotaClient::ID client_id;
+
+ // The origin to monitor usage for. Must be specified.
+ GURL origin;
+
+ Filter();
+ };
+
+ struct WEBKIT_STORAGE_BROWSER_EXPORT MonitorParams {
+ // Storage types and origin to monitor.
+ Filter filter;
+
+ // When the usage exceeds this threshold, the observer will be notified.
+ int64 threshold;
tzik 2014/03/17 05:31:56 IMO, it's also desirable to get a notification on
+
+ // After usage has exceeded the threshold, the observer can receive further
+ // notifications when usage continues to increase. |increments| specifies
+ // when these further notifications should occur, or can be set to zero to
+ // disable them.
+ int64 increments;
tzik 2014/03/17 05:31:56 Can we start without |increments| for simpler impl
+
+ MonitorParams();
+ };
+
+ struct WEBKIT_STORAGE_BROWSER_EXPORT Event {
+ // The storage types and origin monitored.
+ Filter filter;
+
+ // The threshold that triggered this notification. Can be some |increment|
+ // above |threshold|.
+ int64 threshold;
+
+ // The current usage corresponding to the filter.
+ int64 current_usage;
+
+ Event();
+ };
+
+ // Will be called when the usage exceeds a threshold set by the observer.
+ virtual void OnUsageThresholdExceeded(const Event& event) = 0;
+
+ protected:
+ virtual ~UsageObserver() {}
+};
+
+} // namespace quota
+
+#endif // WEBKIT_BROWSER_QUOTA_USAGE_OBSERVER_H_
« no previous file with comments | « webkit/browser/quota/quota_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698