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

Unified Diff: net/url_request/url_request.cc

Issue 122453002: Allows deferral of a URLRequest just before talking to the network, at (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated content-length in test to actual length Created 6 years, 11 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/url_request.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request.cc
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index ce267302ee1bd90116606062f2c7695ff537fd4d..54fd28d2058d6bb27577d8a441150a30f9f7e02f 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -198,6 +198,10 @@ void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request,
request->Cancel();
}
+void URLRequest::Delegate::OnBeforeNetworkStart(URLRequest* request,
+ bool* defer) {
+}
+
///////////////////////////////////////////////////////////////////////////////
// URLRequest
@@ -225,7 +229,8 @@ URLRequest::URLRequest(const GURL& url,
base::Unretained(this))),
has_notified_completion_(false),
received_response_content_length_(0),
- creation_time_(base::TimeTicks::Now()) {
+ creation_time_(base::TimeTicks::Now()),
+ notified_before_network_start_(false) {
SIMPLE_STATS_COUNTER("URLRequestCount");
// Sanity check out environment.
@@ -824,6 +829,24 @@ void URLRequest::NotifyReceivedRedirect(const GURL& location,
}
}
+void URLRequest::NotifyBeforeNetworkStart(bool* defer) {
+ if (delegate_ && !notified_before_network_start_) {
+ OnCallToDelegate();
+ delegate_->OnBeforeNetworkStart(this, defer);
+ if (!*defer)
+ OnCallToDelegateComplete();
+ notified_before_network_start_ = true;
+ }
+}
+
+void URLRequest::ResumeNetworkStart() {
+ DCHECK(job_);
+ DCHECK(notified_before_network_start_);
+
+ OnCallToDelegateComplete();
+ job_->ResumeNetworkStart();
+}
+
void URLRequest::NotifyResponseStarted() {
int net_error = OK;
if (!status_.is_success())
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698