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