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

Side by Side Diff: chrome/browser/safe_browsing/browser_feature_extractor.cc

Issue 2821193005: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/safe_browsing (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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/certificate_reporting_service.cc » ('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) 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/safe_browsing/browser_feature_extractor.h" 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 request); 238 request);
239 } 239 }
240 240
241 // The API doesn't take a std::unique_ptr because the API gets mocked and we 241 // The API doesn't take a std::unique_ptr because the API gets mocked and we
242 // cannot mock an API that takes std::unique_ptr as arguments. 242 // cannot mock an API that takes std::unique_ptr as arguments.
243 std::unique_ptr<ClientPhishingRequest> req(request); 243 std::unique_ptr<ClientPhishingRequest> req(request);
244 244
245 ExtractBrowseInfoFeatures(*info, request); 245 ExtractBrowseInfoFeatures(*info, request);
246 base::ThreadTaskRunnerHandle::Get()->PostTask( 246 base::ThreadTaskRunnerHandle::Get()->PostTask(
247 FROM_HERE, 247 FROM_HERE,
248 base::Bind(&BrowserFeatureExtractor::StartExtractFeatures, 248 base::BindOnce(&BrowserFeatureExtractor::StartExtractFeatures,
249 weak_factory_.GetWeakPtr(), base::Passed(&req), callback)); 249 weak_factory_.GetWeakPtr(), base::Passed(&req), callback));
250 } 250 }
251 251
252 void BrowserFeatureExtractor::ExtractMalwareFeatures( 252 void BrowserFeatureExtractor::ExtractMalwareFeatures(
253 BrowseInfo* info, 253 BrowseInfo* info,
254 ClientMalwareRequest* request, 254 ClientMalwareRequest* request,
255 const MalwareDoneCallback& callback) { 255 const MalwareDoneCallback& callback) {
256 DCHECK_CURRENTLY_ON(BrowserThread::UI); 256 DCHECK_CURRENTLY_ON(BrowserThread::UI);
257 DCHECK(!callback.is_null()); 257 DCHECK(!callback.is_null());
258 258
259 // Grab the IPs because they might go away before we're done 259 // Grab the IPs because they might go away before we're done
260 // checking them against the IP blacklist on the IO thread. 260 // checking them against the IP blacklist on the IO thread.
261 std::unique_ptr<IPUrlMap> ips(new IPUrlMap); 261 std::unique_ptr<IPUrlMap> ips(new IPUrlMap);
262 ips->swap(info->ips); 262 ips->swap(info->ips);
263 263
264 IPUrlMap* ips_ptr = ips.get(); 264 IPUrlMap* ips_ptr = ips.get();
265 265
266 // The API doesn't take a std::unique_ptr because the API gets mocked and we 266 // The API doesn't take a std::unique_ptr because the API gets mocked and we
267 // cannot mock an API that takes std::unique_ptr as arguments. 267 // cannot mock an API that takes std::unique_ptr as arguments.
268 std::unique_ptr<ClientMalwareRequest> req(request); 268 std::unique_ptr<ClientMalwareRequest> req(request);
269 269
270 // IP blacklist lookups have to happen on the IO thread. 270 // IP blacklist lookups have to happen on the IO thread.
271 BrowserThread::PostTaskAndReply( 271 BrowserThread::PostTaskAndReply(
272 BrowserThread::IO, 272 BrowserThread::IO, FROM_HERE,
273 FROM_HERE, 273 base::BindOnce(&FilterBenignIpsOnIOThread, host_->database_manager(),
274 base::Bind(&FilterBenignIpsOnIOThread, 274 ips_ptr),
275 host_->database_manager(), 275 base::BindOnce(&BrowserFeatureExtractor::FinishExtractMalwareFeatures,
276 ips_ptr), 276 weak_factory_.GetWeakPtr(), base::Passed(&ips), callback,
277 base::Bind(&BrowserFeatureExtractor::FinishExtractMalwareFeatures, 277 base::Passed(&req)));
278 weak_factory_.GetWeakPtr(),
279 base::Passed(&ips), callback, base::Passed(&req)));
280 } 278 }
281 279
282 void BrowserFeatureExtractor::ExtractBrowseInfoFeatures( 280 void BrowserFeatureExtractor::ExtractBrowseInfoFeatures(
283 const BrowseInfo& info, 281 const BrowseInfo& info,
284 ClientPhishingRequest* request) { 282 ClientPhishingRequest* request) {
285 if (info.unsafe_resource.get()) { 283 if (info.unsafe_resource.get()) {
286 // A SafeBrowsing interstitial was shown for the current URL. 284 // A SafeBrowsing interstitial was shown for the current URL.
287 AddFeature(features::kSafeBrowsingMaliciousUrl + 285 AddFeature(features::kSafeBrowsingMaliciousUrl +
288 info.unsafe_resource->url.spec(), 286 info.unsafe_resource->url.spec(),
289 1.0, 287 1.0,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // Limit the number of matched bad IPs in one request to control 485 // Limit the number of matched bad IPs in one request to control
488 // the request's size 486 // the request's size
489 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { 487 if (matched_bad_ips >= kMaxMalwareIPPerRequest) {
490 break; 488 break;
491 } 489 }
492 } 490 }
493 callback.Run(true, std::move(request)); 491 callback.Run(true, std::move(request));
494 } 492 }
495 493
496 } // namespace safe_browsing 494 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/certificate_reporting_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698