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

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

Issue 2676033002: Give URLRequestJob::GetResponseCode a better default implementation. (Closed)
Patch Set: Add headers Created 3 years, 10 months 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
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 CHECK(phase_ == READ_SYNC || phase_ == READ_ASYNC); 107 CHECK(phase_ == READ_SYNC || phase_ == READ_ASYNC);
108 if (net_error_ == ERR_IO_PENDING || phase_ == READ_SYNC) 108 if (net_error_ == ERR_IO_PENDING || phase_ == READ_SYNC)
109 return net_error_; 109 return net_error_;
110 110
111 base::ThreadTaskRunnerHandle::Get()->PostTask( 111 base::ThreadTaskRunnerHandle::Get()->PostTask(
112 FROM_HERE, base::Bind(&URLRequestFailedJob::ReadRawDataComplete, 112 FROM_HERE, base::Bind(&URLRequestFailedJob::ReadRawDataComplete,
113 weak_factory_.GetWeakPtr(), net_error_)); 113 weak_factory_.GetWeakPtr(), net_error_));
114 return ERR_IO_PENDING; 114 return ERR_IO_PENDING;
115 } 115 }
116 116
117 int URLRequestFailedJob::GetResponseCode() const {
118 // If we have headers, get the response code from them.
119 if (response_info_.headers)
120 return response_info_.headers->response_code();
121 return URLRequestJob::GetResponseCode();
122 }
123
124 void URLRequestFailedJob::GetResponseInfo(HttpResponseInfo* info) { 117 void URLRequestFailedJob::GetResponseInfo(HttpResponseInfo* info) {
125 *info = response_info_; 118 *info = response_info_;
126 } 119 }
127 120
128 void URLRequestFailedJob::PopulateNetErrorDetails( 121 void URLRequestFailedJob::PopulateNetErrorDetails(
129 NetErrorDetails* details) const { 122 NetErrorDetails* details) const {
130 if (net_error_ == ERR_QUIC_PROTOCOL_ERROR) { 123 if (net_error_ == ERR_QUIC_PROTOCOL_ERROR) {
131 details->quic_connection_error = QUIC_INTERNAL_ERROR; 124 details->quic_connection_error = QUIC_INTERNAL_ERROR;
132 } 125 }
133 } 126 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 188 }
196 return; 189 return;
197 } 190 }
198 const std::string headers = "HTTP/1.1 200 OK"; 191 const std::string headers = "HTTP/1.1 200 OK";
199 response_info_.headers = new net::HttpResponseHeaders(headers); 192 response_info_.headers = new net::HttpResponseHeaders(headers);
200 total_received_bytes_ = headers.size(); 193 total_received_bytes_ = headers.size();
201 NotifyHeadersComplete(); 194 NotifyHeadersComplete();
202 } 195 }
203 196
204 } // namespace net 197 } // namespace net
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_failed_job.h ('k') | net/test/url_request/url_request_hanging_read_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698