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

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

Issue 8600006: Track download request time and always send back the hash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Err. Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 DownloadProtectionService* service, 333 DownloadProtectionService* service,
334 SafeBrowsingService* sb_service, 334 SafeBrowsingService* sb_service,
335 SignatureUtil* signature_util) 335 SignatureUtil* signature_util)
336 : info_(info), 336 : info_(info),
337 callback_(callback), 337 callback_(callback),
338 service_(service), 338 service_(service),
339 signature_util_(signature_util), 339 signature_util_(signature_util),
340 sb_service_(sb_service), 340 sb_service_(sb_service),
341 pingback_enabled_(service_->enabled()), 341 pingback_enabled_(service_->enabled()),
342 finished_(false), 342 finished_(false),
343 ALLOW_THIS_IN_INITIALIZER_LIST(timeout_weakptr_factory_(this)) { 343 ALLOW_THIS_IN_INITIALIZER_LIST(timeout_weakptr_factory_(this)),
344 start_time_(base::TimeTicks::Now()) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 } 346 }
346 347
347 void Start() { 348 void Start() {
348 VLOG(2) << "Starting SafeBrowsing download check for: " 349 VLOG(2) << "Starting SafeBrowsing download check for: "
349 << info_.DebugString(); 350 << info_.DebugString();
350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
351 // TODO(noelutz): implement some cache to make sure we don't issue the same 352 // TODO(noelutz): implement some cache to make sure we don't issue the same
352 // request over and over again if a user downloads the same binary multiple 353 // request over and over again if a user downloads the same binary multiple
353 // times. 354 // times.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } else if (response.verdict() == ClientDownloadResponse::DANGEROUS) { 434 } else if (response.verdict() == ClientDownloadResponse::DANGEROUS) {
434 reason = REASON_DOWNLOAD_DANGEROUS; 435 reason = REASON_DOWNLOAD_DANGEROUS;
435 result = DANGEROUS; 436 result = DANGEROUS;
436 } else { 437 } else {
437 reason = REASON_DOWNLOAD_SAFE; 438 reason = REASON_DOWNLOAD_SAFE;
438 } 439 }
439 } 440 }
440 // We don't need the fetcher anymore. 441 // We don't need the fetcher anymore.
441 fetcher_.reset(); 442 fetcher_.reset();
442 RecordImprovedProtectionStats(reason); 443 RecordImprovedProtectionStats(reason);
444 UMA_HISTOGRAM_TIMES("SBClientDownload.DownloadRequestDuration",
445 base::TimeTicks::Now() - start_time_);
443 FinishRequest(result); 446 FinishRequest(result);
444 } 447 }
445 448
446 private: 449 private:
447 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 450 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
448 friend class DeleteTask<CheckClientDownloadRequest>; 451 friend class DeleteTask<CheckClientDownloadRequest>;
449 452
450 virtual ~CheckClientDownloadRequest() { 453 virtual ~CheckClientDownloadRequest() {
451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
452 } 455 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 ClientDownloadRequest_SignatureInfo signature_info_; 613 ClientDownloadRequest_SignatureInfo signature_info_;
611 CheckDownloadCallback callback_; 614 CheckDownloadCallback callback_;
612 // Will be NULL if the request has been canceled. 615 // Will be NULL if the request has been canceled.
613 DownloadProtectionService* service_; 616 DownloadProtectionService* service_;
614 scoped_refptr<SignatureUtil> signature_util_; 617 scoped_refptr<SignatureUtil> signature_util_;
615 scoped_refptr<SafeBrowsingService> sb_service_; 618 scoped_refptr<SafeBrowsingService> sb_service_;
616 const bool pingback_enabled_; 619 const bool pingback_enabled_;
617 scoped_ptr<content::URLFetcher> fetcher_; 620 scoped_ptr<content::URLFetcher> fetcher_;
618 bool finished_; 621 bool finished_;
619 base::WeakPtrFactory<CheckClientDownloadRequest> timeout_weakptr_factory_; 622 base::WeakPtrFactory<CheckClientDownloadRequest> timeout_weakptr_factory_;
623 base::TimeTicks start_time_; // Used for stats.
620 624
621 DISALLOW_COPY_AND_ASSIGN(CheckClientDownloadRequest); 625 DISALLOW_COPY_AND_ASSIGN(CheckClientDownloadRequest);
622 }; 626 };
623 627
624 DownloadProtectionService::DownloadProtectionService( 628 DownloadProtectionService::DownloadProtectionService(
625 SafeBrowsingService* sb_service, 629 SafeBrowsingService* sb_service,
626 net::URLRequestContextGetter* request_context_getter) 630 net::URLRequestContextGetter* request_context_getter)
627 : sb_service_(sb_service), 631 : sb_service_(sb_service),
628 request_context_getter_(request_context_getter), 632 request_context_getter_(request_context_getter),
629 enabled_(false), 633 enabled_(false),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 693
690 void DownloadProtectionService::RequestFinished( 694 void DownloadProtectionService::RequestFinished(
691 CheckClientDownloadRequest* request) { 695 CheckClientDownloadRequest* request) {
692 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 696 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
693 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = 697 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it =
694 download_requests_.find(request); 698 download_requests_.find(request);
695 DCHECK(it != download_requests_.end()); 699 DCHECK(it != download_requests_.end());
696 download_requests_.erase(*it); 700 download_requests_.erase(*it);
697 } 701 }
698 } // namespace safe_browsing 702 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698