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

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: Formatting nits 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
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..ef53cbe194582607f4f97907679ed65a1b43c8a7 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -198,6 +198,11 @@ void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request,
request->Cancel();
}
+void URLRequest::Delegate::OnBeforeNetworkStart(URLRequest* request,
+ bool* defer) {
+ *defer = false;
mmenke 2014/01/07 15:26:23 "OnReceivedRedirect" assumes defer is initialized
jkarlin 2014/01/07 16:19:32 Done.
+}
+
///////////////////////////////////////////////////////////////////////////////
// URLRequest
@@ -225,7 +230,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 +830,22 @@ void URLRequest::NotifyReceivedRedirect(const GURL& location,
}
}
+void URLRequest::NotifyBeforeNetworkStart(bool* defer) {
+ if (delegate_ && !notified_before_network_start_) {
+ notified_before_network_start_ = true;
+ OnCallToDelegate();
+ delegate_->OnBeforeNetworkStart(this, defer);
+ if (!(*defer))
mmenke 2014/01/07 15:26:23 optional nit: I think !*defer is more common in n
jkarlin 2014/01/07 16:19:32 Done.
+ OnCallToDelegateComplete();
+ }
+}
+
+void URLRequest::ResumeNetworkStart() {
+ DCHECK(job_);
mmenke 2014/01/07 15:26:23 Maybe DCHECK(notified_network_create_stream_);? I
jkarlin 2014/01/07 16:19:32 Done.
+ OnCallToDelegateComplete();
+ job_->ResumeNetworkStart();
+}
+
void URLRequest::NotifyResponseStarted() {
int net_error = OK;
if (!status_.is_success())

Powered by Google App Engine
This is Rietveld 408576698