| OLD | NEW |
| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 std::string path_str = path.MaybeAsASCII(); | 126 std::string path_str = path.MaybeAsASCII(); |
| 127 DCHECK(!path_str.empty()); // We only expect ASCII paths in tests. | 127 DCHECK(!path_str.empty()); // We only expect ASCII paths in tests. |
| 128 url.append(path_str); | 128 url.append(path_str); |
| 129 return GURL(url); | 129 return GURL(url); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // static | 132 // static |
| 133 GURL URLRequestMockHTTPJob::GetMockUrlWithFailure(const base::FilePath& path, | 133 GURL URLRequestMockHTTPJob::GetMockUrlWithFailure(const base::FilePath& path, |
| 134 FailurePhase phase, | 134 FailurePhase phase, |
| 135 int net_error) { | 135 int net_error) { |
| 136 COMPILE_ASSERT(arraysize(kFailurePhase) == MAX_FAILURE_PHASE, | 136 static_assert(arraysize(kFailurePhase) == MAX_FAILURE_PHASE, |
| 137 kFailurePhase_must_match_FailurePhase_enum); | 137 "kFailurePhase must match FailurePhase enum"); |
| 138 DCHECK_GE(phase, START); | 138 DCHECK_GE(phase, START); |
| 139 DCHECK_LE(phase, READ_SYNC); | 139 DCHECK_LE(phase, READ_SYNC); |
| 140 std::string url(GetMockUrl(path).spec()); | 140 std::string url(GetMockUrl(path).spec()); |
| 141 url.append("?"); | 141 url.append("?"); |
| 142 url.append(kFailurePhase[phase]); | 142 url.append(kFailurePhase[phase]); |
| 143 url.append("="); | 143 url.append("="); |
| 144 url.append(base::IntToString(net_error)); | 144 url.append(base::IntToString(net_error)); |
| 145 return GURL(url); | 145 return GURL(url); |
| 146 } | 146 } |
| 147 | 147 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 return net::URLRequestJob::GetResponseCode(); | 277 return net::URLRequestJob::GetResponseCode(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 280 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
| 281 net::HttpResponseInfo info; | 281 net::HttpResponseInfo info; |
| 282 GetResponseInfo(&info); | 282 GetResponseInfo(&info); |
| 283 return info.headers.get() && info.headers->GetCharset(charset); | 283 return info.headers.get() && info.headers->GetCharset(charset); |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace net | 286 } // namespace net |
| OLD | NEW |