OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/http/failing_http_transaction_factory.h" | 5 #include "net/http/failing_http_transaction_factory.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "net/base/load_timing_info.h" | 15 #include "net/base/load_timing_info.h" |
16 #include "net/base/upload_progress.h" | 16 #include "net/base/upload_progress.h" |
17 #include "net/http/http_response_info.h" | 17 #include "net/http/http_response_info.h" |
18 #include "net/socket/connection_attempts.h" | 18 #include "net/socket/connection_attempts.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 class AuthCredentials; | 22 class AuthCredentials; |
23 class BoundNetLog; | 23 class BoundNetLog; |
24 class HttpRequestHeaders; | 24 class HttpRequestHeaders; |
25 class IOBuffer; | 25 class IOBuffer; |
| 26 class SSLPrivateKey; |
26 class X509Certificate; | 27 class X509Certificate; |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // A simple class to interpose between the cache and network http layers. | 31 // A simple class to interpose between the cache and network http layers. |
31 // These transactions can be generated by the FailingHttpTransactionFactory | 32 // These transactions can be generated by the FailingHttpTransactionFactory |
32 // to test interactions between cache and network. | 33 // to test interactions between cache and network. |
33 class FailingHttpTransaction : public HttpTransaction { | 34 class FailingHttpTransaction : public HttpTransaction { |
34 public: | 35 public: |
35 explicit FailingHttpTransaction(Error error); | 36 explicit FailingHttpTransaction(Error error); |
36 ~FailingHttpTransaction() override; | 37 ~FailingHttpTransaction() override; |
37 | 38 |
38 // HttpTransaction | 39 // HttpTransaction |
39 int Start(const HttpRequestInfo* request_info, | 40 int Start(const HttpRequestInfo* request_info, |
40 const CompletionCallback& callback, | 41 const CompletionCallback& callback, |
41 const BoundNetLog& net_log) override; | 42 const BoundNetLog& net_log) override; |
42 int RestartIgnoringLastError(const CompletionCallback& callback) override; | 43 int RestartIgnoringLastError(const CompletionCallback& callback) override; |
43 int RestartWithCertificate(X509Certificate* client_cert, | 44 int RestartWithCertificate(X509Certificate* client_cert, |
| 45 SSLPrivateKey* client_private_key, |
44 const CompletionCallback& callback) override; | 46 const CompletionCallback& callback) override; |
45 int RestartWithAuth(const AuthCredentials& credentials, | 47 int RestartWithAuth(const AuthCredentials& credentials, |
46 const CompletionCallback& callback) override; | 48 const CompletionCallback& callback) override; |
47 bool IsReadyToRestartForAuth() override; | 49 bool IsReadyToRestartForAuth() override; |
48 int Read(IOBuffer* buf, | 50 int Read(IOBuffer* buf, |
49 int buf_len, | 51 int buf_len, |
50 const CompletionCallback& callback) override; | 52 const CompletionCallback& callback) override; |
51 void StopCaching() override; | 53 void StopCaching() override; |
52 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; | 54 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; |
53 int64_t GetTotalReceivedBytes() const override; | 55 int64_t GetTotalReceivedBytes() const override; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return ERR_IO_PENDING; | 90 return ERR_IO_PENDING; |
89 } | 91 } |
90 | 92 |
91 int FailingHttpTransaction::RestartIgnoringLastError( | 93 int FailingHttpTransaction::RestartIgnoringLastError( |
92 const CompletionCallback& callback) { | 94 const CompletionCallback& callback) { |
93 return ERR_FAILED; | 95 return ERR_FAILED; |
94 } | 96 } |
95 | 97 |
96 int FailingHttpTransaction::RestartWithCertificate( | 98 int FailingHttpTransaction::RestartWithCertificate( |
97 X509Certificate* client_cert, | 99 X509Certificate* client_cert, |
98 const CompletionCallback& callback) { | 100 SSLPrivateKey* client_private_key, |
| 101 const CompletionCallback& callback) { |
99 return ERR_FAILED; | 102 return ERR_FAILED; |
100 } | 103 } |
101 | 104 |
102 int FailingHttpTransaction::RestartWithAuth( | 105 int FailingHttpTransaction::RestartWithAuth( |
103 const AuthCredentials& credentials, | 106 const AuthCredentials& credentials, |
104 const CompletionCallback& callback) { | 107 const CompletionCallback& callback) { |
105 return ERR_FAILED; | 108 return ERR_FAILED; |
106 } | 109 } |
107 | 110 |
108 bool FailingHttpTransaction::IsReadyToRestartForAuth() { | 111 bool FailingHttpTransaction::IsReadyToRestartForAuth() { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 207 |
205 HttpCache* FailingHttpTransactionFactory::GetCache() { | 208 HttpCache* FailingHttpTransactionFactory::GetCache() { |
206 return NULL; | 209 return NULL; |
207 } | 210 } |
208 | 211 |
209 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { | 212 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { |
210 return session_; | 213 return session_; |
211 } | 214 } |
212 | 215 |
213 } // namespace net | 216 } // namespace net |
214 | |
OLD | NEW |