| 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 "content/test/net/url_request_failed_job.h" | 5 #include "content/test/net/url_request_failed_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 13 #include "net/url_request/url_request_filter.h" | 13 #include "net/url_request/url_request_filter.h" |
| 14 | 14 |
| 15 namespace content { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const char kMockHostname[] = "mock.failed.request"; | 18 const char kMockHostname[] = "mock.failed.request"; |
| 18 | 19 |
| 19 // Gets the numeric net error code from URL of the form: | 20 // Gets the numeric net error code from URL of the form: |
| 20 // scheme://kMockHostname/error_code. The error code must be a valid | 21 // scheme://kMockHostname/error_code. The error code must be a valid |
| 21 // net error code, and not net::OK or net::ERR_IO_PENDING. | 22 // net error code, and not net::OK or net::ERR_IO_PENDING. |
| 22 int GetErrorCode(net::URLRequest* request) { | 23 int GetErrorCode(net::URLRequest* request) { |
| 23 int net_error; | 24 int net_error; |
| 24 std::string path = request->url().path(); | 25 std::string path = request->url().path(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 net::NetworkDelegate* network_delegate, | 83 net::NetworkDelegate* network_delegate, |
| 83 const std::string& scheme) { | 84 const std::string& scheme) { |
| 84 return new URLRequestFailedJob( | 85 return new URLRequestFailedJob( |
| 85 request, network_delegate, GetErrorCode(request)); | 86 request, network_delegate, GetErrorCode(request)); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void URLRequestFailedJob::StartAsync() { | 89 void URLRequestFailedJob::StartAsync() { |
| 89 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, | 90 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
| 90 net_error_)); | 91 net_error_)); |
| 91 } | 92 } |
| 93 |
| 94 } // namespace content |
| OLD | NEW |