Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_appcache_helper.h

Issue 545243002: Clean up BrowsingDataAppCacheHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:
40 friend class base::RefCountedThreadSafe<BrowsingDataAppCacheHelper>; 38 friend class base::RefCountedThreadSafe<BrowsingDataAppCacheHelper>;
41 virtual ~BrowsingDataAppCacheHelper(); 39 virtual ~BrowsingDataAppCacheHelper();
42 40
43 base::Closure completion_callback_; 41 base::Closure completion_callback_;
44 scoped_refptr<content::AppCacheInfoCollection> info_collection_; 42 scoped_refptr<content::AppCacheInfoCollection> info_collection_;
45 43
46 private: 44 private:
47 void OnFetchComplete(int rv); 45 void OnFetchComplete(int rv);
48 46
49 bool is_fetching_; 47 bool is_fetching_;
50 content::AppCacheService* appcache_service_; 48 content::AppCacheService* appcache_service_;
51 net::CancelableCompletionCallback appcache_info_callback_;
52 49
53 DISALLOW_COPY_AND_ASSIGN(BrowsingDataAppCacheHelper); 50 DISALLOW_COPY_AND_ASSIGN(BrowsingDataAppCacheHelper);
54 }; 51 };
55 52
56 // This class is a thin wrapper around BrowsingDataAppCacheHelper that does not 53 // This class is a thin wrapper around BrowsingDataAppCacheHelper that does not
57 // fetch its information from the appcache service, but gets them passed as 54 // fetch its information from the appcache service, but gets them passed as
58 // a parameter during construction. 55 // a parameter during construction.
59 class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper { 56 class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper {
60 public: 57 public:
61 explicit CannedBrowsingDataAppCacheHelper(Profile* profile); 58 explicit CannedBrowsingDataAppCacheHelper(
59 content::BrowserContext* browser_context);
62 60
63 // Return a copy of the appcache helper. Only one consumer can use the 61 // Return a copy of the appcache helper. Only one consumer can use the
64 // StartFetching method at a time, so we need to create a copy of the helper 62 // StartFetching method at a time, so we need to create a copy of the helper
65 // every time we instantiate a cookies tree model for it. 63 // every time we instantiate a cookies tree model for it.
66 CannedBrowsingDataAppCacheHelper* Clone(); 64 CannedBrowsingDataAppCacheHelper* Clone();
67 65
68 // Add an appcache to the set of canned caches that is returned by this 66 // Add an appcache to the set of canned caches that is returned by this
69 // helper. 67 // helper.
70 void AddAppCache(const GURL& manifest_url); 68 void AddAppCache(const GURL& manifest_url);
71 69
72 // Clears the list of canned caches. 70 // Clears the list of canned caches.
73 void Reset(); 71 void Reset();
74 72
75 // True if no appcaches are currently stored. 73 // True if no appcaches are currently stored.
76 bool empty() const; 74 bool empty() const;
77 75
78 // Returns the number of app cache resources. 76 // Returns the number of app cache resources.
79 size_t GetAppCacheCount() const; 77 size_t GetAppCacheCount() const;
80 78
81 // Returns a current map with the |AppCacheInfoVector|s per origin. 79 // Returns a current map with the |AppCacheInfoVector|s per origin.
82 const OriginAppCacheInfoMap& GetOriginAppCacheInfoMap() const; 80 const OriginAppCacheInfoMap& GetOriginAppCacheInfoMap() const;
83 81
84 // BrowsingDataAppCacheHelper methods. 82 // BrowsingDataAppCacheHelper methods.
85 virtual void StartFetching(const base::Closure& completion_callback) OVERRIDE; 83 virtual void StartFetching(const base::Closure& completion_callback) OVERRIDE;
86 virtual void DeleteAppCacheGroup(const GURL& manifest_url) OVERRIDE; 84 virtual void DeleteAppCacheGroup(const GURL& manifest_url) OVERRIDE;
87 85
88 private: 86 private:
89 virtual ~CannedBrowsingDataAppCacheHelper(); 87 virtual ~CannedBrowsingDataAppCacheHelper();
90 88
91 Profile* profile_; 89 content::BrowserContext* browser_context_;
92 90
93 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper); 91 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataAppCacheHelper);
94 }; 92 };
95 93
96 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_ 94 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_APPCACHE_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698