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_
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/public/browser/appcache_service.h"
19 // This class fetches appcache information on behalf of a caller
21 class BrowsingDataAppCacheHelper
22 : public base::RefCountedThreadSafe
<BrowsingDataAppCacheHelper
> {
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();
37 friend class base::RefCountedThreadSafe
<BrowsingDataAppCacheHelper
>;
38 virtual ~BrowsingDataAppCacheHelper();
40 base::Closure completion_callback_
;
41 scoped_refptr
<content::AppCacheInfoCollection
> info_collection_
;
44 void OnFetchComplete(int rv
);
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
{
57 explicit CannedBrowsingDataAppCacheHelper(
58 content::BrowserContext
* browser_context
);
60 // Add an appcache to the set of canned caches that is returned by this
62 void AddAppCache(const GURL
& manifest_url
);
64 // Clears the list of canned caches.
67 // True if no appcaches are currently stored.
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
;
81 ~CannedBrowsingDataAppCacheHelper() override
;
83 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper
);
86 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_