Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_appcache_helper.h
blob15d17977c1b9e96365bcca8bed4be7b92f631247
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 using FetchCallback =
27 base::Callback<void(scoped_refptr<content::AppCacheInfoCollection>)>;
29 explicit BrowsingDataAppCacheHelper(content::BrowserContext* browser_context);
31 virtual void StartFetching(const FetchCallback& completion_callback);
32 virtual void DeleteAppCacheGroup(const GURL& manifest_url);
34 protected:
35 friend class base::RefCountedThreadSafe<BrowsingDataAppCacheHelper>;
36 virtual ~BrowsingDataAppCacheHelper();
38 private:
39 void StartFetchingOnIOThread(const FetchCallback& completion_callback);
40 void DeleteAppCacheGroupOnIOThread(const GURL& manifest_url);
42 content::AppCacheService* appcache_service_;
44 DISALLOW_COPY_AND_ASSIGN(BrowsingDataAppCacheHelper);
47 // This class is a thin wrapper around BrowsingDataAppCacheHelper that does not
48 // fetch its information from the appcache service, but gets them passed as
49 // a parameter during construction.
50 class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper {
51 public:
52 explicit CannedBrowsingDataAppCacheHelper(
53 content::BrowserContext* browser_context);
55 // Add an appcache to the set of canned caches that is returned by this
56 // helper.
57 void AddAppCache(const GURL& manifest_url);
59 // Clears the list of canned caches.
60 void Reset();
62 // True if no appcaches are currently stored.
63 bool empty() const;
65 // Returns the number of app cache resources.
66 size_t GetAppCacheCount() const;
68 // Returns a current map with the |AppCacheInfoVector|s per origin.
69 const OriginAppCacheInfoMap& GetOriginAppCacheInfoMap() const;
71 // BrowsingDataAppCacheHelper methods.
72 void StartFetching(const FetchCallback& completion_callback) override;
73 void DeleteAppCacheGroup(const GURL& manifest_url) override;
75 private:
76 ~CannedBrowsingDataAppCacheHelper() override;
78 scoped_refptr<content::AppCacheInfoCollection> info_collection_;
80 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper);
83 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_