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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return ERR_IO_PENDING; | 89 return ERR_IO_PENDING; |
88 } | 90 } |
89 | 91 |
90 int FailingHttpTransaction::RestartIgnoringLastError( | 92 int FailingHttpTransaction::RestartIgnoringLastError( |
91 const CompletionCallback& callback) { | 93 const CompletionCallback& callback) { |
92 return ERR_FAILED; | 94 return ERR_FAILED; |
93 } | 95 } |
94 | 96 |
95 int FailingHttpTransaction::RestartWithCertificate( | 97 int FailingHttpTransaction::RestartWithCertificate( |
96 X509Certificate* client_cert, | 98 X509Certificate* client_cert, |
97 const CompletionCallback& callback) { | 99 SSLPrivateKey* client_private_key, |
| 100 const CompletionCallback& callback) { |
98 return ERR_FAILED; | 101 return ERR_FAILED; |
99 } | 102 } |
100 | 103 |
101 int FailingHttpTransaction::RestartWithAuth( | 104 int FailingHttpTransaction::RestartWithAuth( |
102 const AuthCredentials& credentials, | 105 const AuthCredentials& credentials, |
103 const CompletionCallback& callback) { | 106 const CompletionCallback& callback) { |
104 return ERR_FAILED; | 107 return ERR_FAILED; |
105 } | 108 } |
106 | 109 |
107 bool FailingHttpTransaction::IsReadyToRestartForAuth() { | 110 bool FailingHttpTransaction::IsReadyToRestartForAuth() { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 202 |
200 HttpCache* FailingHttpTransactionFactory::GetCache() { | 203 HttpCache* FailingHttpTransactionFactory::GetCache() { |
201 return NULL; | 204 return NULL; |
202 } | 205 } |
203 | 206 |
204 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { | 207 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { |
205 return session_; | 208 return session_; |
206 } | 209 } |
207 | 210 |
208 } // namespace net | 211 } // namespace net |
209 | |
OLD | NEW |