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

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

Issue 1343273003: Integrate SiteEngagementEvictionPolicy with QuotaManager. (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 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_ 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_ 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "storage/browser/quota/quota_manager.h" 14 #include "storage/browser/quota/quota_manager.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace content { 17 namespace content {
17 class BrowserContext; 18 class BrowserContext;
18 } 19 }
19 20
20 class SiteEngagementScoreProvider; 21 class SiteEngagementScoreProvider;
21 22
22 class SiteEngagementEvictionPolicy : public storage::QuotaEvictionPolicy { 23 class SiteEngagementEvictionPolicy : public storage::QuotaEvictionPolicy {
23 public: 24 public:
24 explicit SiteEngagementEvictionPolicy( 25 SiteEngagementEvictionPolicy(storage::StorageType type,
25 content::BrowserContext* browser_context); 26 storage::QuotaManager* manager,
26 virtual ~SiteEngagementEvictionPolicy(); 27 content::BrowserContext* browser_context);
28 ~SiteEngagementEvictionPolicy() override;
27 29
28 // Overridden from storage::QuotaEvictionPolicy: 30 // Overridden from storage::QuotaEvictionPolicy:
29 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>& 31 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>&
30 special_storage_policy, 32 special_storage_policy,
31 const std::map<GURL, int64>& usage_map,
32 int64 global_quota,
33 const storage::GetOriginCallback& callback) override; 33 const storage::GetOriginCallback& callback) override;
34 34
35 private: 35 private:
36 friend class SiteEngagementEvictionPolicyTest; 36 friend class SiteEngagementEvictionPolicyTest;
37 friend class SiteEngagementEvictionPolicyWithQuotaManagerTest;
38
39 static void SetSiteEngagementScoreProviderCallback(
40 base::Callback<SiteEngagementScoreProvider*(content::BrowserContext*)>
41 callback);
37 42
38 static GURL CalculateEvictionOrigin( 43 static GURL CalculateEvictionOrigin(
39 const scoped_refptr<storage::SpecialStoragePolicy>& 44 const scoped_refptr<storage::SpecialStoragePolicy>&
40 special_storage_policy, 45 special_storage_policy,
41 SiteEngagementScoreProvider* score_provider, 46 SiteEngagementScoreProvider* score_provider,
42 const std::map<GURL, int64>& usage_map, 47 const std::map<GURL, int64>& usage_map,
43 int64 global_quota); 48 int64 global_quota);
44 49
45 content::BrowserContext* browser_context_; 50 void DidGetGlobalUsage(storage::StorageType type, int64, int64);
51 void DidGetGlobalQuota(storage::QuotaStatusCode status, int64 quota);
52 void OnQuotaTasksCompleted();
53
54 const storage::StorageType type_;
55 storage::QuotaManager* const manager_;
56 content::BrowserContext* const browser_context_;
57
58 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
59 std::map<GURL, int64> usage_map_;
60 int64 global_quota_;
61
62 int remaining_tasks_;
63
64 storage::GetOriginCallback eviction_origin_callback_;
65
66 base::WeakPtrFactory<SiteEngagementEvictionPolicy> weak_factory_;
46 67
47 DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy); 68 DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy);
48 }; 69 };
49 70
50 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_ 71 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698