Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_appcache_helper.h
blob44492073871fb8d1687abbc1eba74b2862d09cb0
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_
8 #include <map>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/public/browser/appcache_service.h"
13 #include "url/gurl.h"
15 namespace content {
16 class BrowserContext;
19 // This class fetches appcache information on behalf of a caller
20 // on the UI thread.
21 class BrowsingDataAppCacheHelper
22 : public base::RefCountedThreadSafe<BrowsingDataAppCacheHelper> {
23 public:
24 typedef std::map<GURL, content::AppCacheInfoVector> OriginAppCacheInfoMap;
26 explicit BrowsingDataAppCacheHelper(content::BrowserContext* browser_context);
28 virtual void StartFetching(const base::Closure& completion_callback);
29 virtual void DeleteAppCacheGroup(const GURL& manifest_url);
31 content::AppCacheInfoCollection* info_collection() const {
32 DCHECK(!is_fetching_);
33 return info_collection_.get();
36 protected:
37 friend class base::RefCountedThreadSafe<BrowsingDataAppCacheHelper>;
38 virtual ~BrowsingDataAppCacheHelper();
40 base::Closure completion_callback_;
41 scoped_refptr<content::AppCacheInfoCollection> info_collection_;
43 private:
44 void OnFetchComplete(int rv);
46 bool is_fetching_;
47 content::AppCacheService* appcache_service_;
49 DISALLOW_COPY_AND_ASSIGN(BrowsingDataAppCacheHelper);
52 // This class is a thin wrapper around BrowsingDataAppCacheHelper that does not
53 // fetch its information from the appcache service, but gets them passed as
54 // a parameter during construction.
55 class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper {
56 public:
57 explicit CannedBrowsingDataAppCacheHelper(
58 content::BrowserContext* browser_context);
60 // Add an appcache to the set of canned caches that is returned by this
61 // helper.
62 void AddAppCache(const GURL& manifest_url);
64 // Clears the list of canned caches.
65 void Reset();
67 // True if no appcaches are currently stored.
68 bool empty() const;
70 // Returns the number of app cache resources.
71 size_t GetAppCacheCount() const;
73 // Returns a current map with the |AppCacheInfoVector|s per origin.
74 const OriginAppCacheInfoMap& GetOriginAppCacheInfoMap() const;
76 // BrowsingDataAppCacheHelper methods.
77 void StartFetching(const base::Closure& completion_callback) override;
78 void DeleteAppCacheGroup(const GURL& manifest_url) override;
80 private:
81 ~CannedBrowsingDataAppCacheHelper() override;
83 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper);
86 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_