| OLD | NEW |
| 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_job.h" | 5 #include "net/url_request/url_request_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/power_monitor/power_monitor.h" |
| 10 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 12 #include "net/base/auth.h" | 13 #include "net/base/auth.h" |
| 13 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 15 #include "net/base/load_states.h" | 16 #include "net/base/load_states.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "net/base/network_delegate.h" | 18 #include "net/base/network_delegate.h" |
| 18 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
| 19 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 | 23 |
| 23 URLRequestJob::URLRequestJob(URLRequest* request, | 24 URLRequestJob::URLRequestJob(URLRequest* request, |
| 24 NetworkDelegate* network_delegate) | 25 NetworkDelegate* network_delegate) |
| 25 : request_(request), | 26 : request_(request), |
| 26 done_(false), | 27 done_(false), |
| 27 prefilter_bytes_read_(0), | 28 prefilter_bytes_read_(0), |
| 28 postfilter_bytes_read_(0), | 29 postfilter_bytes_read_(0), |
| 29 filter_input_byte_count_(0), | 30 filter_input_byte_count_(0), |
| 30 filter_needs_more_output_space_(false), | 31 filter_needs_more_output_space_(false), |
| 31 filtered_read_buffer_len_(0), | 32 filtered_read_buffer_len_(0), |
| 32 has_handled_response_(false), | 33 has_handled_response_(false), |
| 33 expected_content_size_(-1), | 34 expected_content_size_(-1), |
| 34 deferred_redirect_status_code_(-1), | 35 deferred_redirect_status_code_(-1), |
| 35 network_delegate_(network_delegate), | 36 network_delegate_(network_delegate), |
| 36 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 37 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 37 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 38 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 38 if (system_monitor) | 39 if (power_monitor) |
| 39 base::SystemMonitor::Get()->AddPowerObserver(this); | 40 power_monitor->AddObserver(this); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void URLRequestJob::SetUpload(UploadDataStream* upload) { | 43 void URLRequestJob::SetUpload(UploadDataStream* upload) { |
| 43 } | 44 } |
| 44 | 45 |
| 45 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { | 46 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { |
| 46 } | 47 } |
| 47 | 48 |
| 48 void URLRequestJob::Kill() { | 49 void URLRequestJob::Kill() { |
| 49 weak_factory_.InvalidateWeakPtrs(); | 50 weak_factory_.InvalidateWeakPtrs(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 220 } |
| 220 | 221 |
| 221 void URLRequestJob::OnSuspend() { | 222 void URLRequestJob::OnSuspend() { |
| 222 Kill(); | 223 Kill(); |
| 223 } | 224 } |
| 224 | 225 |
| 225 void URLRequestJob::NotifyURLRequestDestroyed() { | 226 void URLRequestJob::NotifyURLRequestDestroyed() { |
| 226 } | 227 } |
| 227 | 228 |
| 228 URLRequestJob::~URLRequestJob() { | 229 URLRequestJob::~URLRequestJob() { |
| 229 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 230 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 230 if (system_monitor) | 231 if (power_monitor) |
| 231 base::SystemMonitor::Get()->RemovePowerObserver(this); | 232 power_monitor->RemoveObserver(this); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void URLRequestJob::NotifyCertificateRequested( | 235 void URLRequestJob::NotifyCertificateRequested( |
| 235 SSLCertRequestInfo* cert_request_info) { | 236 SSLCertRequestInfo* cert_request_info) { |
| 236 if (!request_) | 237 if (!request_) |
| 237 return; // The request was destroyed, so there is no more work to do. | 238 return; // The request was destroyed, so there is no more work to do. |
| 238 | 239 |
| 239 request_->NotifyCertificateRequested(cert_request_info); | 240 request_->NotifyCertificateRequested(cert_request_info); |
| 240 } | 241 } |
| 241 | 242 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 710 } |
| 710 | 711 |
| 711 bool URLRequestJob::FilterHasData() { | 712 bool URLRequestJob::FilterHasData() { |
| 712 return filter_.get() && filter_->stream_data_len(); | 713 return filter_.get() && filter_->stream_data_len(); |
| 713 } | 714 } |
| 714 | 715 |
| 715 void URLRequestJob::UpdatePacketReadTimes() { | 716 void URLRequestJob::UpdatePacketReadTimes() { |
| 716 } | 717 } |
| 717 | 718 |
| 718 } // namespace net | 719 } // namespace net |
| OLD | NEW |