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

Side by Side Diff: net/test/url_request/url_request_mock_data_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_data_job.h" 5 #include "net/test/url_request/url_request_mock_data_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/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 int URLRequestMockDataJob::ReadRawData(IOBuffer* buf, int buf_size) { 122 int URLRequestMockDataJob::ReadRawData(IOBuffer* buf, int buf_size) {
123 int bytes_read = 123 int bytes_read =
124 std::min(static_cast<size_t>(buf_size), data_.length() - data_offset_); 124 std::min(static_cast<size_t>(buf_size), data_.length() - data_offset_);
125 memcpy(buf->data(), data_.c_str() + data_offset_, bytes_read); 125 memcpy(buf->data(), data_.c_str() + data_offset_, bytes_read);
126 data_offset_ += bytes_read; 126 data_offset_ += bytes_read;
127 return bytes_read; 127 return bytes_read;
128 } 128 }
129 129
130 int URLRequestMockDataJob::GetResponseCode() const {
131 HttpResponseInfo info;
132 GetResponseInfoConst(&info);
133 return info.headers->response_code();
134 }
135
136 void URLRequestMockDataJob::ContinueWithCertificate( 130 void URLRequestMockDataJob::ContinueWithCertificate(
137 X509Certificate* client_cert, 131 X509Certificate* client_cert,
138 SSLPrivateKey* client_private_key) { 132 SSLPrivateKey* client_private_key) {
139 DCHECK(request_client_certificate_); 133 DCHECK(request_client_certificate_);
140 NotifyHeadersComplete(); 134 NotifyHeadersComplete();
141 } 135 }
142 136
143 // Public virtual version. 137 // Public virtual version.
144 void URLRequestMockDataJob::GetResponseInfo(HttpResponseInfo* info) { 138 void URLRequestMockDataJob::GetResponseInfo(HttpResponseInfo* info) {
145 // Forward to private const version. 139 // Forward to private const version.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 208
215 // static 209 // static
216 GURL URLRequestMockDataJob::GetMockHttpsUrlForHostname( 210 GURL URLRequestMockDataJob::GetMockHttpsUrlForHostname(
217 const std::string& hostname, 211 const std::string& hostname,
218 const std::string& data, 212 const std::string& data,
219 int repeat_count) { 213 int repeat_count) {
220 return GetMockUrl("https", hostname, data, repeat_count, false); 214 return GetMockUrl("https", hostname, data, repeat_count, false);
221 } 215 }
222 216
223 } // namespace net 217 } // namespace net
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_mock_data_job.h ('k') | net/test/url_request/url_request_mock_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698