| 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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 : request_(request), | 66 : request_(request), |
| 67 done_(false), | 67 done_(false), |
| 68 prefilter_bytes_read_(0), | 68 prefilter_bytes_read_(0), |
| 69 postfilter_bytes_read_(0), | 69 postfilter_bytes_read_(0), |
| 70 filter_needs_more_output_space_(false), | 70 filter_needs_more_output_space_(false), |
| 71 filtered_read_buffer_len_(0), | 71 filtered_read_buffer_len_(0), |
| 72 has_handled_response_(false), | 72 has_handled_response_(false), |
| 73 expected_content_size_(-1), | 73 expected_content_size_(-1), |
| 74 network_delegate_(network_delegate), | 74 network_delegate_(network_delegate), |
| 75 last_notified_total_received_bytes_(0), | 75 last_notified_total_received_bytes_(0), |
| 76 last_notified_total_sent_bytes_(0), |
| 76 weak_factory_(this) { | 77 weak_factory_(this) { |
| 77 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 78 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 78 if (power_monitor) | 79 if (power_monitor) |
| 79 power_monitor->AddObserver(this); | 80 power_monitor->AddObserver(this); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void URLRequestJob::SetUpload(UploadDataStream* upload) { | 83 void URLRequestJob::SetUpload(UploadDataStream* upload) { |
| 83 } | 84 } |
| 84 | 85 |
| 85 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { | 86 void URLRequestJob::SetExtraRequestHeaders(const HttpRequestHeaders& headers) { |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 request_->referrer(), | 931 request_->referrer(), |
| 931 redirect_info.new_url).spec(); | 932 redirect_info.new_url).spec(); |
| 932 | 933 |
| 933 return redirect_info; | 934 return redirect_info; |
| 934 } | 935 } |
| 935 | 936 |
| 936 void URLRequestJob::MaybeNotifyNetworkBytes() { | 937 void URLRequestJob::MaybeNotifyNetworkBytes() { |
| 937 if (!request_ || !network_delegate_) | 938 if (!request_ || !network_delegate_) |
| 938 return; | 939 return; |
| 939 | 940 |
| 941 // Report any new received bytes. |
| 940 int64_t total_received_bytes = GetTotalReceivedBytes(); | 942 int64_t total_received_bytes = GetTotalReceivedBytes(); |
| 941 DCHECK_GE(total_received_bytes, last_notified_total_received_bytes_); | 943 DCHECK_GE(total_received_bytes, last_notified_total_received_bytes_); |
| 942 if (total_received_bytes > last_notified_total_received_bytes_) { | 944 if (total_received_bytes > last_notified_total_received_bytes_) { |
| 943 network_delegate_->NotifyNetworkBytesReceived( | 945 network_delegate_->NotifyNetworkBytesReceived( |
| 944 *request_, total_received_bytes - last_notified_total_received_bytes_); | 946 *request_, total_received_bytes - last_notified_total_received_bytes_); |
| 945 } | 947 } |
| 946 last_notified_total_received_bytes_ = total_received_bytes; | 948 last_notified_total_received_bytes_ = total_received_bytes; |
| 949 |
| 950 // Report any new sent bytes. |
| 951 int64_t total_sent_bytes = GetTotalSentBytes(); |
| 952 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); |
| 953 if (total_sent_bytes > last_notified_total_sent_bytes_) { |
| 954 network_delegate_->NotifyNetworkBytesSent( |
| 955 *request_, total_sent_bytes - last_notified_total_sent_bytes_); |
| 956 } |
| 957 last_notified_total_sent_bytes_ = total_sent_bytes; |
| 947 } | 958 } |
| 948 | 959 |
| 949 } // namespace net | 960 } // namespace net |
| OLD | NEW |