Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 DCHECK_LT(buf_size, 1000000); // Sanity check. | 83 DCHECK_LT(buf_size, 1000000); // Sanity check. |
| 84 DCHECK(buf); | 84 DCHECK(buf); |
| 85 DCHECK(bytes_read); | 85 DCHECK(bytes_read); |
| 86 DCHECK(filtered_read_buffer_.get() == NULL); | 86 DCHECK(filtered_read_buffer_.get() == NULL); |
| 87 DCHECK_EQ(0, filtered_read_buffer_len_); | 87 DCHECK_EQ(0, filtered_read_buffer_len_); |
| 88 | 88 |
| 89 *bytes_read = 0; | 89 *bytes_read = 0; |
| 90 | 90 |
| 91 // Skip Filter if not present. | 91 // Skip Filter if not present. |
| 92 if (!filter_.get()) { | 92 if (!filter_.get()) { |
| 93 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. | |
| 94 tracked_objects::ScopedTracker tracking_profile1( | |
| 95 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read1")); | |
|
mmenke
2014/12/12 15:23:46
Suggest putting one in ReadRawDataHelper instead (
vadimt
2014/12/12 15:34:50
Done.
| |
| 96 | |
| 93 rv = ReadRawDataHelper(buf, buf_size, bytes_read); | 97 rv = ReadRawDataHelper(buf, buf_size, bytes_read); |
| 94 } else { | 98 } else { |
| 95 // Save the caller's buffers while we do IO | 99 // Save the caller's buffers while we do IO |
| 96 // in the filter's buffers. | 100 // in the filter's buffers. |
| 97 filtered_read_buffer_ = buf; | 101 filtered_read_buffer_ = buf; |
| 98 filtered_read_buffer_len_ = buf_size; | 102 filtered_read_buffer_len_ = buf_size; |
| 99 | 103 |
| 104 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. | |
| 105 tracked_objects::ScopedTracker tracking_profile2( | |
| 106 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read2")); | |
| 107 | |
| 100 if (ReadFilteredData(bytes_read)) { | 108 if (ReadFilteredData(bytes_read)) { |
| 101 rv = true; // We have data to return. | 109 rv = true; // We have data to return. |
| 102 | 110 |
| 103 // It is fine to call DoneReading even if ReadFilteredData receives 0 | 111 // It is fine to call DoneReading even if ReadFilteredData receives 0 |
| 104 // bytes from the net, but we avoid making that call if we know for | 112 // bytes from the net, but we avoid making that call if we know for |
| 105 // sure that's the case (ReadRawDataHelper path). | 113 // sure that's the case (ReadRawDataHelper path). |
| 114 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is | |
| 115 // fixed. | |
| 116 tracked_objects::ScopedTracker tracking_profile3( | |
| 117 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read3")); | |
| 118 | |
| 106 if (*bytes_read == 0) | 119 if (*bytes_read == 0) |
| 107 DoneReading(); | 120 DoneReading(); |
| 108 } else { | 121 } else { |
| 109 rv = false; // Error, or a new IO is pending. | 122 rv = false; // Error, or a new IO is pending. |
| 110 } | 123 } |
| 111 } | 124 } |
| 125 | |
| 126 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. | |
| 127 tracked_objects::ScopedTracker tracking_profile4( | |
| 128 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read4")); | |
| 129 | |
| 112 if (rv && *bytes_read == 0) | 130 if (rv && *bytes_read == 0) |
| 113 NotifyDone(URLRequestStatus()); | 131 NotifyDone(URLRequestStatus()); |
| 114 return rv; | 132 return rv; |
| 115 } | 133 } |
| 116 | 134 |
| 117 void URLRequestJob::StopCaching() { | 135 void URLRequestJob::StopCaching() { |
| 118 // Nothing to do here. | 136 // Nothing to do here. |
| 119 } | 137 } |
| 120 | 138 |
| 121 bool URLRequestJob::GetFullRequestHeaders(HttpRequestHeaders* headers) const { | 139 bool URLRequestJob::GetFullRequestHeaders(HttpRequestHeaders* headers) const { |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). | 919 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). |
| 902 redirect_info.new_referrer = | 920 redirect_info.new_referrer = |
| 903 ComputeReferrerForRedirect(request_->referrer_policy(), | 921 ComputeReferrerForRedirect(request_->referrer_policy(), |
| 904 request_->referrer(), | 922 request_->referrer(), |
| 905 redirect_info.new_url).spec(); | 923 redirect_info.new_url).spec(); |
| 906 | 924 |
| 907 return redirect_info; | 925 return redirect_info; |
| 908 } | 926 } |
| 909 | 927 |
| 910 } // namespace net | 928 } // namespace net |
| OLD | NEW |