| 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::GetInstance()->AddObserver(this); |
| 38 if (system_monitor) | |
| 39 base::SystemMonitor::Get()->AddPowerObserver(this); | |
| 40 } | 39 } |
| 41 | 40 |
| 42 void URLRequestJob::SetUpload(UploadData* upload) { | 41 void URLRequestJob::SetUpload(UploadData* upload) { |
| 43 } | 42 } |
| 44 | 43 |
| 45 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { | 44 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { |
| 46 } | 45 } |
| 47 | 46 |
| 48 void URLRequestJob::Kill() { | 47 void URLRequestJob::Kill() { |
| 49 weak_factory_.InvalidateWeakPtrs(); | 48 weak_factory_.InvalidateWeakPtrs(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 212 } |
| 214 | 213 |
| 215 void URLRequestJob::OnSuspend() { | 214 void URLRequestJob::OnSuspend() { |
| 216 Kill(); | 215 Kill(); |
| 217 } | 216 } |
| 218 | 217 |
| 219 void URLRequestJob::NotifyURLRequestDestroyed() { | 218 void URLRequestJob::NotifyURLRequestDestroyed() { |
| 220 } | 219 } |
| 221 | 220 |
| 222 URLRequestJob::~URLRequestJob() { | 221 URLRequestJob::~URLRequestJob() { |
| 223 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 222 base::PowerMonitor::GetInstance()->RemoveObserver(this); |
| 224 if (system_monitor) | |
| 225 base::SystemMonitor::Get()->RemovePowerObserver(this); | |
| 226 } | 223 } |
| 227 | 224 |
| 228 void URLRequestJob::NotifyCertificateRequested( | 225 void URLRequestJob::NotifyCertificateRequested( |
| 229 SSLCertRequestInfo* cert_request_info) { | 226 SSLCertRequestInfo* cert_request_info) { |
| 230 if (!request_) | 227 if (!request_) |
| 231 return; // The request was destroyed, so there is no more work to do. | 228 return; // The request was destroyed, so there is no more work to do. |
| 232 | 229 |
| 233 request_->NotifyCertificateRequested(cert_request_info); | 230 request_->NotifyCertificateRequested(cert_request_info); |
| 234 } | 231 } |
| 235 | 232 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 } | 696 } |
| 700 | 697 |
| 701 bool URLRequestJob::FilterHasData() { | 698 bool URLRequestJob::FilterHasData() { |
| 702 return filter_.get() && filter_->stream_data_len(); | 699 return filter_.get() && filter_->stream_data_len(); |
| 703 } | 700 } |
| 704 | 701 |
| 705 void URLRequestJob::UpdatePacketReadTimes() { | 702 void URLRequestJob::UpdatePacketReadTimes() { |
| 706 } | 703 } |
| 707 | 704 |
| 708 } // namespace net | 705 } // namespace net |
| OLD | NEW |