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

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

Issue 459233002: Browsing Data Deletion: Style fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-apply comment tweaks Created 6 years, 4 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 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 using content::BrowserContext; 17 using content::BrowserContext;
18 18
19 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 19 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
20 : is_fetching_(false), 20 : is_fetching_(false),
21 appcache_service_(BrowserContext::GetDefaultStoragePartition(profile)-> 21 appcache_service_(BrowserContext::GetDefaultStoragePartition(profile)->
22 GetAppCacheService()) { 22 GetAppCacheService()) {
23 } 23 }
24 24
25 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 25 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
26 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 26 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
27 DCHECK(!is_fetching_); 27 DCHECK(!is_fetching_);
28 DCHECK_EQ(false, callback.is_null()); 28 DCHECK(!callback.is_null());
29 is_fetching_ = true; 29 is_fetching_ = true;
30 info_collection_ = new content::AppCacheInfoCollection; 30 info_collection_ = new content::AppCacheInfoCollection;
31 completion_callback_ = callback; 31 completion_callback_ = callback;
32 BrowserThread::PostTask( 32 BrowserThread::PostTask(
33 BrowserThread::IO, FROM_HERE, 33 BrowserThread::IO, FROM_HERE,
34 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback)); 34 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback));
35 return; 35 return;
36 } 36 }
37 37
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 38 DCHECK_CURRENTLY_ON(BrowserThread::IO);
39 appcache_info_callback_.Reset( 39 appcache_info_callback_.Reset(
40 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, 40 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete,
41 base::Unretained(this))); 41 base::Unretained(this)));
42 appcache_service_->GetAllAppCacheInfo(info_collection_.get(), 42 appcache_service_->GetAllAppCacheInfo(info_collection_.get(),
43 appcache_info_callback_.callback()); 43 appcache_info_callback_.callback());
44 } 44 }
45 45
46 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( 46 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
47 const GURL& manifest_url) { 47 const GURL& manifest_url) {
48 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 48 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
(...skipping 23 matching lines...) Expand all
72 if (!BrowsingDataHelper::HasWebScheme(current->first)) 72 if (!BrowsingDataHelper::HasWebScheme(current->first))
73 origin_map.erase(current); 73 origin_map.erase(current);
74 } 74 }
75 75
76 BrowserThread::PostTask( 76 BrowserThread::PostTask(
77 BrowserThread::UI, FROM_HERE, 77 BrowserThread::UI, FROM_HERE,
78 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv)); 78 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, this, rv));
79 return; 79 return;
80 } 80 }
81 81
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 82 DCHECK_CURRENTLY_ON(BrowserThread::UI);
83 DCHECK(is_fetching_); 83 DCHECK(is_fetching_);
84 is_fetching_ = false; 84 is_fetching_ = false;
85 completion_callback_.Run(); 85 completion_callback_.Run();
86 completion_callback_.Reset(); 86 completion_callback_.Reset();
87 } 87 }
88 88
89 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper( 89 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper(
90 Profile* profile) 90 Profile* profile)
91 : BrowsingDataAppCacheHelper(profile), 91 : BrowsingDataAppCacheHelper(profile),
92 profile_(profile) { 92 profile_(profile) {
93 info_collection_ = new content::AppCacheInfoCollection; 93 info_collection_ = new content::AppCacheInfoCollection;
94 } 94 }
95 95
96 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() { 96 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 97 DCHECK_CURRENTLY_ON(BrowserThread::UI);
98 CannedBrowsingDataAppCacheHelper* clone = 98 CannedBrowsingDataAppCacheHelper* clone =
99 new CannedBrowsingDataAppCacheHelper(profile_); 99 new CannedBrowsingDataAppCacheHelper(profile_);
100 100
101 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin; 101 clone->info_collection_->infos_by_origin = info_collection_->infos_by_origin;
102 return clone; 102 return clone;
103 } 103 }
104 104
105 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) { 105 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
106 if (!BrowsingDataHelper::HasWebScheme(manifest_url)) 106 if (!BrowsingDataHelper::HasWebScheme(manifest_url))
107 return; // Ignore non-websafe schemes. 107 return; // Ignore non-websafe schemes.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 completion_callback.Run(); 151 completion_callback.Run();
152 } 152 }
153 153
154 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup( 154 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup(
155 const GURL& manifest_url) { 155 const GURL& manifest_url) {
156 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin()); 156 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin());
157 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url); 157 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url);
158 } 158 }
159 159
160 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 160 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698