Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2281)

Side by Side Diff: net/url_request/url_request_job.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/crash_cache/crash_cache.cc ('k') | services/surfaces/surfaces_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // Skip Filter if not present. 91 // Skip Filter if not present.
92 if (!filter_.get()) { 92 if (!filter_.get()) {
93 rv = ReadRawDataHelper(buf, buf_size, bytes_read); 93 rv = ReadRawDataHelper(buf, buf_size, bytes_read);
94 } else { 94 } else {
95 // Save the caller's buffers while we do IO 95 // Save the caller's buffers while we do IO
96 // in the filter's buffers. 96 // in the filter's buffers.
97 filtered_read_buffer_ = buf; 97 filtered_read_buffer_ = buf;
98 filtered_read_buffer_len_ = buf_size; 98 filtered_read_buffer_len_ = buf_size;
99 99
100 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
101 tracked_objects::ScopedTracker tracking_profile2(
102 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read2"));
103
100 if (ReadFilteredData(bytes_read)) { 104 if (ReadFilteredData(bytes_read)) {
101 rv = true; // We have data to return. 105 rv = true; // We have data to return.
102 106
103 // It is fine to call DoneReading even if ReadFilteredData receives 0 107 // 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 108 // bytes from the net, but we avoid making that call if we know for
105 // sure that's the case (ReadRawDataHelper path). 109 // sure that's the case (ReadRawDataHelper path).
110 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is
111 // fixed.
112 tracked_objects::ScopedTracker tracking_profile3(
113 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read3"));
114
106 if (*bytes_read == 0) 115 if (*bytes_read == 0)
107 DoneReading(); 116 DoneReading();
108 } else { 117 } else {
109 rv = false; // Error, or a new IO is pending. 118 rv = false; // Error, or a new IO is pending.
110 } 119 }
111 } 120 }
121
122 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
123 tracked_objects::ScopedTracker tracking_profile4(
124 FROM_HERE_WITH_EXPLICIT_FUNCTION("423948 URLRequestJob::Read4"));
125
112 if (rv && *bytes_read == 0) 126 if (rv && *bytes_read == 0)
113 NotifyDone(URLRequestStatus()); 127 NotifyDone(URLRequestStatus());
114 return rv; 128 return rv;
115 } 129 }
116 130
117 void URLRequestJob::StopCaching() { 131 void URLRequestJob::StopCaching() {
118 // Nothing to do here. 132 // Nothing to do here.
119 } 133 }
120 134
121 bool URLRequestJob::GetFullRequestHeaders(HttpRequestHeaders* headers) const { 135 bool URLRequestJob::GetFullRequestHeaders(HttpRequestHeaders* headers) const {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 494
481 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. 495 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
482 tracked_objects::ScopedTracker tracking_profile10( 496 tracked_objects::ScopedTracker tracking_profile10(
483 FROM_HERE_WITH_EXPLICIT_FUNCTION( 497 FROM_HERE_WITH_EXPLICIT_FUNCTION(
484 "423948 URLRequestJob::NotifyHeadersComplete 10")); 498 "423948 URLRequestJob::NotifyHeadersComplete 10"));
485 499
486 request_->NotifyResponseStarted(); 500 request_->NotifyResponseStarted();
487 } 501 }
488 502
489 void URLRequestJob::NotifyReadComplete(int bytes_read) { 503 void URLRequestJob::NotifyReadComplete(int bytes_read) {
504 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
505 tracked_objects::ScopedTracker tracking_profile(
506 FROM_HERE_WITH_EXPLICIT_FUNCTION("URLRequestJob::NotifyReadComplete"));
507
490 if (!request_ || !request_->has_delegate()) 508 if (!request_ || !request_->has_delegate())
491 return; // The request was destroyed, so there is no more work to do. 509 return; // The request was destroyed, so there is no more work to do.
492 510
493 // TODO(darin): Bug 1004233. Re-enable this test once all of the chrome 511 // TODO(darin): Bug 1004233. Re-enable this test once all of the chrome
494 // unit_tests have been fixed to not trip this. 512 // unit_tests have been fixed to not trip this.
495 #if 0 513 #if 0
496 DCHECK(!request_->status().is_io_pending()); 514 DCHECK(!request_->status().is_io_pending());
497 #endif 515 #endif
498 // The headers should be complete before reads complete 516 // The headers should be complete before reads complete
499 DCHECK(has_handled_response_); 517 DCHECK(has_handled_response_);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (!filter_->stream_data_len() && !is_done()) { 812 if (!filter_->stream_data_len() && !is_done()) {
795 IOBuffer* stream_buffer = filter_->stream_buffer(); 813 IOBuffer* stream_buffer = filter_->stream_buffer();
796 int stream_buffer_size = filter_->stream_buffer_size(); 814 int stream_buffer_size = filter_->stream_buffer_size();
797 rv = ReadRawDataHelper(stream_buffer, stream_buffer_size, bytes_read); 815 rv = ReadRawDataHelper(stream_buffer, stream_buffer_size, bytes_read);
798 } 816 }
799 return rv; 817 return rv;
800 } 818 }
801 819
802 bool URLRequestJob::ReadRawDataHelper(IOBuffer* buf, int buf_size, 820 bool URLRequestJob::ReadRawDataHelper(IOBuffer* buf, int buf_size,
803 int* bytes_read) { 821 int* bytes_read) {
822 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
823 tracked_objects::ScopedTracker tracking_profile(
824 FROM_HERE_WITH_EXPLICIT_FUNCTION(
825 "423948 URLRequestJob::ReadRawDataHelper"));
826
804 DCHECK(!request_->status().is_io_pending()); 827 DCHECK(!request_->status().is_io_pending());
805 DCHECK(raw_read_buffer_.get() == NULL); 828 DCHECK(raw_read_buffer_.get() == NULL);
806 829
807 // Keep a pointer to the read buffer, so we have access to it in the 830 // Keep a pointer to the read buffer, so we have access to it in the
808 // OnRawReadComplete() callback in the event that the read completes 831 // OnRawReadComplete() callback in the event that the read completes
809 // asynchronously. 832 // asynchronously.
810 raw_read_buffer_ = buf; 833 raw_read_buffer_ = buf;
811 bool rv = ReadRawData(buf, buf_size, bytes_read); 834 bool rv = ReadRawData(buf, buf_size, bytes_read);
812 835
813 if (!request_->status().is_io_pending()) { 836 if (!request_->status().is_io_pending()) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). 924 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS).
902 redirect_info.new_referrer = 925 redirect_info.new_referrer =
903 ComputeReferrerForRedirect(request_->referrer_policy(), 926 ComputeReferrerForRedirect(request_->referrer_policy(),
904 request_->referrer(), 927 request_->referrer(),
905 redirect_info.new_url).spec(); 928 redirect_info.new_url).spec();
906 929
907 return redirect_info; 930 return redirect_info;
908 } 931 }
909 932
910 } // namespace net 933 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/crash_cache/crash_cache.cc ('k') | services/surfaces/surfaces_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698