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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "net/base/auth.h" | 12 #include "net/base/auth.h" |
13 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/load_states.h" | 15 #include "net/base/load_states.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/network_delegate.h" | 17 #include "net/base/network_delegate.h" |
18 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
19 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
20 #include "net/url_request/url_request_context.h" | |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 | 22 |
24 URLRequestJob::URLRequestJob(URLRequest* request) | 23 URLRequestJob::URLRequestJob(URLRequest* request, |
| 24 NetworkDelegate* network_delegate) |
25 : request_(request), | 25 : request_(request), |
26 done_(false), | 26 done_(false), |
27 prefilter_bytes_read_(0), | 27 prefilter_bytes_read_(0), |
28 postfilter_bytes_read_(0), | 28 postfilter_bytes_read_(0), |
29 filter_input_byte_count_(0), | 29 filter_input_byte_count_(0), |
30 filter_needs_more_output_space_(false), | 30 filter_needs_more_output_space_(false), |
31 filtered_read_buffer_len_(0), | 31 filtered_read_buffer_len_(0), |
32 has_handled_response_(false), | 32 has_handled_response_(false), |
33 expected_content_size_(-1), | 33 expected_content_size_(-1), |
34 deferred_redirect_status_code_(-1), | 34 deferred_redirect_status_code_(-1), |
| 35 network_delegate_(network_delegate), |
35 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 36 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
36 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 37 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); |
37 if (system_monitor) | 38 if (system_monitor) |
38 base::SystemMonitor::Get()->AddPowerObserver(this); | 39 base::SystemMonitor::Get()->AddPowerObserver(this); |
39 } | 40 } |
40 | 41 |
41 void URLRequestJob::SetUpload(UploadData* upload) { | 42 void URLRequestJob::SetUpload(UploadData* upload) { |
42 } | 43 } |
43 | 44 |
44 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { | 45 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 filter_input_byte_count_ += bytes_read; | 686 filter_input_byte_count_ += bytes_read; |
686 prefilter_bytes_read_ += bytes_read; | 687 prefilter_bytes_read_ += bytes_read; |
687 if (!filter_.get()) | 688 if (!filter_.get()) |
688 postfilter_bytes_read_ += bytes_read; | 689 postfilter_bytes_read_ += bytes_read; |
689 DVLOG(2) << __FUNCTION__ << "() " | 690 DVLOG(2) << __FUNCTION__ << "() " |
690 << "\"" << (request_ ? request_->url().spec() : "???") << "\"" | 691 << "\"" << (request_ ? request_->url().spec() : "???") << "\"" |
691 << " pre bytes read = " << bytes_read | 692 << " pre bytes read = " << bytes_read |
692 << " pre total = " << prefilter_bytes_read_ | 693 << " pre total = " << prefilter_bytes_read_ |
693 << " post total = " << postfilter_bytes_read_; | 694 << " post total = " << postfilter_bytes_read_; |
694 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. | 695 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. |
695 const URLRequestContext* context = request_->context(); | 696 if (network_delegate_) |
696 if (context && context->network_delegate()) | 697 network_delegate_->NotifyRawBytesRead(*request_, bytes_read); |
697 context->network_delegate()->NotifyRawBytesRead(*request_, bytes_read); | |
698 } | 698 } |
699 | 699 |
700 bool URLRequestJob::FilterHasData() { | 700 bool URLRequestJob::FilterHasData() { |
701 return filter_.get() && filter_->stream_data_len(); | 701 return filter_.get() && filter_->stream_data_len(); |
702 } | 702 } |
703 | 703 |
704 void URLRequestJob::UpdatePacketReadTimes() { | 704 void URLRequestJob::UpdatePacketReadTimes() { |
705 } | 705 } |
706 | 706 |
707 } // namespace net | 707 } // namespace net |
OLD | NEW |