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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class Origin; | 22 class Origin; |
23 } // namespace url | 23 } // namespace url |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 class BoundNetLog; | 27 class BoundNetLog; |
28 class DeterministicMockClientSocketFactory; | 28 class DeterministicMockClientSocketFactory; |
29 class DeterministicSocketData; | 29 class DeterministicSocketData; |
30 class ProxyService; | 30 class ProxyService; |
31 class URLRequestContext; | 31 class URLRequestContext; |
32 class WebSocketHandshakeStreamCreateHelper; | |
33 struct SSLSocketDataProvider; | 32 struct SSLSocketDataProvider; |
34 | 33 |
35 class LinearCongruentialGenerator { | 34 class LinearCongruentialGenerator { |
36 public: | 35 public: |
37 explicit LinearCongruentialGenerator(uint32 seed); | 36 explicit LinearCongruentialGenerator(uint32 seed); |
38 uint32 Generate(); | 37 uint32 Generate(); |
39 | 38 |
40 private: | 39 private: |
41 uint64 current_; | 40 uint64 current_; |
42 }; | 41 }; |
43 | 42 |
44 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing | |
45 // use only. The differences are the use of a |create_helper| argument in place | |
46 // of |requested_subprotocols| and taking |timer| as the handshake timeout | |
47 // timer. Implemented in websocket_stream.cc. | |
48 NET_EXPORT_PRIVATE scoped_ptr<WebSocketStreamRequest> | |
49 CreateAndConnectStreamForTesting( | |
50 const GURL& socket_url, | |
51 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, | |
52 const url::Origin& origin, | |
53 URLRequestContext* url_request_context, | |
54 const BoundNetLog& net_log, | |
55 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate, | |
56 scoped_ptr<base::Timer> timer); | |
57 | |
58 // Generates a standard WebSocket handshake request. The challenge key used is | 43 // Generates a standard WebSocket handshake request. The challenge key used is |
59 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated | 44 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated |
60 // with "\r\n". | 45 // with "\r\n". |
61 std::string WebSocketStandardRequest(const std::string& path, | 46 std::string WebSocketStandardRequest(const std::string& path, |
62 const std::string& host, | 47 const std::string& host, |
63 const std::string& origin, | 48 const std::string& origin, |
64 const std::string& extra_headers); | 49 const std::string& extra_headers); |
65 | 50 |
66 // Generates a standard WebSocket handshake request. The challenge key used is | 51 // Generates a standard WebSocket handshake request. The challenge key used is |
67 // "dGhlIHNhbXBsZSBub25jZQ==". |cookies| must be empty or terminated with | 52 // "dGhlIHNhbXBsZSBub25jZQ==". |cookies| must be empty or terminated with |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 TestNetworkDelegate network_delegate_; | 135 TestNetworkDelegate network_delegate_; |
151 scoped_ptr<ProxyService> proxy_service_; | 136 scoped_ptr<ProxyService> proxy_service_; |
152 bool url_request_context_initialized_; | 137 bool url_request_context_initialized_; |
153 | 138 |
154 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); | 139 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); |
155 }; | 140 }; |
156 | 141 |
157 } // namespace net | 142 } // namespace net |
158 | 143 |
159 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 144 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
OLD | NEW |