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

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

Issue 10878041: Remove silly uses of ResourceContext that unnecessarily violate the Law of Demeter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 80-cols Created 8 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 | 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_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/resource_context.h" 14 #include "content/public/browser/storage_partition.h"
14 #include "webkit/appcache/appcache_database.h" 15 #include "webkit/appcache/appcache_database.h"
15 #include "webkit/appcache/appcache_storage.h" 16 #include "webkit/appcache/appcache_storage.h"
16 17
17 using appcache::AppCacheDatabase; 18 using content::BrowserThread;
18 using content::BrowserContext; 19 using content::BrowserContext;
19 using content::BrowserThread;
20 using content::ResourceContext;
21 20
22 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 21 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
23 : is_fetching_(false), 22 : is_fetching_(false),
24 resource_context_(profile->GetResourceContext()) { 23 appcache_service_(BrowserContext::GetDefaultStoragePartition(profile)->
24 GetAppCacheService()) {
25 } 25 }
26 26
27 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 27 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
28 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 28 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
29 DCHECK(!is_fetching_); 29 DCHECK(!is_fetching_);
30 DCHECK_EQ(false, callback.is_null()); 30 DCHECK_EQ(false, callback.is_null());
31 is_fetching_ = true; 31 is_fetching_ = true;
32 info_collection_ = new appcache::AppCacheInfoCollection; 32 info_collection_ = new appcache::AppCacheInfoCollection;
33 completion_callback_ = callback; 33 completion_callback_ = callback;
34 BrowserThread::PostTask( 34 BrowserThread::PostTask(
35 BrowserThread::IO, FROM_HERE, 35 BrowserThread::IO, FROM_HERE,
36 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback)); 36 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback));
37 return; 37 return;
38 } 38 }
39 39
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
41 appcache_info_callback_.Reset( 41 appcache_info_callback_.Reset(
42 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, 42 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete,
43 base::Unretained(this))); 43 base::Unretained(this)));
44 ResourceContext::GetAppCacheService(resource_context_)-> 44 appcache_service_->
45 GetAllAppCacheInfo(info_collection_, appcache_info_callback_.callback()); 45 GetAllAppCacheInfo(info_collection_, appcache_info_callback_.callback());
46 } 46 }
47 47
48 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( 48 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
49 const GURL& manifest_url) { 49 const GURL& manifest_url) {
50 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 50 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
51 BrowserThread::PostTask( 51 BrowserThread::PostTask(
52 BrowserThread::IO, FROM_HERE, 52 BrowserThread::IO, FROM_HERE,
53 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this, 53 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this,
54 manifest_url)); 54 manifest_url));
55 return; 55 return;
56 } 56 }
57 57
58 ResourceContext::GetAppCacheService(resource_context_)->DeleteAppCacheGroup( 58 appcache_service_->DeleteAppCacheGroup(manifest_url,
59 manifest_url, net::CompletionCallback()); 59 net::CompletionCallback());
60 } 60 }
61 61
62 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} 62 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {}
63 63
64 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { 64 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) {
65 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 65 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
66 // Filter out appcache info entries for non-websafe schemes. Extension state 66 // Filter out appcache info entries for non-websafe schemes. Extension state
67 // and DevTools, for example, are not considered browsing data. 67 // and DevTools, for example, are not considered browsing data.
68 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 68 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
69 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 69 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 CannedBrowsingDataAppCacheHelper::GetOriginAppCacheInfoMap() const { 147 CannedBrowsingDataAppCacheHelper::GetOriginAppCacheInfoMap() const {
148 return info_collection_->infos_by_origin; 148 return info_collection_->infos_by_origin;
149 } 149 }
150 150
151 void CannedBrowsingDataAppCacheHelper::StartFetching( 151 void CannedBrowsingDataAppCacheHelper::StartFetching(
152 const base::Closure& completion_callback) { 152 const base::Closure& completion_callback) {
153 completion_callback.Run(); 153 completion_callback.Run();
154 } 154 }
155 155
156 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 156 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_appcache_helper.h ('k') | chrome/browser/extensions/data_deleter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698