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

Unified Diff: net/url_request/test_url_fetcher_factory.cc

Issue 1212773002: Add prefetch UMA metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for CloudExternalDataManagerBaseTest.CacheCorruption. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/test_url_fetcher_factory.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/test_url_fetcher_factory.cc
diff --git a/net/url_request/test_url_fetcher_factory.cc b/net/url_request/test_url_fetcher_factory.cc
index 41259214ee1bad0600995f6b8e3e47ffc24a3efc..dfb624837b0d444a8ed90b5f695653b0ae2c1ed4 100644
--- a/net/url_request/test_url_fetcher_factory.cc
+++ b/net/url_request/test_url_fetcher_factory.cc
@@ -356,6 +356,7 @@ FakeURLFetcher::FakeURLFetcher(const GURL& url,
set_status(URLRequestStatus(status, error));
set_response_code(response_code);
SetResponseString(response_data);
+ response_bytes_ = response_data.size();
}
FakeURLFetcher::~FakeURLFetcher() {}
@@ -367,7 +368,14 @@ void FakeURLFetcher::Start() {
}
void FakeURLFetcher::RunDelegate() {
- delegate()->OnURLFetchComplete(this);
+ // OnURLFetchDownloadProgress may delete this URLFetcher. We keep track of
+ // this with a weak pointer, and only call OnURLFetchComplete if this still
+ // exists.
+ auto weak_this = weak_factory_.GetWeakPtr();
+ delegate()->OnURLFetchDownloadProgress(this, response_bytes_,
+ response_bytes_);
+ if (weak_this.get())
+ delegate()->OnURLFetchComplete(this);
}
const GURL& FakeURLFetcher::GetURL() const {
« no previous file with comments | « net/url_request/test_url_fetcher_factory.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698