OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "content/public/browser/appcache_service.h" | 12 #include "content/public/browser/appcache_service.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 class Profile; | |
17 | |
18 namespace content { | 16 namespace content { |
19 class AppCacheService; | 17 class BrowserContext; |
20 } | 18 } |
21 | 19 |
22 // This class fetches appcache information on behalf of a caller | 20 // This class fetches appcache information on behalf of a caller |
23 // on the UI thread. | 21 // on the UI thread. |
24 class BrowsingDataAppCacheHelper | 22 class BrowsingDataAppCacheHelper |
25 : public base::RefCountedThreadSafe<BrowsingDataAppCacheHelper> { | 23 : public base::RefCountedThreadSafe<BrowsingDataAppCacheHelper> { |
26 public: | 24 public: |
27 typedef std::map<GURL, content::AppCacheInfoVector> OriginAppCacheInfoMap; | 25 typedef std::map<GURL, content::AppCacheInfoVector> OriginAppCacheInfoMap; |
28 | 26 |
29 explicit BrowsingDataAppCacheHelper(Profile* profile); | 27 explicit BrowsingDataAppCacheHelper(content::BrowserContext* browser_context); |
30 | 28 |
31 virtual void StartFetching(const base::Closure& completion_callback); | 29 virtual void StartFetching(const base::Closure& completion_callback); |
32 virtual void DeleteAppCacheGroup(const GURL& manifest_url); | 30 virtual void DeleteAppCacheGroup(const GURL& manifest_url); |
33 | 31 |
34 content::AppCacheInfoCollection* info_collection() const { | 32 content::AppCacheInfoCollection* info_collection() const { |
35 DCHECK(!is_fetching_); | 33 DCHECK(!is_fetching_); |
36 return info_collection_.get(); | 34 return info_collection_.get(); |
37 } | 35 } |
38 | 36 |
39 protected: | 37 protected: |
(...skipping 11 matching lines...) Expand all Loading... |
51 net::CancelableCompletionCallback appcache_info_callback_; | 49 net::CancelableCompletionCallback appcache_info_callback_; |
52 | 50 |
53 DISALLOW_COPY_AND_ASSIGN(BrowsingDataAppCacheHelper); | 51 DISALLOW_COPY_AND_ASSIGN(BrowsingDataAppCacheHelper); |
54 }; | 52 }; |
55 | 53 |
56 // This class is a thin wrapper around BrowsingDataAppCacheHelper that does not | 54 // This class is a thin wrapper around BrowsingDataAppCacheHelper that does not |
57 // fetch its information from the appcache service, but gets them passed as | 55 // fetch its information from the appcache service, but gets them passed as |
58 // a parameter during construction. | 56 // a parameter during construction. |
59 class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper { | 57 class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper { |
60 public: | 58 public: |
61 explicit CannedBrowsingDataAppCacheHelper(Profile* profile); | 59 explicit CannedBrowsingDataAppCacheHelper( |
| 60 content::BrowserContext* browser_context); |
62 | 61 |
63 // Add an appcache to the set of canned caches that is returned by this | 62 // Add an appcache to the set of canned caches that is returned by this |
64 // helper. | 63 // helper. |
65 void AddAppCache(const GURL& manifest_url); | 64 void AddAppCache(const GURL& manifest_url); |
66 | 65 |
67 // Clears the list of canned caches. | 66 // Clears the list of canned caches. |
68 void Reset(); | 67 void Reset(); |
69 | 68 |
70 // True if no appcaches are currently stored. | 69 // True if no appcaches are currently stored. |
71 bool empty() const; | 70 bool empty() const; |
72 | 71 |
73 // Returns the number of app cache resources. | 72 // Returns the number of app cache resources. |
74 size_t GetAppCacheCount() const; | 73 size_t GetAppCacheCount() const; |
75 | 74 |
76 // Returns a current map with the |AppCacheInfoVector|s per origin. | 75 // Returns a current map with the |AppCacheInfoVector|s per origin. |
77 const OriginAppCacheInfoMap& GetOriginAppCacheInfoMap() const; | 76 const OriginAppCacheInfoMap& GetOriginAppCacheInfoMap() const; |
78 | 77 |
79 // BrowsingDataAppCacheHelper methods. | 78 // BrowsingDataAppCacheHelper methods. |
80 virtual void StartFetching(const base::Closure& completion_callback) OVERRIDE; | 79 virtual void StartFetching(const base::Closure& completion_callback) OVERRIDE; |
81 virtual void DeleteAppCacheGroup(const GURL& manifest_url) OVERRIDE; | 80 virtual void DeleteAppCacheGroup(const GURL& manifest_url) OVERRIDE; |
82 | 81 |
83 private: | 82 private: |
84 virtual ~CannedBrowsingDataAppCacheHelper(); | 83 virtual ~CannedBrowsingDataAppCacheHelper(); |
85 | 84 |
86 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper); | 85 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper); |
87 }; | 86 }; |
88 | 87 |
89 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ | 88 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ |
OLD | NEW |