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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 } | 691 } |
692 default: { | 692 default: { |
693 NOTREACHED(); | 693 NOTREACHED(); |
694 filter_needs_more_output_space_ = false; | 694 filter_needs_more_output_space_ = false; |
695 rv = false; | 695 rv = false; |
696 break; | 696 break; |
697 } | 697 } |
698 } | 698 } |
699 | 699 |
700 // If logging all bytes is enabled, log the filtered bytes read. | 700 // If logging all bytes is enabled, log the filtered bytes read. |
701 if (rv && request() && | 701 if (rv && request() && filtered_data_len > 0 && |
702 request()->net_log().GetCaptureMode().include_socket_bytes() && | 702 request()->net_log().IsCapturing()) { |
703 filtered_data_len > 0) { | |
704 request()->net_log().AddByteTransferEvent( | 703 request()->net_log().AddByteTransferEvent( |
705 NetLog::TYPE_URL_REQUEST_JOB_FILTERED_BYTES_READ, | 704 NetLog::TYPE_URL_REQUEST_JOB_FILTERED_BYTES_READ, filtered_data_len, |
706 filtered_data_len, filtered_read_buffer_->data()); | 705 filtered_read_buffer_->data()); |
707 } | 706 } |
708 } else { | 707 } else { |
709 // we are done, or there is no data left. | 708 // we are done, or there is no data left. |
710 rv = true; | 709 rv = true; |
711 } | 710 } |
712 break; | 711 break; |
713 } | 712 } |
714 | 713 |
715 if (rv) { | 714 if (rv) { |
716 // When we successfully finished a read, we no longer need to save the | 715 // When we successfully finished a read, we no longer need to save the |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 782 |
784 void URLRequestJob::FollowRedirect(const RedirectInfo& redirect_info) { | 783 void URLRequestJob::FollowRedirect(const RedirectInfo& redirect_info) { |
785 int rv = request_->Redirect(redirect_info); | 784 int rv = request_->Redirect(redirect_info); |
786 if (rv != OK) | 785 if (rv != OK) |
787 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 786 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
788 } | 787 } |
789 | 788 |
790 void URLRequestJob::OnRawReadComplete(int bytes_read) { | 789 void URLRequestJob::OnRawReadComplete(int bytes_read) { |
791 DCHECK(raw_read_buffer_.get()); | 790 DCHECK(raw_read_buffer_.get()); |
792 // If |filter_| is non-NULL, bytes will be logged after it is applied instead. | 791 // If |filter_| is non-NULL, bytes will be logged after it is applied instead. |
793 if (!filter_.get() && request() && | 792 if (!filter_.get() && request() && bytes_read > 0 && |
794 request()->net_log().GetCaptureMode().include_socket_bytes() && | 793 request()->net_log().IsCapturing()) { |
795 bytes_read > 0) { | |
796 request()->net_log().AddByteTransferEvent( | 794 request()->net_log().AddByteTransferEvent( |
797 NetLog::TYPE_URL_REQUEST_JOB_BYTES_READ, | 795 NetLog::TYPE_URL_REQUEST_JOB_BYTES_READ, |
798 bytes_read, raw_read_buffer_->data()); | 796 bytes_read, raw_read_buffer_->data()); |
799 } | 797 } |
800 | 798 |
801 if (bytes_read > 0) { | 799 if (bytes_read > 0) { |
802 RecordBytesRead(bytes_read); | 800 RecordBytesRead(bytes_read); |
803 } | 801 } |
804 raw_read_buffer_ = NULL; | 802 raw_read_buffer_ = NULL; |
805 } | 803 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). | 861 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). |
864 redirect_info.new_referrer = | 862 redirect_info.new_referrer = |
865 ComputeReferrerForRedirect(request_->referrer_policy(), | 863 ComputeReferrerForRedirect(request_->referrer_policy(), |
866 request_->referrer(), | 864 request_->referrer(), |
867 redirect_info.new_url).spec(); | 865 redirect_info.new_url).spec(); |
868 | 866 |
869 return redirect_info; | 867 return redirect_info; |
870 } | 868 } |
871 | 869 |
872 } // namespace net | 870 } // namespace net |
OLD | NEW |