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

Side by Side Diff: net/test/url_request/url_request_failed_job.cc

Issue 2514713002: Send encoded_body_length to renderer when response completed (1/3) (Closed)
Patch Set: merge https://codereview.chromium.org/2526653002/ Created 4 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/test/url_request/url_request_failed_job.h ('k') | no next file » | 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/test/url_request/url_request_failed_job.h" 5 #include "net/test/url_request/url_request_failed_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 } // namespace 78 } // namespace
79 79
80 URLRequestFailedJob::URLRequestFailedJob(URLRequest* request, 80 URLRequestFailedJob::URLRequestFailedJob(URLRequest* request,
81 NetworkDelegate* network_delegate, 81 NetworkDelegate* network_delegate,
82 FailurePhase phase, 82 FailurePhase phase,
83 int net_error) 83 int net_error)
84 : URLRequestJob(request, network_delegate), 84 : URLRequestJob(request, network_delegate),
85 phase_(phase), 85 phase_(phase),
86 net_error_(net_error), 86 net_error_(net_error),
87 total_received_bytes_(0),
87 weak_factory_(this) { 88 weak_factory_(this) {
88 CHECK_GE(phase, URLRequestFailedJob::FailurePhase::START); 89 CHECK_GE(phase, URLRequestFailedJob::FailurePhase::START);
89 CHECK_LE(phase, URLRequestFailedJob::FailurePhase::READ_ASYNC); 90 CHECK_LE(phase, URLRequestFailedJob::FailurePhase::READ_ASYNC);
90 CHECK_LT(net_error, OK); 91 CHECK_LT(net_error, OK);
91 } 92 }
92 93
93 URLRequestFailedJob::URLRequestFailedJob(URLRequest* request, 94 URLRequestFailedJob::URLRequestFailedJob(URLRequest* request,
94 NetworkDelegate* network_delegate, 95 NetworkDelegate* network_delegate,
95 int net_error) 96 int net_error)
96 : URLRequestFailedJob(request, network_delegate, START, net_error) { 97 : URLRequestFailedJob(request, network_delegate, START, net_error) {
(...skipping 27 matching lines...) Expand all
124 *info = response_info_; 125 *info = response_info_;
125 } 126 }
126 127
127 void URLRequestFailedJob::PopulateNetErrorDetails( 128 void URLRequestFailedJob::PopulateNetErrorDetails(
128 NetErrorDetails* details) const { 129 NetErrorDetails* details) const {
129 if (net_error_ == ERR_QUIC_PROTOCOL_ERROR) { 130 if (net_error_ == ERR_QUIC_PROTOCOL_ERROR) {
130 details->quic_connection_error = QUIC_INTERNAL_ERROR; 131 details->quic_connection_error = QUIC_INTERNAL_ERROR;
131 } 132 }
132 } 133 }
133 134
135 int64_t URLRequestFailedJob::GetTotalReceivedBytes() const {
136 return total_received_bytes_;
137 }
138
134 // static 139 // static
135 void URLRequestFailedJob::AddUrlHandler() { 140 void URLRequestFailedJob::AddUrlHandler() {
136 return AddUrlHandlerForHostname(kMockHostname); 141 return AddUrlHandlerForHostname(kMockHostname);
137 } 142 }
138 143
139 // static 144 // static
140 void URLRequestFailedJob::AddUrlHandlerForHostname( 145 void URLRequestFailedJob::AddUrlHandlerForHostname(
141 const std::string& hostname) { 146 const std::string& hostname) {
142 URLRequestFilter* filter = URLRequestFilter::GetInstance(); 147 URLRequestFilter* filter = URLRequestFilter::GetInstance();
143 // Add |hostname| to URLRequestFilter for HTTP and HTTPS. 148 // Add |hostname| to URLRequestFilter for HTTP and HTTPS.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 188 }
184 189
185 void URLRequestFailedJob::StartAsync() { 190 void URLRequestFailedJob::StartAsync() {
186 if (phase_ == START) { 191 if (phase_ == START) {
187 if (net_error_ != ERR_IO_PENDING) { 192 if (net_error_ != ERR_IO_PENDING) {
188 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, net_error_)); 193 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, net_error_));
189 return; 194 return;
190 } 195 }
191 return; 196 return;
192 } 197 }
193 response_info_.headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); 198 const std::string headers = "HTTP/1.1 200 OK";
199 response_info_.headers = new net::HttpResponseHeaders(headers);
200 total_received_bytes_ = headers.size();
194 NotifyHeadersComplete(); 201 NotifyHeadersComplete();
195 } 202 }
196 203
197 } // namespace net 204 } // namespace net
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_failed_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698