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

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

Issue 851553003: Remove bad use of CancelableCallback from BrowingDataAppCacheHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make the callback take a ref to |this| Created 5 years, 11 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
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_appcache_helper.h ('k') | no next file » | 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) 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 "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/storage_partition.h" 12 #include "content/public/browser/storage_partition.h"
13 #include "net/base/completion_callback.h"
13 14
14 using content::BrowserContext; 15 using content::BrowserContext;
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
17 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper( 18 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(
18 BrowserContext* browser_context) 19 BrowserContext* browser_context)
19 : is_fetching_(false), 20 : is_fetching_(false),
20 appcache_service_(BrowserContext::GetDefaultStoragePartition( 21 appcache_service_(BrowserContext::GetDefaultStoragePartition(
21 browser_context)->GetAppCacheService()) { 22 browser_context)->GetAppCacheService()) {
22 } 23 }
23 24
24 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 25 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
25 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 26 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
26 DCHECK(!is_fetching_); 27 DCHECK(!is_fetching_);
27 DCHECK(!callback.is_null()); 28 DCHECK(!callback.is_null());
28 is_fetching_ = true; 29 is_fetching_ = true;
29 info_collection_ = new content::AppCacheInfoCollection; 30 info_collection_ = new content::AppCacheInfoCollection;
30 completion_callback_ = callback; 31 completion_callback_ = callback;
31 BrowserThread::PostTask( 32 BrowserThread::PostTask(
32 BrowserThread::IO, FROM_HERE, 33 BrowserThread::IO, FROM_HERE,
33 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback)); 34 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback));
34 return; 35 return;
35 } 36 }
36 37
37 DCHECK_CURRENTLY_ON(BrowserThread::IO); 38 DCHECK_CURRENTLY_ON(BrowserThread::IO);
38 appcache_info_callback_.Reset( 39 net::CompletionCallback appcache_info_callback =
39 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, 40 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this);
michaeln 2015/01/13 21:46:27 nit: its real common to put the base::Bind call in
40 base::Unretained(this)));
41 appcache_service_->GetAllAppCacheInfo(info_collection_.get(), 41 appcache_service_->GetAllAppCacheInfo(info_collection_.get(),
42 appcache_info_callback_.callback()); 42 appcache_info_callback);
43 } 43 }
44 44
45 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( 45 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
46 const GURL& manifest_url) { 46 const GURL& manifest_url) {
47 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 47 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
48 BrowserThread::PostTask( 48 BrowserThread::PostTask(
49 BrowserThread::IO, FROM_HERE, 49 BrowserThread::IO, FROM_HERE,
50 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this, 50 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this,
51 manifest_url)); 51 manifest_url));
52 return; 52 return;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 completion_callback.Run(); 140 completion_callback.Run();
141 } 141 }
142 142
143 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup( 143 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup(
144 const GURL& manifest_url) { 144 const GURL& manifest_url) {
145 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin()); 145 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin());
146 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url); 146 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url);
147 } 147 }
148 148
149 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 149 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_appcache_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698