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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/power_monitor/power_monitor.h" | 10 #include "base/power_monitor/power_monitor.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 URLRequestJob::URLRequestJob(URLRequest* request, | 57 URLRequestJob::URLRequestJob(URLRequest* request, |
58 NetworkDelegate* network_delegate) | 58 NetworkDelegate* network_delegate) |
59 : request_(request), | 59 : request_(request), |
60 done_(false), | 60 done_(false), |
61 prefilter_bytes_read_(0), | 61 prefilter_bytes_read_(0), |
62 postfilter_bytes_read_(0), | 62 postfilter_bytes_read_(0), |
63 filter_input_byte_count_(0), | |
64 filter_needs_more_output_space_(false), | 63 filter_needs_more_output_space_(false), |
65 filtered_read_buffer_len_(0), | 64 filtered_read_buffer_len_(0), |
66 has_handled_response_(false), | 65 has_handled_response_(false), |
67 expected_content_size_(-1), | 66 expected_content_size_(-1), |
68 network_delegate_(network_delegate), | 67 network_delegate_(network_delegate), |
69 weak_factory_(this) { | 68 weak_factory_(this) { |
70 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 69 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
71 if (power_monitor) | 70 if (power_monitor) |
72 power_monitor->AddObserver(this); | 71 power_monitor->AddObserver(this); |
73 } | 72 } |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 bytes_read, raw_read_buffer_->data()); | 876 bytes_read, raw_read_buffer_->data()); |
878 } | 877 } |
879 | 878 |
880 if (bytes_read > 0) { | 879 if (bytes_read > 0) { |
881 RecordBytesRead(bytes_read); | 880 RecordBytesRead(bytes_read); |
882 } | 881 } |
883 raw_read_buffer_ = NULL; | 882 raw_read_buffer_ = NULL; |
884 } | 883 } |
885 | 884 |
886 void URLRequestJob::RecordBytesRead(int bytes_read) { | 885 void URLRequestJob::RecordBytesRead(int bytes_read) { |
887 filter_input_byte_count_ += bytes_read; | |
888 prefilter_bytes_read_ += bytes_read; | 886 prefilter_bytes_read_ += bytes_read; |
889 if (!filter_.get()) | 887 if (!filter_.get()) |
890 postfilter_bytes_read_ += bytes_read; | 888 postfilter_bytes_read_ += bytes_read; |
891 DVLOG(2) << __FUNCTION__ << "() " | 889 DVLOG(2) << __FUNCTION__ << "() " |
892 << "\"" << (request_ ? request_->url().spec() : "???") << "\"" | 890 << "\"" << (request_ ? request_->url().spec() : "???") << "\"" |
893 << " pre bytes read = " << bytes_read | 891 << " pre bytes read = " << bytes_read |
894 << " pre total = " << prefilter_bytes_read_ | 892 << " pre total = " << prefilter_bytes_read_ |
895 << " post total = " << postfilter_bytes_read_; | 893 << " post total = " << postfilter_bytes_read_; |
896 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. | 894 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. |
897 if (network_delegate_) { | 895 if (network_delegate_) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). | 947 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). |
950 redirect_info.new_referrer = | 948 redirect_info.new_referrer = |
951 ComputeReferrerForRedirect(request_->referrer_policy(), | 949 ComputeReferrerForRedirect(request_->referrer_policy(), |
952 request_->referrer(), | 950 request_->referrer(), |
953 redirect_info.new_url).spec(); | 951 redirect_info.new_url).spec(); |
954 | 952 |
955 return redirect_info; | 953 return redirect_info; |
956 } | 954 } |
957 | 955 |
958 } // namespace net | 956 } // namespace net |
OLD | NEW |