| OLD | NEW |
| 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 "storage/browser/quota/quota_manager.h" | 13 #include "storage/browser/quota/quota_manager.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class SiteEngagementScoreProvider; | 20 class SiteEngagementScoreProvider; |
| 21 | 21 |
| 22 class SiteEngagementEvictionPolicy : public storage::QuotaEvictionPolicy { | 22 class SiteEngagementEvictionPolicy : public storage::QuotaEvictionPolicy { |
| 23 public: | 23 public: |
| 24 static bool IsEnabled(); |
| 25 |
| 24 explicit SiteEngagementEvictionPolicy( | 26 explicit SiteEngagementEvictionPolicy( |
| 25 content::BrowserContext* browser_context); | 27 content::BrowserContext* browser_context); |
| 26 ~SiteEngagementEvictionPolicy() override; | 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::set<GURL>& exceptions, | 33 const std::set<GURL>& exceptions, |
| 32 const std::map<GURL, int64>& usage_map, | 34 const std::map<GURL, int64>& usage_map, |
| 33 int64 global_quota, | 35 int64 global_quota, |
| 34 const storage::GetOriginCallback& callback) override; | 36 const storage::GetOriginCallback& callback) override; |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 friend class SiteEngagementEvictionPolicyTest; | 39 friend class SiteEngagementEvictionPolicyTest; |
| 38 | 40 |
| 39 static GURL CalculateEvictionOriginForTests( | 41 static GURL CalculateEvictionOriginForTests( |
| 40 const scoped_refptr<storage::SpecialStoragePolicy>& | 42 const scoped_refptr<storage::SpecialStoragePolicy>& |
| 41 special_storage_policy, | 43 special_storage_policy, |
| 42 SiteEngagementScoreProvider* score_provider, | 44 SiteEngagementScoreProvider* score_provider, |
| 43 const std::set<GURL>& exceptions, | 45 const std::set<GURL>& exceptions, |
| 44 const std::map<GURL, int64>& usage_map, | 46 const std::map<GURL, int64>& usage_map, |
| 45 int64 global_quota); | 47 int64 global_quota); |
| 46 | 48 |
| 47 content::BrowserContext* const browser_context_; | 49 content::BrowserContext* const browser_context_; |
| 48 | 50 |
| 49 DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy); | 51 DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy); |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_ | 54 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_ |
| OLD | NEW |