| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 12 #include "net/url_request/url_request_test_util.h" |
| 13 #include "net/websockets/websocket_stream.h" | 13 #include "net/websockets/websocket_stream.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 | 16 |
| 17 namespace base { |
| 18 class Timer; |
| 19 } // namespace base |
| 20 |
| 17 namespace url { | 21 namespace url { |
| 18 class Origin; | 22 class Origin; |
| 19 } // namespace url | 23 } // namespace url |
| 20 | 24 |
| 21 namespace net { | 25 namespace net { |
| 22 | 26 |
| 23 class BoundNetLog; | 27 class BoundNetLog; |
| 24 class DeterministicMockClientSocketFactory; | 28 class DeterministicMockClientSocketFactory; |
| 25 class DeterministicSocketData; | 29 class DeterministicSocketData; |
| 26 class URLRequestContext; | 30 class URLRequestContext; |
| 27 class WebSocketHandshakeStreamCreateHelper; | 31 class WebSocketHandshakeStreamCreateHelper; |
| 28 struct SSLSocketDataProvider; | 32 struct SSLSocketDataProvider; |
| 29 | 33 |
| 30 class LinearCongruentialGenerator { | 34 class LinearCongruentialGenerator { |
| 31 public: | 35 public: |
| 32 explicit LinearCongruentialGenerator(uint32 seed); | 36 explicit LinearCongruentialGenerator(uint32 seed); |
| 33 uint32 Generate(); | 37 uint32 Generate(); |
| 34 | 38 |
| 35 private: | 39 private: |
| 36 uint64 current_; | 40 uint64 current_; |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing | 43 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing |
| 40 // use only. The difference is the use of a |create_helper| argument in place of | 44 // use only. The differences are the use of a |create_helper| argument in place |
| 41 // |requested_subprotocols|. Implemented in websocket_stream.cc. | 45 // of |requested_subprotocols| and taking |timer| as the handshake timeout |
| 46 // timer. Implemented in websocket_stream.cc. |
| 42 NET_EXPORT_PRIVATE extern scoped_ptr<WebSocketStreamRequest> | 47 NET_EXPORT_PRIVATE extern scoped_ptr<WebSocketStreamRequest> |
| 43 CreateAndConnectStreamForTesting( | 48 CreateAndConnectStreamForTesting( |
| 44 const GURL& socket_url, | 49 const GURL& socket_url, |
| 45 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, | 50 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, |
| 46 const url::Origin& origin, | 51 const url::Origin& origin, |
| 47 URLRequestContext* url_request_context, | 52 URLRequestContext* url_request_context, |
| 48 const BoundNetLog& net_log, | 53 const BoundNetLog& net_log, |
| 49 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate); | 54 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate, |
| 55 scoped_ptr<base::Timer> timer); |
| 50 | 56 |
| 51 // Generates a standard WebSocket handshake request. The challenge key used is | 57 // Generates a standard WebSocket handshake request. The challenge key used is |
| 52 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated | 58 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated |
| 53 // with "\r\n". | 59 // with "\r\n". |
| 54 extern std::string WebSocketStandardRequest(const std::string& path, | 60 extern std::string WebSocketStandardRequest(const std::string& path, |
| 55 const std::string& origin, | 61 const std::string& origin, |
| 56 const std::string& extra_headers); | 62 const std::string& extra_headers); |
| 57 | 63 |
| 58 // A response with the appropriate accept header to match the above challenge | 64 // A response with the appropriate accept header to match the above challenge |
| 59 // key. Each header in |extra_headers| must be terminated with "\r\n". | 65 // key. Each header in |extra_headers| must be terminated with "\r\n". |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 TestURLRequestContext url_request_context_; | 131 TestURLRequestContext url_request_context_; |
| 126 TestNetworkDelegate network_delegate_; | 132 TestNetworkDelegate network_delegate_; |
| 127 bool url_request_context_initialized_; | 133 bool url_request_context_initialized_; |
| 128 | 134 |
| 129 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); | 135 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); |
| 130 }; | 136 }; |
| 131 | 137 |
| 132 } // namespace net | 138 } // namespace net |
| 133 | 139 |
| 134 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 140 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
| OLD | NEW |