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

Unified Diff: chrome/browser/engagement/site_engagement_eviction_policy.h

Issue 1221523003: Add a SiteEngagementEvictionPolicy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get_total_engagement_points
Patch Set: Created 5 years, 5 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
Index: chrome/browser/engagement/site_engagement_eviction_policy.h
diff --git a/chrome/browser/engagement/site_engagement_eviction_policy.h b/chrome/browser/engagement/site_engagement_eviction_policy.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf5c2f1c089a847cad8399dbd62b190f2ecadaae
--- /dev/null
+++ b/chrome/browser/engagement/site_engagement_eviction_policy.h
@@ -0,0 +1,49 @@
+// Copyright 2015 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 CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
+#define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
+
+#include "storage/browser/quota/quota_manager.h"
+
+class SiteEngagementService;
+
+class SiteEngagementEvictionPolicy
+ : public storage::TemporaryStorageEvictionPolicy {
+ public:
+ explicit SiteEngagementEvictionPolicy(SiteEngagementService* service);
+ virtual ~SiteEngagementEvictionPolicy();
+
+ // Returns the origin from |usage_map| to evict based on usage and site
raymes 2015/07/08 04:43:29 nit: Returns the next origin from |usage_map| to e
calamity 2015/07/10 05:05:05 Done.
+ // engagement.
+ GURL GetEvictionOriginOnUIThread(const std::map<GURL, int64>& usage_map,
+ int64 global_quota);
raymes 2015/07/08 04:43:29 nit: include gurl.h and <map>
calamity 2015/07/10 05:05:05 Done.
+
+ // Overridden from storage::TemporaryStorageEvictionPolicy:
+ void GetEvictionOrigin(
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota,
+ const storage::GetEvictionOriginCallback& callback) override;
+
+ protected:
+ // Overridden in tests.
+ virtual int GetScore(const GURL& origin);
+ virtual int GetTotalEngagementPoints();
+
+ private:
+ // Gets the quota that an origin deserves based on its site engagement.
+ int64 GetSoftQuotaForOrigin(const GURL& origin,
+ int64 global_quota,
+ int total_engagement_points);
+
+ void ReplyWithEvictionOrigin(
+ const storage::GetEvictionOriginCallback& callback,
+ const GURL& origin_to_evict);
+
+ SiteEngagementService* engagement_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy);
raymes 2015/07/08 04:43:29 base/macros.h
calamity 2015/07/10 05:05:05 Done.
+};
+
+#endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_

Powered by Google App Engine
This is Rietveld 408576698