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
;
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
);
35 friend class base::RefCountedThreadSafe
<BrowsingDataAppCacheHelper
>;
36 virtual ~BrowsingDataAppCacheHelper();
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
{
52 explicit CannedBrowsingDataAppCacheHelper(
53 content::BrowserContext
* browser_context
);
55 // Add an appcache to the set of canned caches that is returned by this
57 void AddAppCache(const GURL
& manifest_url
);
59 // Clears the list of canned caches.
62 // True if no appcaches are currently stored.
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
;
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_