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

Side by Side Diff: net/test/url_request/url_request_mock_http_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_mock_http_job.h" 5 #include "net/test/url_request/url_request_mock_http_job.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 int64_t URLRequestMockHTTPJob::GetTotalReceivedBytes() const { 196 int64_t URLRequestMockHTTPJob::GetTotalReceivedBytes() const {
197 return total_received_bytes_; 197 return total_received_bytes_;
198 } 198 }
199 199
200 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const { 200 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const {
201 HttpResponseInfo info; 201 HttpResponseInfo info;
202 GetResponseInfoConst(&info); 202 GetResponseInfoConst(&info);
203 return info.headers.get() && info.headers->GetMimeType(mime_type); 203 return info.headers.get() && info.headers->GetMimeType(mime_type);
204 } 204 }
205 205
206 int URLRequestMockHTTPJob::GetResponseCode() const {
207 HttpResponseInfo info;
208 GetResponseInfoConst(&info);
209 // If we have headers, get the response code from them.
210 if (info.headers.get())
211 return info.headers->response_code();
212 return URLRequestJob::GetResponseCode();
213 }
214
215 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { 206 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) {
216 HttpResponseInfo info; 207 HttpResponseInfo info;
217 GetResponseInfo(&info); 208 GetResponseInfo(&info);
218 return info.headers.get() && info.headers->GetCharset(charset); 209 return info.headers.get() && info.headers->GetCharset(charset);
219 } 210 }
220 211
221 } // namespace net 212 } // namespace net
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_mock_http_job.h ('k') | net/url_request/test_url_request_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698