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

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

Issue 12328072: Remove some calls to URLRequestContext::network_delegate(). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 7 years, 10 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 URLRequestHttpJob* job_; 75 URLRequestHttpJob* job_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(HttpFilterContext); 77 DISALLOW_COPY_AND_ASSIGN(HttpFilterContext);
78 }; 78 };
79 79
80 class URLRequestHttpJob::HttpTransactionDelegateImpl 80 class URLRequestHttpJob::HttpTransactionDelegateImpl
81 : public HttpTransactionDelegate { 81 : public HttpTransactionDelegate {
82 public: 82 public:
83 explicit HttpTransactionDelegateImpl(URLRequest* request) 83 explicit HttpTransactionDelegateImpl(URLRequest* request)
84 : request_(request), 84 : request_(request),
85 network_delegate_(request->context()->network_delegate()), 85 network_delegate_(request->network_delegate()),
erikwright (departed) 2013/02/25 15:07:23 In the various job implementations, the change sho
86 cache_active_(false), 86 cache_active_(false),
87 network_active_(false) { 87 network_active_(false) {
88 } 88 }
89 virtual ~HttpTransactionDelegateImpl() { 89 virtual ~HttpTransactionDelegateImpl() {
90 OnDetachRequest(); 90 OnDetachRequest();
91 } 91 }
92 void OnDetachRequest() { 92 void OnDetachRequest() {
93 if (request_ == NULL || network_delegate_ == NULL) 93 if (request_ == NULL || network_delegate_ == NULL)
94 return; 94 return;
95 network_delegate_->NotifyRequestWaitStateChange( 95 network_delegate_->NotifyRequestWaitStateChange(
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 void URLRequestHttpJob::DestroyTransaction() { 329 void URLRequestHttpJob::DestroyTransaction() {
330 DCHECK(transaction_.get()); 330 DCHECK(transaction_.get());
331 331
332 DoneWithRequest(ABORTED); 332 DoneWithRequest(ABORTED);
333 transaction_.reset(); 333 transaction_.reset();
334 response_info_ = NULL; 334 response_info_ = NULL;
335 } 335 }
336 336
337 void URLRequestHttpJob::StartTransaction() { 337 void URLRequestHttpJob::StartTransaction() {
338 if (request_->context()->network_delegate()) { 338 if (request_->network_delegate()) {
339 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( 339 int rv = request_->network_delegate()->NotifyBeforeSendHeaders(
340 request_, notify_before_headers_sent_callback_, 340 request_, notify_before_headers_sent_callback_,
341 &request_info_.extra_headers); 341 &request_info_.extra_headers);
342 // If an extension blocks the request, we rely on the callback to 342 // If an extension blocks the request, we rely on the callback to
343 // MaybeStartTransactionInternal(). 343 // MaybeStartTransactionInternal().
344 if (rv == ERR_IO_PENDING) { 344 if (rv == ERR_IO_PENDING) {
345 SetBlockedOnDelegate(); 345 SetBlockedOnDelegate();
346 return; 346 return;
347 } 347 }
348 MaybeStartTransactionInternal(rv); 348 MaybeStartTransactionInternal(rv);
349 return; 349 return;
(...skipping 23 matching lines...) Expand all
373 } 373 }
374 374
375 void URLRequestHttpJob::StartTransactionInternal() { 375 void URLRequestHttpJob::StartTransactionInternal() {
376 // NOTE: This method assumes that request_info_ is already setup properly. 376 // NOTE: This method assumes that request_info_ is already setup properly.
377 377
378 // If we already have a transaction, then we should restart the transaction 378 // If we already have a transaction, then we should restart the transaction
379 // with auth provided by auth_credentials_. 379 // with auth provided by auth_credentials_.
380 380
381 int rv; 381 int rv;
382 382
383 if (request_->context()->network_delegate()) { 383 if (request_->network_delegate()) {
384 request_->context()->network_delegate()->NotifySendHeaders( 384 request_->network_delegate()->NotifySendHeaders(
385 request_, request_info_.extra_headers); 385 request_, request_info_.extra_headers);
386 } 386 }
387 387
388 if (transaction_.get()) { 388 if (transaction_.get()) {
389 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); 389 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_);
390 auth_credentials_ = AuthCredentials(); 390 auth_credentials_ = AuthCredentials();
391 } else { 391 } else {
392 DCHECK(request_->context()->http_transaction_factory()); 392 DCHECK(request_->context()->http_transaction_factory());
393 393
394 rv = request_->context()->http_transaction_factory()->CreateTransaction( 394 rv = request_->context()->http_transaction_factory()->CreateTransaction(
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 bool sni_available = SSLConfigService::IsSNIAvailable( 757 bool sni_available = SSLConfigService::IsSNIAvailable(
758 context->ssl_config_service()); 758 context->ssl_config_service());
759 const std::string& host = request_->url().host(); 759 const std::string& host = request_->url().host();
760 760
761 reporter->SendReport(host, ssl_info, sni_available); 761 reporter->SendReport(host, ssl_info, sni_available);
762 } 762 }
763 } 763 }
764 764
765 if (result == OK) { 765 if (result == OK) {
766 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); 766 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders();
767 if (context->network_delegate()) { 767 if (request_->network_delegate()) {
768 // Note that |this| may not be deleted until 768 // Note that |this| may not be deleted until
769 // |on_headers_received_callback_| or 769 // |on_headers_received_callback_| or
770 // |NetworkDelegate::URLRequestDestroyed()| has been called. 770 // |NetworkDelegate::URLRequestDestroyed()| has been called.
771 int error = context->network_delegate()-> 771 int error = request_->network_delegate()->
772 NotifyHeadersReceived(request_, on_headers_received_callback_, 772 NotifyHeadersReceived(request_, on_headers_received_callback_,
773 headers, &override_response_headers_); 773 headers, &override_response_headers_);
774 if (error != net::OK) { 774 if (error != net::OK) {
775 if (error == net::ERR_IO_PENDING) { 775 if (error == net::ERR_IO_PENDING) {
776 awaiting_callback_ = true; 776 awaiting_callback_ = true;
777 SetBlockedOnDelegate(); 777 SetBlockedOnDelegate();
778 } else { 778 } else {
779 std::string source("delegate"); 779 std::string source("delegate");
780 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 780 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
781 NetLog::StringCallback("source", 781 NetLog::StringCallback("source",
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 1576
1577 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1577 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1578 awaiting_callback_ = false; 1578 awaiting_callback_ = false;
1579 } 1579 }
1580 1580
1581 void URLRequestHttpJob::OnDetachRequest() { 1581 void URLRequestHttpJob::OnDetachRequest() {
1582 http_transaction_delegate_->OnDetachRequest(); 1582 http_transaction_delegate_->OnDetachRequest();
1583 } 1583 }
1584 1584
1585 } // namespace net 1585 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698