Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 filter_input_byte_count_ += bytes_read; | 688 filter_input_byte_count_ += bytes_read; |
| 688 prefilter_bytes_read_ += bytes_read; | 689 prefilter_bytes_read_ += bytes_read; |
| 689 if (!filter_.get()) | 690 if (!filter_.get()) |
| 690 postfilter_bytes_read_ += bytes_read; | 691 postfilter_bytes_read_ += bytes_read; |
| 691 DVLOG(2) << __FUNCTION__ << "() " | 692 DVLOG(2) << __FUNCTION__ << "() " |
| 692 << "\"" << (request_ ? request_->url().spec() : "???") << "\"" | 693 << "\"" << (request_ ? request_->url().spec() : "???") << "\"" |
| 693 << " pre bytes read = " << bytes_read | 694 << " pre bytes read = " << bytes_read |
| 694 << " pre total = " << prefilter_bytes_read_ | 695 << " pre total = " << prefilter_bytes_read_ |
| 695 << " post total = " << postfilter_bytes_read_; | 696 << " post total = " << postfilter_bytes_read_; |
| 696 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. | 697 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. |
| 697 const URLRequestContext* context = request_->context(); | 698 if (network_delegate_) |
| 698 if (context && context->network_delegate()) | 699 network_delegate_->NotifyRawBytesRead(*request_, bytes_read); |
|
willchan no longer on Chromium
2012/06/13 19:07:33
Is this safe? We're losing the NULL check on |cont
shalev
2012/06/21 20:03:55
Done.
| |
| 699 context->network_delegate()->NotifyRawBytesRead(*request_, bytes_read); | |
| 700 } | 700 } |
| 701 | 701 |
| 702 bool URLRequestJob::FilterHasData() { | 702 bool URLRequestJob::FilterHasData() { |
| 703 return filter_.get() && filter_->stream_data_len(); | 703 return filter_.get() && filter_->stream_data_len(); |
| 704 } | 704 } |
| 705 | 705 |
| 706 void URLRequestJob::UpdatePacketReadTimes() { | 706 void URLRequestJob::UpdatePacketReadTimes() { |
| 707 } | 707 } |
| 708 | 708 |
| 709 } // namespace net | 709 } // namespace net |
| OLD | NEW |