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 #ifndef NET_HTTP_HTTP_TRANSACTION_TEST_UTIL_H_ | 5 #ifndef NET_HTTP_HTTP_TRANSACTION_TEST_UTIL_H_ |
6 #define NET_HTTP_HTTP_TRANSACTION_TEST_UTIL_H_ | 6 #define NET_HTTP_HTTP_TRANSACTION_TEST_UTIL_H_ |
7 | 7 |
8 #include "net/http/http_transaction.h" | 8 #include "net/http/http_transaction.h" |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void SetBeforeHeadersSentCallback( | 234 void SetBeforeHeadersSentCallback( |
235 const BeforeHeadersSentCallback& callback) override; | 235 const BeforeHeadersSentCallback& callback) override; |
236 | 236 |
237 int ResumeNetworkStart() override; | 237 int ResumeNetworkStart() override; |
238 | 238 |
239 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 239 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
240 | 240 |
241 CreateHelper* websocket_handshake_stream_create_helper() { | 241 CreateHelper* websocket_handshake_stream_create_helper() { |
242 return websocket_handshake_stream_create_helper_; | 242 return websocket_handshake_stream_create_helper_; |
243 } | 243 } |
| 244 |
| 245 // Error to return on a future Read call. |
| 246 void SetReadError(int error); |
| 247 |
244 RequestPriority priority() const { return priority_; } | 248 RequestPriority priority() const { return priority_; } |
245 const HttpRequestInfo* request() const { return request_; } | 249 const HttpRequestInfo* request() const { return request_; } |
246 | 250 |
247 // Bogus value that will be returned by GetTotalReceivedBytes() if the | 251 // Bogus value that will be returned by GetTotalReceivedBytes() if the |
248 // MockNetworkTransaction was started. | 252 // MockNetworkTransaction was started. |
249 static const int64_t kTotalReceivedBytes; | 253 static const int64_t kTotalReceivedBytes; |
250 // Bogus value that will be returned by GetTotalSentBytes() if the | 254 // Bogus value that will be returned by GetTotalSentBytes() if the |
251 // MockNetworkTransaction was started. | 255 // MockNetworkTransaction was started. |
252 static const int64_t kTotalSentBytes; | 256 static const int64_t kTotalSentBytes; |
253 | 257 |
(...skipping 21 matching lines...) Expand all Loading... |
275 // NetLog ID of the fake / non-existent underlying socket used by the | 279 // NetLog ID of the fake / non-existent underlying socket used by the |
276 // connection. Requires Start() be passed a NetLogWithSource with a real | 280 // connection. Requires Start() be passed a NetLogWithSource with a real |
277 // NetLog to | 281 // NetLog to |
278 // be initialized. | 282 // be initialized. |
279 unsigned int socket_log_id_; | 283 unsigned int socket_log_id_; |
280 | 284 |
281 bool done_reading_called_; | 285 bool done_reading_called_; |
282 | 286 |
283 CompletionCallback resume_start_callback_; // used for pause and restart. | 287 CompletionCallback resume_start_callback_; // used for pause and restart. |
284 | 288 |
| 289 int read_error_; |
| 290 |
285 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; | 291 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; |
286 | 292 |
287 }; | 293 }; |
288 | 294 |
289 class MockNetworkLayer : public HttpTransactionFactory, | 295 class MockNetworkLayer : public HttpTransactionFactory, |
290 public base::SupportsWeakPtr<MockNetworkLayer> { | 296 public base::SupportsWeakPtr<MockNetworkLayer> { |
291 public: | 297 public: |
292 MockNetworkLayer(); | 298 MockNetworkLayer(); |
293 ~MockNetworkLayer() override; | 299 ~MockNetworkLayer() override; |
294 | 300 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 357 |
352 //----------------------------------------------------------------------------- | 358 //----------------------------------------------------------------------------- |
353 // helpers | 359 // helpers |
354 | 360 |
355 // read the transaction completely | 361 // read the transaction completely |
356 int ReadTransaction(HttpTransaction* trans, std::string* result); | 362 int ReadTransaction(HttpTransaction* trans, std::string* result); |
357 | 363 |
358 } // namespace net | 364 } // namespace net |
359 | 365 |
360 #endif // NET_HTTP_HTTP_TRANSACTION_TEST_UTIL_H_ | 366 #endif // NET_HTTP_HTTP_TRANSACTION_TEST_UTIL_H_ |
OLD | NEW |