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::SetPriority(RequestPriority priority) { | 49 void URLRequestJob::SetPriority(RequestPriority priority) { |
49 } | 50 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 223 } |
223 | 224 |
224 void URLRequestJob::OnSuspend() { | 225 void URLRequestJob::OnSuspend() { |
225 Kill(); | 226 Kill(); |
226 } | 227 } |
227 | 228 |
228 void URLRequestJob::NotifyURLRequestDestroyed() { | 229 void URLRequestJob::NotifyURLRequestDestroyed() { |
229 } | 230 } |
230 | 231 |
231 URLRequestJob::~URLRequestJob() { | 232 URLRequestJob::~URLRequestJob() { |
232 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 233 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
233 if (system_monitor) | 234 if (power_monitor) |
234 base::SystemMonitor::Get()->RemovePowerObserver(this); | 235 power_monitor->RemoveObserver(this); |
235 } | 236 } |
236 | 237 |
237 void URLRequestJob::NotifyCertificateRequested( | 238 void URLRequestJob::NotifyCertificateRequested( |
238 SSLCertRequestInfo* cert_request_info) { | 239 SSLCertRequestInfo* cert_request_info) { |
239 if (!request_) | 240 if (!request_) |
240 return; // The request was destroyed, so there is no more work to do. | 241 return; // The request was destroyed, so there is no more work to do. |
241 | 242 |
242 request_->NotifyCertificateRequested(cert_request_info); | 243 request_->NotifyCertificateRequested(cert_request_info); |
243 } | 244 } |
244 | 245 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 } | 713 } |
713 | 714 |
714 bool URLRequestJob::FilterHasData() { | 715 bool URLRequestJob::FilterHasData() { |
715 return filter_.get() && filter_->stream_data_len(); | 716 return filter_.get() && filter_->stream_data_len(); |
716 } | 717 } |
717 | 718 |
718 void URLRequestJob::UpdatePacketReadTimes() { | 719 void URLRequestJob::UpdatePacketReadTimes() { |
719 } | 720 } |
720 | 721 |
721 } // namespace net | 722 } // namespace net |
OLD | NEW |