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 int ReadRawData(IOBuffer* buf, int buf_size) override; | 42 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) 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(); | |
75 | 74 |
76 private: | 75 private: |
77 HttpResponseInfo response_info_; | 76 HttpResponseInfo response_info_; |
78 const FailurePhase phase_; | 77 const FailurePhase phase_; |
79 const int net_error_; | 78 const int net_error_; |
80 | 79 |
81 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; | 80 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; |
82 | 81 |
83 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); | 82 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); |
84 }; | 83 }; |
85 | 84 |
86 } // namespace net | 85 } // namespace net |
87 | 86 |
88 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 87 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
OLD | NEW |