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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 struct HttpRequestInfo; | 22 struct HttpRequestInfo; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // A simple class to interpose between the cache and network http layers. | 26 // A simple class to interpose between the cache and network http layers. |
27 // These transactions can be generated by the FailingHttpTransactionFactory | 27 // These transactions can be generated by the FailingHttpTransactionFactory |
28 // to test interactions between cache and network. | 28 // to test interactions between cache and network. |
29 class FailingHttpTransaction : public HttpTransaction { | 29 class FailingHttpTransaction : public HttpTransaction { |
30 public: | 30 public: |
31 explicit FailingHttpTransaction(Error error); | 31 explicit FailingHttpTransaction(Error error); |
32 virtual ~FailingHttpTransaction(); | 32 ~FailingHttpTransaction() override; |
33 | 33 |
34 // HttpTransaction | 34 // HttpTransaction |
35 virtual int Start(const HttpRequestInfo* request_info, | 35 int Start(const HttpRequestInfo* request_info, |
36 const CompletionCallback& callback, | 36 const CompletionCallback& callback, |
37 const BoundNetLog& net_log) override; | 37 const BoundNetLog& net_log) override; |
38 virtual int RestartIgnoringLastError( | 38 int RestartIgnoringLastError(const CompletionCallback& callback) override; |
39 const CompletionCallback& callback) override; | 39 int RestartWithCertificate(X509Certificate* client_cert, |
40 virtual int RestartWithCertificate( | 40 const CompletionCallback& callback) override; |
41 X509Certificate* client_cert, | 41 int RestartWithAuth(const AuthCredentials& credentials, |
42 const CompletionCallback& callback) override; | 42 const CompletionCallback& callback) override; |
43 virtual int RestartWithAuth( | 43 bool IsReadyToRestartForAuth() override; |
44 const AuthCredentials& credentials, | 44 int Read(IOBuffer* buf, |
45 const CompletionCallback& callback) override; | 45 int buf_len, |
46 virtual bool IsReadyToRestartForAuth() override; | 46 const CompletionCallback& callback) override; |
47 virtual int Read(IOBuffer* buf, int buf_len, | 47 void StopCaching() override; |
48 const CompletionCallback& callback) override; | 48 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; |
49 virtual void StopCaching() override; | 49 int64 GetTotalReceivedBytes() const override; |
50 virtual bool GetFullRequestHeaders( | 50 void DoneReading() override; |
51 HttpRequestHeaders* headers) const override; | 51 const HttpResponseInfo* GetResponseInfo() const override; |
52 virtual int64 GetTotalReceivedBytes() const override; | 52 LoadState GetLoadState() const override; |
53 virtual void DoneReading() override; | 53 UploadProgress GetUploadProgress() const override; |
54 virtual const HttpResponseInfo* GetResponseInfo() const override; | 54 void SetQuicServerInfo(net::QuicServerInfo* quic_server_info) override; |
55 virtual LoadState GetLoadState() const override; | 55 bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
56 virtual UploadProgress GetUploadProgress() const override; | 56 void SetPriority(RequestPriority priority) override; |
57 virtual void SetQuicServerInfo( | 57 void SetWebSocketHandshakeStreamCreateHelper( |
58 net::QuicServerInfo* quic_server_info) override; | |
59 virtual bool GetLoadTimingInfo( | |
60 LoadTimingInfo* load_timing_info) const override; | |
61 virtual void SetPriority(RequestPriority priority) override; | |
62 virtual void SetWebSocketHandshakeStreamCreateHelper( | |
63 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; | 58 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; |
64 virtual void SetBeforeNetworkStartCallback( | 59 void SetBeforeNetworkStartCallback( |
65 const BeforeNetworkStartCallback& callback) override; | 60 const BeforeNetworkStartCallback& callback) override; |
66 virtual void SetBeforeProxyHeadersSentCallback( | 61 void SetBeforeProxyHeadersSentCallback( |
67 const BeforeProxyHeadersSentCallback& callback) override; | 62 const BeforeProxyHeadersSentCallback& callback) override; |
68 virtual int ResumeNetworkStart() override; | 63 int ResumeNetworkStart() override; |
69 | 64 |
70 private: | 65 private: |
71 Error error_; | 66 Error error_; |
72 }; | 67 }; |
73 | 68 |
74 FailingHttpTransaction::FailingHttpTransaction(Error error) : error_(error) { | 69 FailingHttpTransaction::FailingHttpTransaction(Error error) : error_(error) { |
75 DCHECK_LT(error, OK); | 70 DCHECK_LT(error, OK); |
76 } | 71 } |
77 | 72 |
78 FailingHttpTransaction::~FailingHttpTransaction() {} | 73 FailingHttpTransaction::~FailingHttpTransaction() {} |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 HttpCache* FailingHttpTransactionFactory::GetCache() { | 183 HttpCache* FailingHttpTransactionFactory::GetCache() { |
189 return NULL; | 184 return NULL; |
190 } | 185 } |
191 | 186 |
192 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { | 187 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { |
193 return session_; | 188 return session_; |
194 } | 189 } |
195 | 190 |
196 } // namespace net | 191 } // namespace net |
197 | 192 |
OLD | NEW |