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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 10911151: URLRequestHttpJob::StartTransaction should honour network delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2 tests split into 6 and only 4 disabled for CF Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 transaction_.reset(); 322 transaction_.reset();
323 response_info_ = NULL; 323 response_info_ = NULL;
324 } 324 }
325 325
326 void URLRequestHttpJob::StartTransaction() { 326 void URLRequestHttpJob::StartTransaction() {
327 if (request_->context()->network_delegate()) { 327 if (request_->context()->network_delegate()) {
328 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( 328 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders(
329 request_, notify_before_headers_sent_callback_, 329 request_, notify_before_headers_sent_callback_,
330 &request_info_.extra_headers); 330 &request_info_.extra_headers);
331 // If an extension blocks the request, we rely on the callback to 331 // If an extension blocks the request, we rely on the callback to
332 // StartTransactionInternal(). 332 // MaybeStartTransactionInternal().
333 if (rv == ERR_IO_PENDING) { 333 if (rv == ERR_IO_PENDING) {
334 SetBlockedOnDelegate(); 334 SetBlockedOnDelegate();
335 return; 335 return;
336 } 336 }
337 MaybeStartTransactionInternal(rv);
338 return;
337 } 339 }
338 StartTransactionInternal(); 340 StartTransactionInternal();
339 } 341 }
340 342
341 void URLRequestHttpJob::NotifyBeforeSendHeadersCallback(int result) { 343 void URLRequestHttpJob::NotifyBeforeSendHeadersCallback(int result) {
342 SetUnblockedOnDelegate(); 344 SetUnblockedOnDelegate();
343 345
344 // Check that there are no callbacks to already canceled requests. 346 // Check that there are no callbacks to already canceled requests.
345 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); 347 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status());
346 348
349 MaybeStartTransactionInternal(result);
350 }
351
352 void URLRequestHttpJob::MaybeStartTransactionInternal(int result) {
347 if (result == OK) { 353 if (result == OK) {
348 StartTransactionInternal(); 354 StartTransactionInternal();
349 } else { 355 } else {
350 std::string source("delegate"); 356 std::string source("delegate");
351 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 357 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
352 NetLog::StringCallback("source", &source)); 358 NetLog::StringCallback("source", &source));
353 NotifyCanceled(); 359 NotifyCanceled();
360 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
354 } 361 }
355 } 362 }
356 363
357 void URLRequestHttpJob::StartTransactionInternal() { 364 void URLRequestHttpJob::StartTransactionInternal() {
358 // NOTE: This method assumes that request_info_ is already setup properly. 365 // NOTE: This method assumes that request_info_ is already setup properly.
359 366
360 // If we already have a transaction, then we should restart the transaction 367 // If we already have a transaction, then we should restart the transaction
361 // with auth provided by auth_credentials_. 368 // with auth provided by auth_credentials_.
362 369
363 int rv; 370 int rv;
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 1508
1502 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1509 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1503 awaiting_callback_ = false; 1510 awaiting_callback_ = false;
1504 } 1511 }
1505 1512
1506 void URLRequestHttpJob::OnDetachRequest() { 1513 void URLRequestHttpJob::OnDetachRequest() {
1507 http_transaction_delegate_->OnDetachRequest(); 1514 http_transaction_delegate_->OnDetachRequest();
1508 } 1515 }
1509 1516
1510 } // namespace net 1517 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698