| 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 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 5 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
| 6 #define NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 6 #define NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 FailurePhase phase, | 32 FailurePhase phase, |
| 33 int net_error); | 33 int net_error); |
| 34 | 34 |
| 35 // Same as above, except that the job fails at FailurePhase.START. | 35 // Same as above, except that the job fails at FailurePhase.START. |
| 36 URLRequestFailedJob(URLRequest* request, | 36 URLRequestFailedJob(URLRequest* request, |
| 37 NetworkDelegate* network_delegate, | 37 NetworkDelegate* network_delegate, |
| 38 int net_error); | 38 int net_error); |
| 39 | 39 |
| 40 // URLRequestJob implementation: | 40 // URLRequestJob implementation: |
| 41 void Start() override; | 41 void Start() override; |
| 42 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override; | 42 int ReadRawData(IOBuffer* buf, int buf_size) override; |
| 43 int GetResponseCode() const override; | 43 int GetResponseCode() const override; |
| 44 void GetResponseInfo(HttpResponseInfo* info) override; | 44 void GetResponseInfo(HttpResponseInfo* info) override; |
| 45 | 45 |
| 46 // Adds the testing URLs to the URLRequestFilter. | 46 // Adds the testing URLs to the URLRequestFilter. |
| 47 static void AddUrlHandler(); | 47 static void AddUrlHandler(); |
| 48 static void AddUrlHandlerForHostname(const std::string& hostname); | 48 static void AddUrlHandlerForHostname(const std::string& hostname); |
| 49 | 49 |
| 50 // Given a net error code, constructs a mock URL that will return that error | 50 // Given a net error code, constructs a mock URL that will return that error |
| 51 // asynchronously when started. |net_error| must be a valid net error code | 51 // asynchronously when started. |net_error| must be a valid net error code |
| 52 // other than net::OK. Passing net::ERR_IO_PENDING for |net_error| causes the | 52 // other than net::OK. Passing net::ERR_IO_PENDING for |net_error| causes the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 // return that error asynchronously when started. |net_error| must be a valid | 64 // return that error asynchronously when started. |net_error| must be a valid |
| 65 // net error code other than net::OK. Passing net::ERR_IO_PENDING for | 65 // net error code other than net::OK. Passing net::ERR_IO_PENDING for |
| 66 // |net_error| causes the resulting request to hang. | 66 // |net_error| causes the resulting request to hang. |
| 67 static GURL GetMockHttpUrlForHostname(int net_error, | 67 static GURL GetMockHttpUrlForHostname(int net_error, |
| 68 const std::string& hostname); | 68 const std::string& hostname); |
| 69 static GURL GetMockHttpsUrlForHostname(int net_error, | 69 static GURL GetMockHttpsUrlForHostname(int net_error, |
| 70 const std::string& hostname); | 70 const std::string& hostname); |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 ~URLRequestFailedJob() override; | 73 ~URLRequestFailedJob() override; |
| 74 void StartAsync(); |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 HttpResponseInfo response_info_; | 77 HttpResponseInfo response_info_; |
| 77 const FailurePhase phase_; | 78 const FailurePhase phase_; |
| 78 const int net_error_; | 79 const int net_error_; |
| 79 | 80 |
| 80 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; | 81 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); | 83 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace net | 86 } // namespace net |
| 86 | 87 |
| 87 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 88 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
| OLD | NEW |