| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 // Tell the filter that it has more data. | 558 // Tell the filter that it has more data. |
| 559 PushInputToFilter(bytes_read); | 559 PushInputToFilter(bytes_read); |
| 560 | 560 |
| 561 // Filter the data. | 561 // Filter the data. |
| 562 error = ReadFilteredData(&filter_bytes_read); | 562 error = ReadFilteredData(&filter_bytes_read); |
| 563 } | 563 } |
| 564 | 564 |
| 565 if (error == OK && !filter_bytes_read) | 565 if (error == OK && !filter_bytes_read) |
| 566 DoneReading(); | 566 DoneReading(); |
| 567 | 567 |
| 568 DVLOG(1) << __FUNCTION__ << "() " | 568 DVLOG(1) << __func__ << "() \"" << request_->url().spec() << "\"" |
| 569 << "\"" << request_->url().spec() << "\"" | |
| 570 << " pre bytes read = " << bytes_read | 569 << " pre bytes read = " << bytes_read |
| 571 << " pre total = " << prefilter_bytes_read_ | 570 << " pre total = " << prefilter_bytes_read_ |
| 572 << " post total = " << postfilter_bytes_read_; | 571 << " post total = " << postfilter_bytes_read_; |
| 573 bytes_read = filter_bytes_read; | 572 bytes_read = filter_bytes_read; |
| 574 } else { | 573 } else { |
| 575 DVLOG(1) << __FUNCTION__ << "() " | 574 DVLOG(1) << __func__ << "() \"" << request_->url().spec() << "\"" |
| 576 << "\"" << request_->url().spec() << "\"" | |
| 577 << " pre bytes read = " << bytes_read | 575 << " pre bytes read = " << bytes_read |
| 578 << " pre total = " << prefilter_bytes_read_ | 576 << " pre total = " << prefilter_bytes_read_ |
| 579 << " post total = " << postfilter_bytes_read_; | 577 << " post total = " << postfilter_bytes_read_; |
| 580 } | 578 } |
| 581 | 579 |
| 582 // Synchronize the URLRequest state machine with the URLRequestJob state | 580 // Synchronize the URLRequest state machine with the URLRequestJob state |
| 583 // machine. If this read succeeded, either the request is at EOF and the | 581 // machine. If this read succeeded, either the request is at EOF and the |
| 584 // URLRequest state machine goes to 'finished', or it is not and the | 582 // URLRequest state machine goes to 'finished', or it is not and the |
| 585 // URLRequest state machine goes to 'success'. If the read failed, the | 583 // URLRequest state machine goes to 'success'. If the read failed, the |
| 586 // URLRequest state machine goes directly to 'finished'. If filtered data is | 584 // URLRequest state machine goes directly to 'finished'. If filtered data is |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 } | 787 } |
| 790 break; | 788 break; |
| 791 } | 789 } |
| 792 case Filter::FILTER_OK: { | 790 case Filter::FILTER_OK: { |
| 793 *bytes_read = filtered_data_len; | 791 *bytes_read = filtered_data_len; |
| 794 postfilter_bytes_read_ += filtered_data_len; | 792 postfilter_bytes_read_ += filtered_data_len; |
| 795 error = OK; | 793 error = OK; |
| 796 break; | 794 break; |
| 797 } | 795 } |
| 798 case Filter::FILTER_ERROR: { | 796 case Filter::FILTER_ERROR: { |
| 799 DVLOG(1) << __FUNCTION__ << "() " | 797 DVLOG(1) << __func__ << "() \"" << request_->url().spec() << "\"" |
| 800 << "\"" << request_->url().spec() << "\"" | |
| 801 << " Filter Error"; | 798 << " Filter Error"; |
| 802 filter_needs_more_output_space_ = false; | 799 filter_needs_more_output_space_ = false; |
| 803 error = ERR_CONTENT_DECODING_FAILED; | 800 error = ERR_CONTENT_DECODING_FAILED; |
| 804 UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed.FilterType", | 801 UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed.FilterType", |
| 805 filter_->type(), Filter::FILTER_TYPE_MAX); | 802 filter_->type(), Filter::FILTER_TYPE_MAX); |
| 806 break; | 803 break; |
| 807 } | 804 } |
| 808 default: { | 805 default: { |
| 809 NOTREACHED(); | 806 NOTREACHED(); |
| 810 filter_needs_more_output_space_ = false; | 807 filter_needs_more_output_space_ = false; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 // first raw read of the response body. This is used as the signal that | 932 // first raw read of the response body. This is used as the signal that |
| 936 // response headers have been received. | 933 // response headers have been received. |
| 937 if (request_->context()->network_quality_estimator() && | 934 if (request_->context()->network_quality_estimator() && |
| 938 prefilter_bytes_read_ == bytes_read) { | 935 prefilter_bytes_read_ == bytes_read) { |
| 939 request_->context()->network_quality_estimator()->NotifyHeadersReceived( | 936 request_->context()->network_quality_estimator()->NotifyHeadersReceived( |
| 940 *request_); | 937 *request_); |
| 941 } | 938 } |
| 942 | 939 |
| 943 if (!filter_.get()) | 940 if (!filter_.get()) |
| 944 postfilter_bytes_read_ += bytes_read; | 941 postfilter_bytes_read_ += bytes_read; |
| 945 DVLOG(2) << __FUNCTION__ << "() " | 942 DVLOG(2) << __func__ << "() \"" << request_->url().spec() << "\"" |
| 946 << "\"" << request_->url().spec() << "\"" | |
| 947 << " pre bytes read = " << bytes_read | 943 << " pre bytes read = " << bytes_read |
| 948 << " pre total = " << prefilter_bytes_read_ | 944 << " pre total = " << prefilter_bytes_read_ |
| 949 << " post total = " << postfilter_bytes_read_; | 945 << " post total = " << postfilter_bytes_read_; |
| 950 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. | 946 UpdatePacketReadTimes(); // Facilitate stats recording if it is active. |
| 951 | 947 |
| 952 // Notify observers if any additional network usage has occurred. Note that | 948 // Notify observers if any additional network usage has occurred. Note that |
| 953 // the number of received bytes over the network sent by this notification | 949 // the number of received bytes over the network sent by this notification |
| 954 // could be vastly different from |bytes_read|, such as when a large chunk of | 950 // could be vastly different from |bytes_read|, such as when a large chunk of |
| 955 // network bytes is received before multiple smaller raw reads are performed | 951 // network bytes is received before multiple smaller raw reads are performed |
| 956 // on it. | 952 // on it. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 int64_t total_sent_bytes = GetTotalSentBytes(); | 1036 int64_t total_sent_bytes = GetTotalSentBytes(); |
| 1041 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); | 1037 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); |
| 1042 if (total_sent_bytes > last_notified_total_sent_bytes_) { | 1038 if (total_sent_bytes > last_notified_total_sent_bytes_) { |
| 1043 network_delegate_->NotifyNetworkBytesSent( | 1039 network_delegate_->NotifyNetworkBytesSent( |
| 1044 request_, total_sent_bytes - last_notified_total_sent_bytes_); | 1040 request_, total_sent_bytes - last_notified_total_sent_bytes_); |
| 1045 } | 1041 } |
| 1046 last_notified_total_sent_bytes_ = total_sent_bytes; | 1042 last_notified_total_sent_bytes_ = total_sent_bytes; |
| 1047 } | 1043 } |
| 1048 | 1044 |
| 1049 } // namespace net | 1045 } // namespace net |
| OLD | NEW |