OLD | NEW |
---|---|
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, |
40 base::Unretained(this))); | 41 base::Unretained(this)); |
michaeln
2015/01/12 22:46:58
This assumes BrowsingDataAppCacheHelper can't be d
dmichael (off chromium)
2015/01/13 00:02:01
I was admittedly going with what I thought was the
| |
41 appcache_service_->GetAllAppCacheInfo(info_collection_.get(), | 42 appcache_service_->GetAllAppCacheInfo(info_collection_.get(), |
42 appcache_info_callback_.callback()); | 43 appcache_info_callback); |
43 } | 44 } |
44 | 45 |
45 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( | 46 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( |
46 const GURL& manifest_url) { | 47 const GURL& manifest_url) { |
47 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 48 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
48 BrowserThread::PostTask( | 49 BrowserThread::PostTask( |
49 BrowserThread::IO, FROM_HERE, | 50 BrowserThread::IO, FROM_HERE, |
50 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this, | 51 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this, |
51 manifest_url)); | 52 manifest_url)); |
52 return; | 53 return; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 completion_callback.Run(); | 141 completion_callback.Run(); |
141 } | 142 } |
142 | 143 |
143 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup( | 144 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup( |
144 const GURL& manifest_url) { | 145 const GURL& manifest_url) { |
145 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin()); | 146 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin()); |
146 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url); | 147 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url); |
147 } | 148 } |
148 | 149 |
149 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} | 150 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} |
OLD | NEW |