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

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

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 years, 7 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 (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/client_side_detection_service.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 FROM_HERE, 266 FROM_HERE,
267 base::Bind(&ClientSideDetectionService::StartFetchModel, 267 base::Bind(&ClientSideDetectionService::StartFetchModel,
268 weak_factory_.GetWeakPtr()), 268 weak_factory_.GetWeakPtr()),
269 base::TimeDelta::FromMilliseconds(delay_ms)); 269 base::TimeDelta::FromMilliseconds(delay_ms));
270 } 270 }
271 271
272 void ClientSideDetectionService::StartFetchModel() { 272 void ClientSideDetectionService::StartFetchModel() {
273 if (enabled_) { 273 if (enabled_) {
274 // Start fetching the model either from the cache or possibly from the 274 // Start fetching the model either from the cache or possibly from the
275 // network if the model isn't in the cache. 275 // network if the model isn't in the cache.
276 model_fetcher_.reset(net::URLFetcher::Create( 276 model_fetcher_ = net::URLFetcher::Create(0 /* ID used for testing */,
277 0 /* ID used for testing */, GURL(kClientModelUrl), 277 GURL(kClientModelUrl),
278 net::URLFetcher::GET, this)); 278 net::URLFetcher::GET, this);
279 model_fetcher_->SetRequestContext(request_context_getter_.get()); 279 model_fetcher_->SetRequestContext(request_context_getter_.get());
280 model_fetcher_->Start(); 280 model_fetcher_->Start();
281 } 281 }
282 } 282 }
283 283
284 void ClientSideDetectionService::EndFetchModel(ClientModelStatus status) { 284 void ClientSideDetectionService::EndFetchModel(ClientModelStatus status) {
285 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.ClientModelStatus", 285 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.ClientModelStatus",
286 status, 286 status,
287 MODEL_STATUS_MAX); 287 MODEL_STATUS_MAX);
288 if (status == MODEL_SUCCESS) { 288 if (status == MODEL_SUCCESS) {
(...skipping 30 matching lines...) Expand all
319 319
320 std::string request_data; 320 std::string request_data;
321 if (!request->SerializeToString(&request_data)) { 321 if (!request->SerializeToString(&request_data)) {
322 UMA_HISTOGRAM_COUNTS("SBClientPhishing.RequestNotSerialized", 1); 322 UMA_HISTOGRAM_COUNTS("SBClientPhishing.RequestNotSerialized", 1);
323 DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?"; 323 DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?";
324 if (!callback.is_null()) 324 if (!callback.is_null())
325 callback.Run(GURL(request->url()), false); 325 callback.Run(GURL(request->url()), false);
326 return; 326 return;
327 } 327 }
328 328
329 net::URLFetcher* fetcher = net::URLFetcher::Create( 329 net::URLFetcher* fetcher =
330 0 /* ID used for testing */, 330 net::URLFetcher::Create(0 /* ID used for testing */,
331 GetClientReportUrl(kClientReportPhishingUrl), 331 GetClientReportUrl(kClientReportPhishingUrl),
332 net::URLFetcher::POST, this); 332 net::URLFetcher::POST, this).release();
333 333
334 // Remember which callback and URL correspond to the current fetcher object. 334 // Remember which callback and URL correspond to the current fetcher object.
335 ClientReportInfo* info = new ClientReportInfo; 335 ClientReportInfo* info = new ClientReportInfo;
336 info->callback = callback; 336 info->callback = callback;
337 info->phishing_url = GURL(request->url()); 337 info->phishing_url = GURL(request->url());
338 client_phishing_reports_[fetcher] = info; 338 client_phishing_reports_[fetcher] = info;
339 339
340 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); 340 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE);
341 fetcher->SetRequestContext(request_context_getter_.get()); 341 fetcher->SetRequestContext(request_context_getter_.get());
342 fetcher->SetUploadData("application/octet-stream", request_data); 342 fetcher->SetUploadData("application/octet-stream", request_data);
(...skipping 17 matching lines...) Expand all
360 360
361 std::string request_data; 361 std::string request_data;
362 if (!request->SerializeToString(&request_data)) { 362 if (!request->SerializeToString(&request_data)) {
363 UpdateEnumUMAHistogram(REPORT_FAILED_SERIALIZATION); 363 UpdateEnumUMAHistogram(REPORT_FAILED_SERIALIZATION);
364 DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?"; 364 DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?";
365 if (!callback.is_null()) 365 if (!callback.is_null())
366 callback.Run(GURL(request->url()), GURL(request->url()), false); 366 callback.Run(GURL(request->url()), GURL(request->url()), false);
367 return; 367 return;
368 } 368 }
369 369
370 net::URLFetcher* fetcher = net::URLFetcher::Create( 370 net::URLFetcher* fetcher =
371 0 /* ID used for testing */, 371 net::URLFetcher::Create(0 /* ID used for testing */,
372 GetClientReportUrl(kClientReportMalwareUrl), 372 GetClientReportUrl(kClientReportMalwareUrl),
373 net::URLFetcher::POST, this); 373 net::URLFetcher::POST, this).release();
374 374
375 // Remember which callback and URL correspond to the current fetcher object. 375 // Remember which callback and URL correspond to the current fetcher object.
376 ClientMalwareReportInfo* info = new ClientMalwareReportInfo; 376 ClientMalwareReportInfo* info = new ClientMalwareReportInfo;
377 info->callback = callback; 377 info->callback = callback;
378 info->original_url = GURL(request->url()); 378 info->original_url = GURL(request->url());
379 client_malware_reports_[fetcher] = info; 379 client_malware_reports_[fetcher] = info;
380 380
381 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); 381 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE);
382 fetcher->SetRequestContext(request_context_getter_.get()); 382 fetcher->SetRequestContext(request_context_getter_.get());
383 fetcher->SetUploadData("application/octet-stream", request_data); 383 fetcher->SetUploadData("application/octet-stream", request_data);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 GURL ClientSideDetectionService::GetClientReportUrl( 635 GURL ClientSideDetectionService::GetClientReportUrl(
636 const std::string& report_url) { 636 const std::string& report_url) {
637 GURL url(report_url); 637 GURL url(report_url);
638 std::string api_key = google_apis::GetAPIKey(); 638 std::string api_key = google_apis::GetAPIKey();
639 if (!api_key.empty()) 639 if (!api_key.empty())
640 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); 640 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true));
641 641
642 return url; 642 return url;
643 } 643 }
644 } // namespace safe_browsing 644 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_downloader.cc ('k') | chrome/browser/safe_browsing/download_protection_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698