| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |