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

Unified Diff: net/url_request/url_request.cc

Issue 7747016: Allow the NetworkDelegate to synchronously cancel a URLRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 4 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 | « no previous file | net/url_request/url_request_unittest.cc » ('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 7c94964c117cdaaa8ae092394c688ea7d8361f17..8f25db9243f4c79b823a5f0253374ea99d20b8be 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -403,11 +403,17 @@ void URLRequest::Start() {
// Only notify the delegate for the initial request.
if (context_ && context_->network_delegate()) {
- if (context_->network_delegate()->NotifyBeforeURLRequest(
- this, &before_request_callback_, &delegate_redirect_url_) ==
- net::ERR_IO_PENDING) {
- SetBlockedOnDelegate();
- return; // paused
+ int error = context_->network_delegate()->NotifyBeforeURLRequest(
+ this, &before_request_callback_, &delegate_redirect_url_);
+ if (error != net::OK) {
+ if (error == net::ERR_IO_PENDING) {
+ // Paused on the delegate, will invoke |before_request_callback_| later.
+ SetBlockedOnDelegate();
+ } else {
+ // The delegate immediately returned some error code.
+ BeforeRequestComplete(error);
+ }
+ return;
}
}
@@ -420,7 +426,8 @@ void URLRequest::BeforeRequestComplete(int error) {
DCHECK(!job_);
DCHECK_NE(ERR_IO_PENDING, error);
- SetUnblockedOnDelegate();
+ if (blocked_on_delegate_)
+ SetUnblockedOnDelegate();
if (error != OK) {
net_log_.AddEvent(NetLog::TYPE_CANCELLED,
make_scoped_refptr(new NetLogStringParameter("source", "delegate")));
« no previous file with comments | « no previous file | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698