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

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

Issue 344493002: Move all remaining appcache-related code to content namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 | Annotate | Revision Log
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 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/browsing_data/browsing_data_helper.h" 9 #include "chrome/browser/browsing_data/browsing_data_helper.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/storage_partition.h" 14 #include "content/public/browser/storage_partition.h"
15 #include "webkit/browser/appcache/appcache_database.h"
16 #include "webkit/browser/appcache/appcache_storage.h"
17 15
18 using content::BrowserThread; 16 using content::BrowserThread;
19 using content::BrowserContext; 17 using content::BrowserContext;
20 18
21 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 19 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
22 : is_fetching_(false), 20 : is_fetching_(false),
23 appcache_service_(BrowserContext::GetDefaultStoragePartition(profile)-> 21 appcache_service_(BrowserContext::GetDefaultStoragePartition(profile)->
24 GetAppCacheService()) { 22 GetAppCacheService()) {
25 } 23 }
26 24
27 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 25 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
28 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 26 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
29 DCHECK(!is_fetching_); 27 DCHECK(!is_fetching_);
30 DCHECK_EQ(false, callback.is_null()); 28 DCHECK_EQ(false, callback.is_null());
31 is_fetching_ = true; 29 is_fetching_ = true;
32 info_collection_ = new appcache::AppCacheInfoCollection; 30 info_collection_ = new content::AppCacheInfoCollection;
33 completion_callback_ = callback; 31 completion_callback_ = callback;
34 BrowserThread::PostTask( 32 BrowserThread::PostTask(
35 BrowserThread::IO, FROM_HERE, 33 BrowserThread::IO, FROM_HERE,
36 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback)); 34 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback));
37 return; 35 return;
38 } 36 }
39 37
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
41 appcache_info_callback_.Reset( 39 appcache_info_callback_.Reset(
42 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, 40 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete,
(...skipping 15 matching lines...) Expand all
58 appcache_service_->DeleteAppCacheGroup(manifest_url, 56 appcache_service_->DeleteAppCacheGroup(manifest_url,
59 net::CompletionCallback()); 57 net::CompletionCallback());
60 } 58 }
61 59
62 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} 60 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {}
63 61
64 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { 62 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) {
65 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 63 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
66 // Filter out appcache info entries for non-websafe schemes. Extension state 64 // Filter out appcache info entries for non-websafe schemes. Extension state
67 // and DevTools, for example, are not considered browsing data. 65 // and DevTools, for example, are not considered browsing data.
68 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 66 typedef std::map<GURL, content::AppCacheInfoVector> InfoByOrigin;
69 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 67 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
70 for (InfoByOrigin::iterator origin = origin_map.begin(); 68 for (InfoByOrigin::iterator origin = origin_map.begin();
71 origin != origin_map.end();) { 69 origin != origin_map.end();) {
72 InfoByOrigin::iterator current = origin; 70 InfoByOrigin::iterator current = origin;
73 ++origin; 71 ++origin;
74 if (!BrowsingDataHelper::HasWebScheme(current->first)) 72 if (!BrowsingDataHelper::HasWebScheme(current->first))
75 origin_map.erase(current); 73 origin_map.erase(current);
76 } 74 }
77 75
78 BrowserThread::PostTask( 76 BrowserThread::PostTask(
79 BrowserThread::UI, FROM_HERE, 77 BrowserThread::UI, FROM_HERE,
80 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv)); 78 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv));
81 return; 79 return;
82 } 80 }
83 81
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
85 DCHECK(is_fetching_); 83 DCHECK(is_fetching_);
86 is_fetching_ = false; 84 is_fetching_ = false;
87 completion_callback_.Run(); 85 completion_callback_.Run();
88 completion_callback_.Reset(); 86 completion_callback_.Reset();
89 } 87 }
90 88
91 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper( 89 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper(
92 Profile* profile) 90 Profile* profile)
93 : BrowsingDataAppCacheHelper(profile), 91 : BrowsingDataAppCacheHelper(profile),
94 profile_(profile) { 92 profile_(profile) {
95 info_collection_ = new appcache::AppCacheInfoCollection; 93 info_collection_ = new content::AppCacheInfoCollection;
96 } 94 }
97 95
98 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() { 96 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() {
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
100 CannedBrowsingDataAppCacheHelper* clone = 98 CannedBrowsingDataAppCacheHelper* clone =
101 new CannedBrowsingDataAppCacheHelper(profile_); 99 new CannedBrowsingDataAppCacheHelper(profile_);
102 100
103 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin; 101 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin;
104 return clone; 102 return clone;
105 } 103 }
106 104
107 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) { 105 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
108 if (!BrowsingDataHelper::HasWebScheme(manifest_url)) 106 if (!BrowsingDataHelper::HasWebScheme(manifest_url))
109 return; // Ignore non-websafe schemes. 107 return; // Ignore non-websafe schemes.
110 108
111 OriginAppCacheInfoMap& origin_map = info_collection_->infos_by_origin; 109 OriginAppCacheInfoMap& origin_map = info_collection_->infos_by_origin;
112 appcache::AppCacheInfoVector& appcache_infos_ = 110 content::AppCacheInfoVector& appcache_infos_ =
113 origin_map[manifest_url.GetOrigin()]; 111 origin_map[manifest_url.GetOrigin()];
114 112
115 for (appcache::AppCacheInfoVector::iterator 113 for (content::AppCacheInfoVector::iterator
116 appcache = appcache_infos_.begin(); appcache != appcache_infos_.end(); 114 appcache = appcache_infos_.begin(); appcache != appcache_infos_.end();
117 ++appcache) { 115 ++appcache) {
118 if (appcache->manifest_url == manifest_url) 116 if (appcache->manifest_url == manifest_url)
119 return; 117 return;
120 } 118 }
121 119
122 appcache::AppCacheInfo info; 120 content::AppCacheInfo info;
123 info.manifest_url = manifest_url; 121 info.manifest_url = manifest_url;
124 appcache_infos_.push_back(info); 122 appcache_infos_.push_back(info);
125 } 123 }
126 124
127 void CannedBrowsingDataAppCacheHelper::Reset() { 125 void CannedBrowsingDataAppCacheHelper::Reset() {
128 info_collection_->infos_by_origin.clear(); 126 info_collection_->infos_by_origin.clear();
129 } 127 }
130 128
131 bool CannedBrowsingDataAppCacheHelper::empty() const { 129 bool CannedBrowsingDataAppCacheHelper::empty() const {
132 return info_collection_->infos_by_origin.empty(); 130 return info_collection_->infos_by_origin.empty();
(...skipping 20 matching lines...) Expand all
153 completion_callback.Run(); 151 completion_callback.Run();
154 } 152 }
155 153
156 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup( 154 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup(
157 const GURL& manifest_url) { 155 const GURL& manifest_url) {
158 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin()); 156 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin());
159 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url); 157 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url);
160 } 158 }
161 159
162 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 160 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698