OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_STREAM_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
19 #include "net/websockets/websocket_event_interface.h" | 19 #include "net/websockets/websocket_event_interface.h" |
20 #include "net/websockets/websocket_handshake_request_info.h" | 20 #include "net/websockets/websocket_handshake_request_info.h" |
21 #include "net/websockets/websocket_handshake_response_info.h" | 21 #include "net/websockets/websocket_handshake_response_info.h" |
22 | 22 |
23 class GURL; | 23 class GURL; |
24 | 24 |
| 25 namespace base { |
| 26 class Timer; |
| 27 } |
| 28 |
25 namespace url { | 29 namespace url { |
26 class Origin; | 30 class Origin; |
27 } // namespace url | 31 } // namespace url |
28 | 32 |
29 namespace net { | 33 namespace net { |
30 | 34 |
31 class BoundNetLog; | 35 class BoundNetLog; |
32 class URLRequestContext; | 36 class URLRequestContext; |
33 struct WebSocketFrame; | 37 struct WebSocketFrame; |
| 38 class WebSocketHandshakeStreamCreateHelper; |
34 | 39 |
35 // WebSocketStreamRequest is the caller's handle to the process of creation of a | 40 // WebSocketStreamRequest is the caller's handle to the process of creation of a |
36 // WebSocketStream. Deleting the object before the OnSuccess or OnFailure | 41 // WebSocketStream. Deleting the object before the OnSuccess or OnFailure |
37 // callbacks are called will cancel the request (and neither callback will be | 42 // callbacks are called will cancel the request (and neither callback will be |
38 // called). After OnSuccess or OnFailure have been called, this object may be | 43 // called). After OnSuccess or OnFailure have been called, this object may be |
39 // safely deleted without side-effects. | 44 // safely deleted without side-effects. |
40 class NET_EXPORT_PRIVATE WebSocketStreamRequest { | 45 class NET_EXPORT_PRIVATE WebSocketStreamRequest { |
41 public: | 46 public: |
42 virtual ~WebSocketStreamRequest(); | 47 virtual ~WebSocketStreamRequest(); |
43 }; | 48 }; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // A helper function used in the implementation of CreateAndConnectStream() and | 208 // A helper function used in the implementation of CreateAndConnectStream() and |
204 // WebSocketBasicHandshakeStream. It creates a WebSocketHandshakeResponseInfo | 209 // WebSocketBasicHandshakeStream. It creates a WebSocketHandshakeResponseInfo |
205 // object and dispatches it to the OnFinishOpeningHandshake() method of the | 210 // object and dispatches it to the OnFinishOpeningHandshake() method of the |
206 // supplied |connect_delegate|. | 211 // supplied |connect_delegate|. |
207 void WebSocketDispatchOnFinishOpeningHandshake( | 212 void WebSocketDispatchOnFinishOpeningHandshake( |
208 WebSocketStream::ConnectDelegate* connect_delegate, | 213 WebSocketStream::ConnectDelegate* connect_delegate, |
209 const GURL& gurl, | 214 const GURL& gurl, |
210 const scoped_refptr<HttpResponseHeaders>& headers, | 215 const scoped_refptr<HttpResponseHeaders>& headers, |
211 base::Time response_time); | 216 base::Time response_time); |
212 | 217 |
| 218 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing |
| 219 // use only. The differences are the use of a |create_helper| argument in place |
| 220 // of |requested_subprotocols| and taking |timer| as the handshake timeout |
| 221 // timer. Implemented in websocket_stream.cc. |
| 222 NET_EXPORT_PRIVATE scoped_ptr<WebSocketStreamRequest> |
| 223 CreateAndConnectStreamForTesting( |
| 224 const GURL& socket_url, |
| 225 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, |
| 226 const url::Origin& origin, |
| 227 URLRequestContext* url_request_context, |
| 228 const BoundNetLog& net_log, |
| 229 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate, |
| 230 scoped_ptr<base::Timer> timer); |
| 231 |
213 } // namespace net | 232 } // namespace net |
214 | 233 |
215 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ | 234 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
OLD | NEW |