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

Unified Diff: net/url_request/url_request.h

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.h
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 119fbd98d097c47527988a647a6ea5506bea38a8..a1f7b534ffe857d0d0c2fb2aecef7056fb706ca9 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -274,6 +274,12 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
const SSLInfo& ssl_info,
bool fatal);
+ // Called to notify that the request must use the network to complete the
+ // request and is about to do so. This is called at most once per
+ // URLRequest, and by default does not defer. If deferred, call
+ // ResumeNetworkStart() to continue or Cancel() to cancel.
+ virtual void OnBeforeNetworkStart(URLRequest* request, bool* defer);
+
// After calling Start(), the delegate will receive an OnResponseStarted
// callback when the request has completed. If an error occurred, the
// request->status() will be set. On success, all redirects have been
@@ -622,6 +628,10 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
// response to an OnReceivedRedirect call.
void FollowDeferredRedirect();
+ // This method must be called to resume network communications that were
+ // deferred in response to an OnBeforeNetworkStart call.
+ void ResumeNetworkStart();
+
// One of the following two methods should be called in response to an
// OnAuthRequired() callback (and only then).
// SetAuth will reissue the request with the given credentials.
@@ -689,12 +699,17 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
// Called by URLRequestJob to allow interception when a redirect occurs.
void NotifyReceivedRedirect(const GURL& location, bool* defer_redirect);
+ // Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to
+ // allow deferral of network initialization.
+ void NotifyBeforeNetworkStart(bool* defer);
+
// Allow an interceptor's URLRequestJob to restart this request.
// Should only be called if the original job has not started a response.
void Restart();
private:
friend class URLRequestJob;
+ friend class URLRequestHttpJob;
// Registers a new protocol handler for the given scheme. If the scheme is
// already handled, this will overwrite the given factory. To delete the
@@ -879,6 +894,9 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
scoped_ptr<const base::debug::StackTrace> stack_trace_;
+ // Keeps track of whether or not OnNetworkCreateStream has been called yet.
+ bool notified_before_network_start_;
+
DISALLOW_COPY_AND_ASSIGN(URLRequest);
};

Powered by Google App Engine
This is Rietveld 408576698