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/threading/thread_task_runner_handle.h" | 14 #include "base/threading/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/net_error_details.h" | 16 #include "net/base/net_error_details.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 NetLogWithSource; |
24 class HttpRequestHeaders; | 24 class HttpRequestHeaders; |
25 class IOBuffer; | 25 class IOBuffer; |
26 class SSLPrivateKey; | 26 class SSLPrivateKey; |
27 class X509Certificate; | 27 class X509Certificate; |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // 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. |
32 // These transactions can be generated by the FailingHttpTransactionFactory | 32 // These transactions can be generated by the FailingHttpTransactionFactory |
33 // to test interactions between cache and network. | 33 // to test interactions between cache and network. |
34 class FailingHttpTransaction : public HttpTransaction { | 34 class FailingHttpTransaction : public HttpTransaction { |
35 public: | 35 public: |
36 explicit FailingHttpTransaction(Error error); | 36 explicit FailingHttpTransaction(Error error); |
37 ~FailingHttpTransaction() override; | 37 ~FailingHttpTransaction() override; |
38 | 38 |
39 // HttpTransaction | 39 // HttpTransaction |
40 int Start(const HttpRequestInfo* request_info, | 40 int Start(const HttpRequestInfo* request_info, |
41 const CompletionCallback& callback, | 41 const CompletionCallback& callback, |
42 const BoundNetLog& net_log) override; | 42 const NetLogWithSource& net_log) override; |
43 int RestartIgnoringLastError(const CompletionCallback& callback) override; | 43 int RestartIgnoringLastError(const CompletionCallback& callback) override; |
44 int RestartWithCertificate(X509Certificate* client_cert, | 44 int RestartWithCertificate(X509Certificate* client_cert, |
45 SSLPrivateKey* client_private_key, | 45 SSLPrivateKey* client_private_key, |
46 const CompletionCallback& callback) override; | 46 const CompletionCallback& callback) override; |
47 int RestartWithAuth(const AuthCredentials& credentials, | 47 int RestartWithAuth(const AuthCredentials& credentials, |
48 const CompletionCallback& callback) override; | 48 const CompletionCallback& callback) override; |
49 bool IsReadyToRestartForAuth() override; | 49 bool IsReadyToRestartForAuth() override; |
50 int Read(IOBuffer* buf, | 50 int Read(IOBuffer* buf, |
51 int buf_len, | 51 int buf_len, |
52 const CompletionCallback& callback) override; | 52 const CompletionCallback& callback) override; |
(...skipping 24 matching lines...) Expand all Loading... |
77 }; | 77 }; |
78 | 78 |
79 FailingHttpTransaction::FailingHttpTransaction(Error error) : error_(error) { | 79 FailingHttpTransaction::FailingHttpTransaction(Error error) : error_(error) { |
80 DCHECK_LT(error, OK); | 80 DCHECK_LT(error, OK); |
81 } | 81 } |
82 | 82 |
83 FailingHttpTransaction::~FailingHttpTransaction() {} | 83 FailingHttpTransaction::~FailingHttpTransaction() {} |
84 | 84 |
85 int FailingHttpTransaction::Start(const HttpRequestInfo* request_info, | 85 int FailingHttpTransaction::Start(const HttpRequestInfo* request_info, |
86 const CompletionCallback& callback, | 86 const CompletionCallback& callback, |
87 const BoundNetLog& net_log) { | 87 const NetLogWithSource& net_log) { |
88 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 88 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
89 base::Bind(callback, error_)); | 89 base::Bind(callback, error_)); |
90 return ERR_IO_PENDING; | 90 return ERR_IO_PENDING; |
91 } | 91 } |
92 | 92 |
93 int FailingHttpTransaction::RestartIgnoringLastError( | 93 int FailingHttpTransaction::RestartIgnoringLastError( |
94 const CompletionCallback& callback) { | 94 const CompletionCallback& callback) { |
95 return ERR_FAILED; | 95 return ERR_FAILED; |
96 } | 96 } |
97 | 97 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 HttpCache* FailingHttpTransactionFactory::GetCache() { | 208 HttpCache* FailingHttpTransactionFactory::GetCache() { |
209 return NULL; | 209 return NULL; |
210 } | 210 } |
211 | 211 |
212 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { | 212 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { |
213 return session_; | 213 return session_; |
214 } | 214 } |
215 | 215 |
216 } // namespace net | 216 } // namespace net |
OLD | NEW |