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

Side by Side Diff: chrome/browser/engagement/site_engagement_eviction_policy.cc

Issue 1321733004: Use the site engagement eviction policy for temporary storage eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_eviction_policy
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/barrier_closure.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" 7 #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
8 #include "chrome/browser/engagement/site_engagement_service.h" 8 #include "chrome/browser/engagement/site_engagement_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/common/chrome_switches.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 13
13 namespace { 14 namespace {
14 15
15 const int kExpectedEngagementSites = 200; 16 const int kExpectedEngagementSites = 200;
16 17
17 // Gets the quota that an origin deserves based on its site engagement. 18 // Gets the quota that an origin deserves based on its site engagement.
18 int64 GetSoftQuotaForOrigin(const GURL& origin, 19 int64 GetSoftQuotaForOrigin(const GURL& origin,
19 int score, 20 int score,
20 int total_engagement_points, 21 int total_engagement_points,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 : nullptr; 81 : nullptr;
81 if (!service) 82 if (!service)
82 return GURL(); 83 return GURL();
83 84
84 return DoCalculateEvictionOrigin(special_storage_policy, service, usage_map, 85 return DoCalculateEvictionOrigin(special_storage_policy, service, usage_map,
85 global_quota); 86 global_quota);
86 } 87 }
87 88
88 } // namespace 89 } // namespace
89 90
91 // static
92 bool SiteEngagementEvictionPolicy::IsEnabled() {
93 return base::CommandLine::ForCurrentProcess()->HasSwitch(
94 switches::kEnableSiteEngagementStorageEviction);
95 }
96
90 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy( 97 SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy(
91 content::BrowserContext* browser_context) 98 content::BrowserContext* browser_context)
92 : browser_context_(browser_context) {} 99 : browser_context_(browser_context) {}
93 100
94 SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {} 101 SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {}
95 102
96 void SiteEngagementEvictionPolicy::GetEvictionOrigin( 103 void SiteEngagementEvictionPolicy::GetEvictionOrigin(
97 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, 104 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
98 const std::map<GURL, int64>& usage_map, 105 const std::map<GURL, int64>& usage_map,
99 int64 global_quota, 106 int64 global_quota,
100 const storage::GetOriginCallback& callback) { 107 const storage::GetOriginCallback& callback) {
101 content::BrowserThread::PostTaskAndReplyWithResult( 108 content::BrowserThread::PostTaskAndReplyWithResult(
102 content::BrowserThread::UI, FROM_HERE, 109 content::BrowserThread::UI, FROM_HERE,
103 base::Bind(&GetSiteEngagementEvictionOriginOnUIThread, 110 base::Bind(&GetSiteEngagementEvictionOriginOnUIThread,
104 special_storage_policy, browser_context_, usage_map, 111 special_storage_policy, browser_context_, usage_map,
105 global_quota), 112 global_quota),
106 callback); 113 callback);
107 } 114 }
108 115
109 // static 116 // static
110 GURL SiteEngagementEvictionPolicy::CalculateEvictionOrigin( 117 GURL SiteEngagementEvictionPolicy::CalculateEvictionOrigin(
111 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy, 118 const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
112 SiteEngagementScoreProvider* score_provider, 119 SiteEngagementScoreProvider* score_provider,
113 const std::map<GURL, int64>& usage_map, 120 const std::map<GURL, int64>& usage_map,
114 int64 global_quota) { 121 int64 global_quota) {
115 return DoCalculateEvictionOrigin(special_storage_policy, score_provider, 122 return DoCalculateEvictionOrigin(special_storage_policy, score_provider,
116 usage_map, global_quota); 123 usage_map, global_quota);
117 } 124 }
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_eviction_policy.h ('k') | chrome/browser/engagement/site_engagement_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698