Commit 54159b2b authored by noelutz@google.com's avatar noelutz@google.com

Track how long a typical SafeBrowsing download protection request takes.

This histogram will also tell us how often the server response got back
too late and the timeout was reached.

This CL also makes sure we always send back the file hash if the
enhanced download protection is enabled.

BUG=NONE
TEST=Run all unit-tests under DownloadProtectionServiceTest.

Review URL: http://codereview.chromium.org/8600006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110801 0039d316-1c4b-4281-b951-d872f2087c98
parent 85f74043
...@@ -340,7 +340,8 @@ class DownloadProtectionService::CheckClientDownloadRequest ...@@ -340,7 +340,8 @@ class DownloadProtectionService::CheckClientDownloadRequest
sb_service_(sb_service), sb_service_(sb_service),
pingback_enabled_(service_->enabled()), pingback_enabled_(service_->enabled()),
finished_(false), finished_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(timeout_weakptr_factory_(this)) { ALLOW_THIS_IN_INITIALIZER_LIST(timeout_weakptr_factory_(this)),
start_time_(base::TimeTicks::Now()) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
} }
...@@ -440,6 +441,8 @@ class DownloadProtectionService::CheckClientDownloadRequest ...@@ -440,6 +441,8 @@ class DownloadProtectionService::CheckClientDownloadRequest
// We don't need the fetcher anymore. // We don't need the fetcher anymore.
fetcher_.reset(); fetcher_.reset();
RecordImprovedProtectionStats(reason); RecordImprovedProtectionStats(reason);
UMA_HISTOGRAM_TIMES("SBClientDownload.DownloadRequestDuration",
base::TimeTicks::Now() - start_time_);
FinishRequest(result); FinishRequest(result);
} }
...@@ -617,6 +620,7 @@ class DownloadProtectionService::CheckClientDownloadRequest ...@@ -617,6 +620,7 @@ class DownloadProtectionService::CheckClientDownloadRequest
scoped_ptr<content::URLFetcher> fetcher_; scoped_ptr<content::URLFetcher> fetcher_;
bool finished_; bool finished_;
base::WeakPtrFactory<CheckClientDownloadRequest> timeout_weakptr_factory_; base::WeakPtrFactory<CheckClientDownloadRequest> timeout_weakptr_factory_;
base::TimeTicks start_time_; // Used for stats.
DISALLOW_COPY_AND_ASSIGN(CheckClientDownloadRequest); DISALLOW_COPY_AND_ASSIGN(CheckClientDownloadRequest);
}; };
......
...@@ -240,7 +240,9 @@ bool SafeBrowsingService::CanReportStats() const { ...@@ -240,7 +240,9 @@ bool SafeBrowsingService::CanReportStats() const {
// Binhash verification is only enabled for UMA users for now. // Binhash verification is only enabled for UMA users for now.
bool SafeBrowsingService::DownloadBinHashNeeded() const { bool SafeBrowsingService::DownloadBinHashNeeded() const {
return enable_download_protection_ && CanReportStats(); return (enable_download_protection_ && CanReportStats()) ||
(download_protection_service() &&
download_protection_service()->enabled());
} }
bool SafeBrowsingService::CheckDownloadUrl(const std::vector<GURL>& url_chain, bool SafeBrowsingService::CheckDownloadUrl(const std::vector<GURL>& url_chain,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment