| 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" |
| 11 #include "net/base/load_timing_info.h" | 11 #include "net/base/load_timing_info.h" |
| 12 #include "net/base/upload_progress.h" | 12 #include "net/base/upload_progress.h" |
| 13 #include "net/http/http_response_info.h" |
| 13 #include "net/socket/connection_attempts.h" | 14 #include "net/socket/connection_attempts.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 | 17 |
| 17 class AuthCredentials; | 18 class AuthCredentials; |
| 18 class BoundNetLog; | 19 class BoundNetLog; |
| 19 class HttpRequestHeaders; | 20 class HttpRequestHeaders; |
| 20 class IOBuffer; | 21 class IOBuffer; |
| 21 class X509Certificate; | 22 class X509Certificate; |
| 22 | 23 |
| 23 struct HttpRequestInfo; | |
| 24 | |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 // 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. |
| 28 // These transactions can be generated by the FailingHttpTransactionFactory | 27 // These transactions can be generated by the FailingHttpTransactionFactory |
| 29 // to test interactions between cache and network. | 28 // to test interactions between cache and network. |
| 30 class FailingHttpTransaction : public HttpTransaction { | 29 class FailingHttpTransaction : public HttpTransaction { |
| 31 public: | 30 public: |
| 32 explicit FailingHttpTransaction(Error error); | 31 explicit FailingHttpTransaction(Error error); |
| 33 ~FailingHttpTransaction() override; | 32 ~FailingHttpTransaction() override; |
| 34 | 33 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 59 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; | 58 WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; |
| 60 void SetBeforeNetworkStartCallback( | 59 void SetBeforeNetworkStartCallback( |
| 61 const BeforeNetworkStartCallback& callback) override; | 60 const BeforeNetworkStartCallback& callback) override; |
| 62 void SetBeforeProxyHeadersSentCallback( | 61 void SetBeforeProxyHeadersSentCallback( |
| 63 const BeforeProxyHeadersSentCallback& callback) override; | 62 const BeforeProxyHeadersSentCallback& callback) override; |
| 64 int ResumeNetworkStart() override; | 63 int ResumeNetworkStart() override; |
| 65 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 64 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 Error error_; | 67 Error error_; |
| 68 HttpResponseInfo response_; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 FailingHttpTransaction::FailingHttpTransaction(Error error) : error_(error) { | 71 FailingHttpTransaction::FailingHttpTransaction(Error error) : error_(error) { |
| 72 DCHECK_LT(error, OK); | 72 DCHECK_LT(error, OK); |
| 73 } | 73 } |
| 74 | 74 |
| 75 FailingHttpTransaction::~FailingHttpTransaction() {} | 75 FailingHttpTransaction::~FailingHttpTransaction() {} |
| 76 | 76 |
| 77 int FailingHttpTransaction::Start(const HttpRequestInfo* request_info, | 77 int FailingHttpTransaction::Start(const HttpRequestInfo* request_info, |
| 78 const CompletionCallback& callback, | 78 const CompletionCallback& callback, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 int64 FailingHttpTransaction::GetTotalReceivedBytes() const { | 119 int64 FailingHttpTransaction::GetTotalReceivedBytes() const { |
| 120 return 0; | 120 return 0; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void FailingHttpTransaction::DoneReading() { | 123 void FailingHttpTransaction::DoneReading() { |
| 124 NOTREACHED(); | 124 NOTREACHED(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 const HttpResponseInfo* FailingHttpTransaction::GetResponseInfo() const { | 127 const HttpResponseInfo* FailingHttpTransaction::GetResponseInfo() const { |
| 128 return NULL; | 128 return &response_; |
| 129 } | 129 } |
| 130 | 130 |
| 131 LoadState FailingHttpTransaction::GetLoadState() const { | 131 LoadState FailingHttpTransaction::GetLoadState() const { |
| 132 return LOAD_STATE_IDLE; | 132 return LOAD_STATE_IDLE; |
| 133 } | 133 } |
| 134 | 134 |
| 135 UploadProgress FailingHttpTransaction::GetUploadProgress() const { | 135 UploadProgress FailingHttpTransaction::GetUploadProgress() const { |
| 136 return UploadProgress(); | 136 return UploadProgress(); |
| 137 } | 137 } |
| 138 | 138 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 HttpCache* FailingHttpTransactionFactory::GetCache() { | 191 HttpCache* FailingHttpTransactionFactory::GetCache() { |
| 192 return NULL; | 192 return NULL; |
| 193 } | 193 } |
| 194 | 194 |
| 195 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { | 195 HttpNetworkSession* FailingHttpTransactionFactory::GetSession() { |
| 196 return session_; | 196 return session_; |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace net | 199 } // namespace net |
| 200 | 200 |
| OLD | NEW |