Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 : URLRequestJob(request), | 202 : URLRequestJob(request), |
| 203 response_info_(NULL), | 203 response_info_(NULL), |
| 204 response_cookies_save_index_(0), | 204 response_cookies_save_index_(0), |
| 205 proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH), | 205 proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH), |
| 206 server_auth_state_(AUTH_STATE_DONT_NEED_AUTH), | 206 server_auth_state_(AUTH_STATE_DONT_NEED_AUTH), |
| 207 ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_( | 207 ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_( |
| 208 this, &URLRequestHttpJob::OnStartCompleted)), | 208 this, &URLRequestHttpJob::OnStartCompleted)), |
| 209 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( | 209 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( |
| 210 this, &URLRequestHttpJob::OnReadCompleted)), | 210 this, &URLRequestHttpJob::OnReadCompleted)), |
| 211 ALLOW_THIS_IN_INITIALIZER_LIST(notify_before_headers_sent_callback_( | 211 ALLOW_THIS_IN_INITIALIZER_LIST(notify_before_headers_sent_callback_( |
| 212 this, &URLRequestHttpJob::NotifyBeforeSendHeadersCallback)), | 212 base::Bind(&URLRequestHttpJob::NotifyBeforeSendHeadersCallback, |
| 213 this))), | |
|
csilv
2011/11/30 21:56:50
should 'this' be unretained? (ie typical callback
James Hawkins
2011/12/01 00:40:26
Done.
| |
| 213 read_in_progress_(false), | 214 read_in_progress_(false), |
| 214 transaction_(NULL), | 215 transaction_(NULL), |
| 215 throttling_entry_(URLRequestThrottlerManager::GetInstance()-> | 216 throttling_entry_(URLRequestThrottlerManager::GetInstance()-> |
| 216 RegisterRequestUrl(request->url())), | 217 RegisterRequestUrl(request->url())), |
| 217 sdch_dictionary_advertised_(false), | 218 sdch_dictionary_advertised_(false), |
| 218 sdch_test_activated_(false), | 219 sdch_test_activated_(false), |
| 219 sdch_test_control_(false), | 220 sdch_test_control_(false), |
| 220 is_cached_content_(false), | 221 is_cached_content_(false), |
| 221 request_creation_time_(), | 222 request_creation_time_(), |
| 222 packet_timing_enabled_(false), | 223 packet_timing_enabled_(false), |
| 223 done_(false), | 224 done_(false), |
| 224 bytes_observed_in_packets_(0), | 225 bytes_observed_in_packets_(0), |
| 225 request_time_snapshot_(), | 226 request_time_snapshot_(), |
| 226 final_packet_time_(), | 227 final_packet_time_(), |
| 227 ALLOW_THIS_IN_INITIALIZER_LIST( | 228 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 228 filter_context_(new HttpFilterContext(this))), | 229 filter_context_(new HttpFilterContext(this))), |
| 229 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 230 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), |
| 230 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 231 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 231 ALLOW_THIS_IN_INITIALIZER_LIST( | 232 ALLOW_THIS_IN_INITIALIZER_LIST(on_headers_received_callback_( |
| 232 on_headers_received_callback_( | 233 base::Bind(&URLRequestHttpJob::OnHeadersReceivedCallback, this))), |
|
csilv
2011/11/30 21:56:50
ditto
James Hawkins
2011/12/01 00:40:26
Done.
| |
| 233 this, &URLRequestHttpJob::OnHeadersReceivedCallback)), | |
| 234 awaiting_callback_(false) { | 234 awaiting_callback_(false) { |
| 235 ResetTimer(); | 235 ResetTimer(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void URLRequestHttpJob::NotifyHeadersComplete() { | 238 void URLRequestHttpJob::NotifyHeadersComplete() { |
| 239 DCHECK(!response_info_); | 239 DCHECK(!response_info_); |
| 240 | 240 |
| 241 response_info_ = transaction_->GetResponseInfo(); | 241 response_info_ = transaction_->GetResponseInfo(); |
| 242 | 242 |
| 243 // Save boolean, as we'll need this info at destruction time, and filters may | 243 // Save boolean, as we'll need this info at destruction time, and filters may |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 298 |
| 299 DoneWithRequest(ABORTED); | 299 DoneWithRequest(ABORTED); |
| 300 transaction_.reset(); | 300 transaction_.reset(); |
| 301 response_info_ = NULL; | 301 response_info_ = NULL; |
| 302 context_ = NULL; | 302 context_ = NULL; |
| 303 } | 303 } |
| 304 | 304 |
| 305 void URLRequestHttpJob::StartTransaction() { | 305 void URLRequestHttpJob::StartTransaction() { |
| 306 if (request_->context() && request_->context()->network_delegate()) { | 306 if (request_->context() && request_->context()->network_delegate()) { |
| 307 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( | 307 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( |
| 308 request_, ¬ify_before_headers_sent_callback_, | 308 request_, notify_before_headers_sent_callback_, |
| 309 &request_info_.extra_headers); | 309 &request_info_.extra_headers); |
| 310 // If an extension blocks the request, we rely on the callback to | 310 // If an extension blocks the request, we rely on the callback to |
| 311 // StartTransactionInternal(). | 311 // StartTransactionInternal(). |
| 312 if (rv == ERR_IO_PENDING) { | 312 if (rv == ERR_IO_PENDING) { |
| 313 SetBlockedOnDelegate(); | 313 SetBlockedOnDelegate(); |
| 314 return; | 314 return; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 StartTransactionInternal(); | 317 StartTransactionInternal(); |
| 318 } | 318 } |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 } | 707 } |
| 708 #endif | 708 #endif |
| 709 | 709 |
| 710 if (result == OK) { | 710 if (result == OK) { |
| 711 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); | 711 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); |
| 712 if (request_->context() && request_->context()->network_delegate()) { | 712 if (request_->context() && request_->context()->network_delegate()) { |
| 713 // Note that |this| may not be deleted until | 713 // Note that |this| may not be deleted until |
| 714 // |on_headers_received_callback_| or | 714 // |on_headers_received_callback_| or |
| 715 // |NetworkDelegate::URLRequestDestroyed()| has been called. | 715 // |NetworkDelegate::URLRequestDestroyed()| has been called. |
| 716 int error = request_->context()->network_delegate()-> | 716 int error = request_->context()->network_delegate()-> |
| 717 NotifyHeadersReceived(request_, &on_headers_received_callback_, | 717 NotifyHeadersReceived(request_, on_headers_received_callback_, |
| 718 headers, &override_response_headers_); | 718 headers, &override_response_headers_); |
| 719 if (error != net::OK) { | 719 if (error != net::OK) { |
| 720 if (error == net::ERR_IO_PENDING) { | 720 if (error == net::ERR_IO_PENDING) { |
| 721 awaiting_callback_ = true; | 721 awaiting_callback_ = true; |
| 722 request_->net_log().BeginEvent( | 722 request_->net_log().BeginEvent( |
| 723 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 723 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
| 724 } else { | 724 } else { |
| 725 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 725 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, |
| 726 make_scoped_refptr( | 726 make_scoped_refptr( |
| 727 new NetLogStringParameter("source", "delegate"))); | 727 new NetLogStringParameter("source", "delegate"))); |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1410 return override_response_headers_.get() ? | 1410 return override_response_headers_.get() ? |
| 1411 override_response_headers_ : | 1411 override_response_headers_ : |
| 1412 transaction_->GetResponseInfo()->headers; | 1412 transaction_->GetResponseInfo()->headers; |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1415 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1416 awaiting_callback_ = false; | 1416 awaiting_callback_ = false; |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 } // namespace net | 1419 } // namespace net |
| OLD | NEW |