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 url { |
| 18 class Origin; |
| 19 } // namespace url |
| 20 |
17 namespace net { | 21 namespace net { |
18 | 22 |
19 class BoundNetLog; | 23 class BoundNetLog; |
20 class DeterministicSocketData; | 24 class DeterministicSocketData; |
21 class URLRequestContext; | 25 class URLRequestContext; |
22 class WebSocketHandshakeStreamCreateHelper; | 26 class WebSocketHandshakeStreamCreateHelper; |
23 class DeterministicMockClientSocketFactory; | 27 class DeterministicMockClientSocketFactory; |
24 | 28 |
25 class LinearCongruentialGenerator { | 29 class LinearCongruentialGenerator { |
26 public: | 30 public: |
27 explicit LinearCongruentialGenerator(uint32 seed); | 31 explicit LinearCongruentialGenerator(uint32 seed); |
28 uint32 Generate(); | 32 uint32 Generate(); |
29 | 33 |
30 private: | 34 private: |
31 uint64 current_; | 35 uint64 current_; |
32 }; | 36 }; |
33 | 37 |
34 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing | 38 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing |
35 // use only. The difference is the use of a |create_helper| argument in place of | 39 // use only. The difference is the use of a |create_helper| argument in place of |
36 // |requested_subprotocols|. Implemented in websocket_stream.cc. | 40 // |requested_subprotocols|. Implemented in websocket_stream.cc. |
37 NET_EXPORT_PRIVATE extern scoped_ptr<WebSocketStreamRequest> | 41 NET_EXPORT_PRIVATE extern scoped_ptr<WebSocketStreamRequest> |
38 CreateAndConnectStreamForTesting( | 42 CreateAndConnectStreamForTesting( |
39 const GURL& socket_url, | 43 const GURL& socket_url, |
40 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, | 44 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, |
41 const GURL& origin, | 45 const url::Origin& origin, |
42 URLRequestContext* url_request_context, | 46 URLRequestContext* url_request_context, |
43 const BoundNetLog& net_log, | 47 const BoundNetLog& net_log, |
44 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate); | 48 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate); |
45 | 49 |
46 // Generates a standard WebSocket handshake request. The challenge key used is | 50 // Generates a standard WebSocket handshake request. The challenge key used is |
47 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated | 51 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated |
48 // with "\r\n". | 52 // with "\r\n". |
49 extern std::string WebSocketStandardRequest(const std::string& path, | 53 extern std::string WebSocketStandardRequest(const std::string& path, |
50 const std::string& origin, | 54 const std::string& origin, |
51 const std::string& extra_headers); | 55 const std::string& extra_headers); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 WebSocketDeterministicMockClientSocketFactoryMaker maker_; | 109 WebSocketDeterministicMockClientSocketFactoryMaker maker_; |
106 TestURLRequestContext url_request_context_; | 110 TestURLRequestContext url_request_context_; |
107 TestNetworkDelegate network_delegate_; | 111 TestNetworkDelegate network_delegate_; |
108 | 112 |
109 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); | 113 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); |
110 }; | 114 }; |
111 | 115 |
112 } // namespace net | 116 } // namespace net |
113 | 117 |
114 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 118 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
OLD | NEW |