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

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

Issue 2826783003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/browsing_data (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/site_data_counting_helper.h" 5 #include "chrome/browser/browsing_data/site_data_counting_helper.h"
6 6
7 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" 7 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
8 #include "chrome/browser/browsing_data/browsing_data_helper.h" 8 #include "chrome/browser/browsing_data/browsing_data_helper.h"
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( 43 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy(
44 profile_->GetSpecialStoragePolicy()); 44 profile_->GetSpecialStoragePolicy());
45 45
46 net::URLRequestContextGetter* rq_context = partition->GetURLRequestContext(); 46 net::URLRequestContextGetter* rq_context = partition->GetURLRequestContext();
47 47
48 tasks_ += 1; 48 tasks_ += 1;
49 // Count origins with cookies. 49 // Count origins with cookies.
50 BrowserThread::PostTask( 50 BrowserThread::PostTask(
51 BrowserThread::IO, FROM_HERE, 51 BrowserThread::IO, FROM_HERE,
52 base::Bind(&SiteDataCountingHelper::GetCookiesOnIOThread, 52 base::BindOnce(&SiteDataCountingHelper::GetCookiesOnIOThread,
53 base::Unretained(this), make_scoped_refptr(rq_context))); 53 base::Unretained(this), make_scoped_refptr(rq_context)));
54 54
55 storage::QuotaManager* quota_manager = partition->GetQuotaManager(); 55 storage::QuotaManager* quota_manager = partition->GetQuotaManager();
56 if (quota_manager) { 56 if (quota_manager) {
57 // Count origins with filesystem, websql, appcache, indexeddb, 57 // Count origins with filesystem, websql, appcache, indexeddb,
58 // serviceworkers and cachestorage using quota manager. 58 // serviceworkers and cachestorage using quota manager.
59 storage::GetOriginsCallback origins_callback = 59 storage::GetOriginsCallback origins_callback =
60 base::Bind(&SiteDataCountingHelper::GetQuotaOriginsCallback, 60 base::Bind(&SiteDataCountingHelper::GetQuotaOriginsCallback,
61 base::Unretained(this)); 61 base::Unretained(this));
62 const storage::StorageType types[] = {storage::kStorageTypeTemporary, 62 const storage::StorageType types[] = {storage::kStorageTypeTemporary,
63 storage::kStorageTypePersistent, 63 storage::kStorageTypePersistent,
64 storage::kStorageTypeSyncable}; 64 storage::kStorageTypeSyncable};
65 for (auto type : types) { 65 for (auto type : types) {
66 tasks_ += 1; 66 tasks_ += 1;
67 BrowserThread::PostTask( 67 BrowserThread::PostTask(
68 BrowserThread::IO, FROM_HERE, 68 BrowserThread::IO, FROM_HERE,
69 base::Bind(&storage::QuotaManager::GetOriginsModifiedSince, 69 base::BindOnce(&storage::QuotaManager::GetOriginsModifiedSince,
70 quota_manager, type, begin_, origins_callback)); 70 quota_manager, type, begin_, origins_callback));
71 } 71 }
72 } 72 }
73 73
74 // Count origins with local storage or session storage. 74 // Count origins with local storage or session storage.
75 content::DOMStorageContext* dom_storage = partition->GetDOMStorageContext(); 75 content::DOMStorageContext* dom_storage = partition->GetDOMStorageContext();
76 if (dom_storage) { 76 if (dom_storage) {
77 tasks_ += 1; 77 tasks_ += 1;
78 auto local_callback = 78 auto local_callback =
79 base::Bind(&SiteDataCountingHelper::GetLocalStorageUsageInfoCallback, 79 base::Bind(&SiteDataCountingHelper::GetLocalStorageUsageInfoCallback,
80 base::Unretained(this), special_storage_policy); 80 base::Unretained(this), special_storage_policy);
(...skipping 22 matching lines...) Expand all
103 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, 103 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE,
104 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, CONTENT_SETTINGS_TYPE_APP_BANNER}; 104 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, CONTENT_SETTINGS_TYPE_APP_BANNER};
105 for (auto type : content_settings) { 105 for (auto type : content_settings) {
106 tasks_ += 1; 106 tasks_ += 1;
107 GetOriginsFromHostContentSettignsMap(hcsm, type); 107 GetOriginsFromHostContentSettignsMap(hcsm, type);
108 } 108 }
109 // Count origins with channel ids. 109 // Count origins with channel ids.
110 tasks_ += 1; 110 tasks_ += 1;
111 BrowserThread::PostTask( 111 BrowserThread::PostTask(
112 BrowserThread::IO, FROM_HERE, 112 BrowserThread::IO, FROM_HERE,
113 base::Bind(&SiteDataCountingHelper::GetChannelIDsOnIOThread, 113 base::BindOnce(&SiteDataCountingHelper::GetChannelIDsOnIOThread,
114 base::Unretained(this), make_scoped_refptr(rq_context))); 114 base::Unretained(this), make_scoped_refptr(rq_context)));
115 } 115 }
116 116
117 void SiteDataCountingHelper::GetOriginsFromHostContentSettignsMap( 117 void SiteDataCountingHelper::GetOriginsFromHostContentSettignsMap(
118 HostContentSettingsMap* hcsm, 118 HostContentSettingsMap* hcsm,
119 ContentSettingsType type) { 119 ContentSettingsType type) {
120 std::set<GURL> origins; 120 std::set<GURL> origins;
121 ContentSettingsForOneType settings; 121 ContentSettingsForOneType settings;
122 hcsm->GetSettingsForOneType(type, std::string(), &settings); 122 hcsm->GetSettingsForOneType(type, std::string(), &settings);
123 for (const ContentSettingPatternSource& rule : settings) { 123 for (const ContentSettingPatternSource& rule : settings) {
124 GURL url(rule.primary_pattern.ToString()); 124 GURL url(rule.primary_pattern.ToString());
(...skipping 10 matching lines...) Expand all
135 135
136 net::CookieStore* cookie_store = 136 net::CookieStore* cookie_store =
137 rq_context->GetURLRequestContext()->cookie_store(); 137 rq_context->GetURLRequestContext()->cookie_store();
138 138
139 if (cookie_store) { 139 if (cookie_store) {
140 cookie_store->GetAllCookiesAsync(base::Bind( 140 cookie_store->GetAllCookiesAsync(base::Bind(
141 &SiteDataCountingHelper::GetCookiesCallback, base::Unretained(this))); 141 &SiteDataCountingHelper::GetCookiesCallback, base::Unretained(this)));
142 } else { 142 } else {
143 BrowserThread::PostTask( 143 BrowserThread::PostTask(
144 BrowserThread::UI, FROM_HERE, 144 BrowserThread::UI, FROM_HERE,
145 base::Bind(&SiteDataCountingHelper::Done, base::Unretained(this), 145 base::BindOnce(&SiteDataCountingHelper::Done, base::Unretained(this),
146 std::vector<GURL>())); 146 std::vector<GURL>()));
147 } 147 }
148 } 148 }
149 149
150 void SiteDataCountingHelper::GetCookiesCallback( 150 void SiteDataCountingHelper::GetCookiesCallback(
151 const net::CookieList& cookies) { 151 const net::CookieList& cookies) {
152 DCHECK_CURRENTLY_ON(BrowserThread::IO); 152 DCHECK_CURRENTLY_ON(BrowserThread::IO);
153 std::vector<GURL> origins; 153 std::vector<GURL> origins;
154 for (const net::CanonicalCookie& cookie : cookies) { 154 for (const net::CanonicalCookie& cookie : cookies) {
155 if (cookie.CreationDate() >= begin_) { 155 if (cookie.CreationDate() >= begin_) {
156 GURL url = net::cookie_util::CookieOriginToURL(cookie.Domain(), 156 GURL url = net::cookie_util::CookieOriginToURL(cookie.Domain(),
157 cookie.IsSecure()); 157 cookie.IsSecure());
158 origins.push_back(url); 158 origins.push_back(url);
159 } 159 }
160 } 160 }
161 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 161 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
162 base::Bind(&SiteDataCountingHelper::Done, 162 base::BindOnce(&SiteDataCountingHelper::Done,
163 base::Unretained(this), origins)); 163 base::Unretained(this), origins));
164 } 164 }
165 165
166 void SiteDataCountingHelper::GetQuotaOriginsCallback( 166 void SiteDataCountingHelper::GetQuotaOriginsCallback(
167 const std::set<GURL>& origin_set, 167 const std::set<GURL>& origin_set,
168 storage::StorageType type) { 168 storage::StorageType type) {
169 DCHECK_CURRENTLY_ON(BrowserThread::IO); 169 DCHECK_CURRENTLY_ON(BrowserThread::IO);
170 std::vector<GURL> origins(origin_set.begin(), origin_set.end()); 170 std::vector<GURL> origins(origin_set.begin(), origin_set.end());
171 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 171 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
172 base::Bind(&SiteDataCountingHelper::Done, 172 base::BindOnce(&SiteDataCountingHelper::Done,
173 base::Unretained(this), origins)); 173 base::Unretained(this), origins));
174 } 174 }
175 175
176 void SiteDataCountingHelper::GetLocalStorageUsageInfoCallback( 176 void SiteDataCountingHelper::GetLocalStorageUsageInfoCallback(
177 const scoped_refptr<storage::SpecialStoragePolicy>& policy, 177 const scoped_refptr<storage::SpecialStoragePolicy>& policy,
178 const std::vector<content::LocalStorageUsageInfo>& infos) { 178 const std::vector<content::LocalStorageUsageInfo>& infos) {
179 std::vector<GURL> origins; 179 std::vector<GURL> origins;
180 for (const auto& info : infos) { 180 for (const auto& info : infos) {
181 if (info.last_modified >= begin_ && 181 if (info.last_modified >= begin_ &&
182 (!policy || !policy->IsStorageProtected(info.origin))) { 182 (!policy || !policy->IsStorageProtected(info.origin))) {
183 origins.push_back(info.origin); 183 origins.push_back(info.origin);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const net::ChannelIDStore::ChannelIDList& channel_ids) { 221 const net::ChannelIDStore::ChannelIDList& channel_ids) {
222 std::vector<GURL> origins; 222 std::vector<GURL> origins;
223 for (const net::ChannelIDStore::ChannelID& channel_id : channel_ids) { 223 for (const net::ChannelIDStore::ChannelID& channel_id : channel_ids) {
224 if (channel_id.creation_time() >= begin_) { 224 if (channel_id.creation_time() >= begin_) {
225 // Assume url is https://<server_identifier> on default port because 225 // Assume url is https://<server_identifier> on default port because
226 // channel ids don't know about their scheme or port. 226 // channel ids don't know about their scheme or port.
227 origins.push_back(GURL("https://" + channel_id.server_identifier())); 227 origins.push_back(GURL("https://" + channel_id.server_identifier()));
228 } 228 }
229 } 229 }
230 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 230 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
231 base::Bind(&SiteDataCountingHelper::Done, 231 base::BindOnce(&SiteDataCountingHelper::Done,
232 base::Unretained(this), origins)); 232 base::Unretained(this), origins));
233 } 233 }
234 234
235 void SiteDataCountingHelper::Done(const std::vector<GURL>& origins) { 235 void SiteDataCountingHelper::Done(const std::vector<GURL>& origins) {
236 DCHECK_CURRENTLY_ON(BrowserThread::UI); 236 DCHECK_CURRENTLY_ON(BrowserThread::UI);
237 DCHECK(tasks_ > 0); 237 DCHECK(tasks_ > 0);
238 for (const GURL& origin : origins) { 238 for (const GURL& origin : origins) {
239 unique_origins_.insert(origin); 239 unique_origins_.insert(origin);
240 } 240 }
241 if (--tasks_ > 0) 241 if (--tasks_ > 0)
242 return; 242 return;
243 base::ThreadTaskRunnerHandle::Get()->PostTask( 243 base::ThreadTaskRunnerHandle::Get()->PostTask(
244 FROM_HERE, base::Bind(completion_callback_, unique_origins_.size())); 244 FROM_HERE, base::BindOnce(completion_callback_, unique_origins_.size()));
245 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 245 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
246 } 246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698