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

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

Issue 8776024: base::Bind: Convert AppCacheService::GetAllAppCacheInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years 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
« no previous file with comments | « chrome/browser/browsing_data_appcache_helper.h ('k') | webkit/appcache/appcache_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_appcache_helper.h" 5 #include "chrome/browser/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 "chrome/browser/net/chrome_url_request_context.h" 9 #include "chrome/browser/net/chrome_url_request_context.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "webkit/appcache/appcache_database.h" 13 #include "webkit/appcache/appcache_database.h"
13 #include "webkit/appcache/appcache_storage.h" 14 #include "webkit/appcache/appcache_storage.h"
14 15
15 using appcache::AppCacheDatabase; 16 using appcache::AppCacheDatabase;
16 using content::BrowserThread; 17 using content::BrowserThread;
17 18
18 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 19 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
19 : is_fetching_(false), 20 : is_fetching_(false),
20 appcache_service_(profile->GetAppCacheService()) { 21 appcache_service_(profile->GetAppCacheService()) {
21 } 22 }
22 23
23 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 24 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
24 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 25 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
25 DCHECK(!is_fetching_); 26 DCHECK(!is_fetching_);
26 DCHECK_EQ(false, callback.is_null()); 27 DCHECK_EQ(false, callback.is_null());
27 is_fetching_ = true; 28 is_fetching_ = true;
28 info_collection_ = new appcache::AppCacheInfoCollection; 29 info_collection_ = new appcache::AppCacheInfoCollection;
29 completion_callback_ = callback; 30 completion_callback_ = callback;
30 BrowserThread::PostTask( 31 BrowserThread::PostTask(
31 BrowserThread::IO, FROM_HERE, 32 BrowserThread::IO, FROM_HERE,
32 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback)); 33 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback));
33 return; 34 return;
34 } 35 }
35 36
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
37 appcache_info_callback_ = 38 appcache_info_callback_.Reset(
38 new net::CancelableOldCompletionCallback<BrowsingDataAppCacheHelper>( 39 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete,
39 this, &BrowsingDataAppCacheHelper::OnFetchComplete); 40 base::Unretained(this)));
40 appcache_service_->GetAllAppCacheInfo(info_collection_, 41 appcache_service_->GetAllAppCacheInfo(info_collection_,
41 appcache_info_callback_); 42 appcache_info_callback_.callback());
42 } 43 }
43 44
44 void BrowsingDataAppCacheHelper::CancelNotification() { 45 void BrowsingDataAppCacheHelper::CancelNotification() {
45 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 46 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
46 completion_callback_.Reset(); 47 completion_callback_.Reset();
47 BrowserThread::PostTask( 48 BrowserThread::PostTask(
48 BrowserThread::IO, FROM_HERE, 49 BrowserThread::IO, FROM_HERE,
49 base::Bind(&BrowsingDataAppCacheHelper::CancelNotification, this)); 50 base::Bind(&BrowsingDataAppCacheHelper::CancelNotification, this));
50 return; 51 return;
51 } 52 }
52 53
53 if (appcache_info_callback_) 54 appcache_info_callback_.Cancel();
54 appcache_info_callback_.release()->Cancel();
55 } 55 }
56 56
57 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( 57 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
58 const GURL& manifest_url) { 58 const GURL& manifest_url) {
59 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 59 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
60 BrowserThread::PostTask( 60 BrowserThread::PostTask(
61 BrowserThread::IO, FROM_HERE, 61 BrowserThread::IO, FROM_HERE,
62 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this, 62 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this,
63 manifest_url)); 63 manifest_url));
64 return; 64 return;
(...skipping 10 matching lines...) Expand all
75 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 75 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
76 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 76 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
77 for (InfoByOrigin::iterator origin = origin_map.begin(); 77 for (InfoByOrigin::iterator origin = origin_map.begin();
78 origin != origin_map.end();) { 78 origin != origin_map.end();) {
79 InfoByOrigin::iterator current = origin; 79 InfoByOrigin::iterator current = origin;
80 ++origin; 80 ++origin;
81 if (current->first.SchemeIs(chrome::kExtensionScheme)) 81 if (current->first.SchemeIs(chrome::kExtensionScheme))
82 origin_map.erase(current); 82 origin_map.erase(current);
83 } 83 }
84 84
85 appcache_info_callback_ = NULL;
86 BrowserThread::PostTask( 85 BrowserThread::PostTask(
87 BrowserThread::UI, FROM_HERE, 86 BrowserThread::UI, FROM_HERE,
88 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv)); 87 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv));
89 return; 88 return;
90 } 89 }
91 90
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
93 DCHECK(is_fetching_); 92 DCHECK(is_fetching_);
94 is_fetching_ = false; 93 is_fetching_ = false;
95 if (!completion_callback_.is_null()) { 94 if (!completion_callback_.is_null()) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 bool CannedBrowsingDataAppCacheHelper::empty() const { 138 bool CannedBrowsingDataAppCacheHelper::empty() const {
140 return info_collection_->infos_by_origin.empty(); 139 return info_collection_->infos_by_origin.empty();
141 } 140 }
142 141
143 void CannedBrowsingDataAppCacheHelper::StartFetching( 142 void CannedBrowsingDataAppCacheHelper::StartFetching(
144 const base::Closure& completion_callback) { 143 const base::Closure& completion_callback) {
145 completion_callback.Run(); 144 completion_callback.Run();
146 } 145 }
147 146
148 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 147 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_appcache_helper.h ('k') | webkit/appcache/appcache_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698