| 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..f38c00b36af6362965b0104a12355555909e1cee
|
| --- /dev/null
|
| +++ b/chrome/browser/engagement/site_engagement_eviction_policy.h
|
| @@ -0,0 +1,87 @@
|
| +// 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 <map>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "storage/browser/quota/quota_manager.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace content {
|
| +class BrowserContext;
|
| +}
|
| +
|
| +class SiteEngagementService;
|
| +
|
| +class SiteEngagementEvictionPolicy
|
| + : public storage::TemporaryStorageEvictionPolicy {
|
| + public:
|
| + explicit SiteEngagementEvictionPolicy(
|
| + content::BrowserContext* browser_context);
|
| + virtual ~SiteEngagementEvictionPolicy();
|
| +
|
| + // Overridden from storage::TemporaryStorageEvictionPolicy:
|
| + void GetEvictionOrigin(
|
| + const std::map<GURL, int64>& usage_map,
|
| + int64 global_quota,
|
| + const storage::GetEvictionOriginCallback& callback) override;
|
| +
|
| + private:
|
| + class GetEvictionOriginTask;
|
| + friend class SiteEngagementEvictionPolicyTest;
|
| +
|
| + content::BrowserContext* browser_context_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy);
|
| +};
|
| +
|
| +// A task that calculates the next origin to evict based on usage and site
|
| +// engagement.
|
| +class SiteEngagementEvictionPolicy::GetEvictionOriginTask
|
| + : public base::RefCountedThreadSafe<
|
| + SiteEngagementEvictionPolicy::GetEvictionOriginTask> {
|
| + public:
|
| + GetEvictionOriginTask(
|
| + content::BrowserContext* browser_context,
|
| + const std::map<GURL, int64>& usage_map,
|
| + int64 global_quota,
|
| + const storage::GetEvictionOriginCallback& result_callback);
|
| +
|
| + void Start();
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<GetEvictionOriginTask>;
|
| + friend class SiteEngagementEvictionPolicyTest;
|
| +
|
| + static GURL GetSiteEngagementEvictionOriginOnUIThread(
|
| + content::BrowserContext* browser_context,
|
| + const std::map<GURL, int64>& usage_map,
|
| + int64 global_quota);
|
| +
|
| + static GURL CalculateEvictionOrigin(
|
| + SiteEngagementService* service,
|
| + const std::map<GURL, int64>& usage_map,
|
| + int64 global_quota);
|
| +
|
| + ~GetEvictionOriginTask();
|
| +
|
| + void ReplyWithEvictionOrigin(const GURL& origin_to_evict);
|
| +
|
| + const std::map<GURL, int64> usage_map_;
|
| + const int64 global_quota_;
|
| +
|
| + content::BrowserContext* browser_context_;
|
| +
|
| + // The callback to run with the next eviction origin.
|
| + storage::GetEvictionOriginCallback result_callback_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(GetEvictionOriginTask);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
|
|
|