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" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "net/url_request/url_request_job.h" | 12 #include "net/url_request/url_request_job.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class SSLCertRequestInfo; | |
svaldez
2015/11/20 16:30:10
unnecessary? Not used in header?
mef
2015/11/20 16:44:06
Done.
| |
18 | |
17 // This class simulates a URLRequestJob failing with a given error code at | 19 // This class simulates a URLRequestJob failing with a given error code at |
18 // a particular phase while trying to connect. | 20 // a particular phase while trying to connect. |
19 class URLRequestFailedJob : public URLRequestJob { | 21 class URLRequestFailedJob : public URLRequestJob { |
20 public: | 22 public: |
21 // A Java counterpart will be generated for this enum. | 23 // A Java counterpart will be generated for this enum. |
22 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net.test | 24 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net.test |
23 enum FailurePhase { | 25 enum FailurePhase { |
24 START = 0, | 26 START = 0, |
25 READ_SYNC = 1, | 27 READ_SYNC = 1, |
26 READ_ASYNC = 2, | 28 READ_ASYNC = 2, |
27 MAX_FAILURE_PHASE = 3, | 29 CERT_REQUESTED = 3, |
30 MAX_FAILURE_PHASE = 4, | |
28 }; | 31 }; |
29 | 32 |
30 URLRequestFailedJob(URLRequest* request, | 33 URLRequestFailedJob(URLRequest* request, |
31 NetworkDelegate* network_delegate, | 34 NetworkDelegate* network_delegate, |
32 FailurePhase phase, | 35 FailurePhase phase, |
33 int net_error); | 36 int net_error); |
34 | 37 |
35 // Same as above, except that the job fails at FailurePhase.START. | 38 // Same as above, except that the job fails at FailurePhase.START. |
36 URLRequestFailedJob(URLRequest* request, | 39 URLRequestFailedJob(URLRequest* request, |
37 NetworkDelegate* network_delegate, | 40 NetworkDelegate* network_delegate, |
38 int net_error); | 41 int net_error); |
39 | 42 |
40 // URLRequestJob implementation: | 43 // URLRequestJob implementation: |
41 void Start() override; | 44 void Start() override; |
42 int ReadRawData(IOBuffer* buf, int buf_size) override; | 45 int ReadRawData(IOBuffer* buf, int buf_size) override; |
43 int GetResponseCode() const override; | 46 int GetResponseCode() const override; |
44 void GetResponseInfo(HttpResponseInfo* info) override; | 47 void GetResponseInfo(HttpResponseInfo* info) override; |
48 void ContinueWithCertificate(X509Certificate* client_cert, | |
49 SSLPrivateKey* client_private_key) override; | |
45 | 50 |
46 // Adds the testing URLs to the URLRequestFilter. | 51 // Adds the testing URLs to the URLRequestFilter. |
47 static void AddUrlHandler(); | 52 static void AddUrlHandler(); |
48 static void AddUrlHandlerForHostname(const std::string& hostname); | 53 static void AddUrlHandlerForHostname(const std::string& hostname); |
49 | 54 |
50 // Given a net error code, constructs a mock URL that will return that error | 55 // 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 | 56 // 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 | 57 // other than net::OK. Passing net::ERR_IO_PENDING for |net_error| causes the |
53 // resulting request to hang. | 58 // resulting request to hang. |
54 static GURL GetMockHttpUrl(int net_error); | 59 static GURL GetMockHttpUrl(int net_error); |
(...skipping 24 matching lines...) Expand all Loading... | |
79 const int net_error_; | 84 const int net_error_; |
80 | 85 |
81 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; | 86 base::WeakPtrFactory<URLRequestFailedJob> weak_factory_; |
82 | 87 |
83 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); | 88 DISALLOW_COPY_AND_ASSIGN(URLRequestFailedJob); |
84 }; | 89 }; |
85 | 90 |
86 } // namespace net | 91 } // namespace net |
87 | 92 |
88 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ | 93 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_FAILED_JOB_H_ |
OLD | NEW |