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/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
17 #include "net/websockets/websocket_handshake_request_info.h" | 17 #include "net/websockets/websocket_handshake_request_info.h" |
18 #include "net/websockets/websocket_handshake_response_info.h" | 18 #include "net/websockets/websocket_handshake_response_info.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
| 21 class SerializedOrigin; |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 class BoundNetLog; | 25 class BoundNetLog; |
25 class URLRequestContext; | 26 class URLRequestContext; |
26 struct WebSocketFrame; | 27 struct WebSocketFrame; |
27 | 28 |
28 // WebSocketStreamRequest is the caller's handle to the process of creation of a | 29 // WebSocketStreamRequest is the caller's handle to the process of creation of a |
29 // WebSocketStream. Deleting the object before the OnSuccess or OnFailure | 30 // WebSocketStream. Deleting the object before the OnSuccess or OnFailure |
30 // callbacks are called will cancel the request (and neither callback will be | 31 // callbacks are called will cancel the request (and neither callback will be |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // is called with a WebSocket result code corresponding to the error. Deleting | 81 // is called with a WebSocket result code corresponding to the error. Deleting |
81 // the returned WebSocketStreamRequest object will cancel the connection, in | 82 // the returned WebSocketStreamRequest object will cancel the connection, in |
82 // which case the |connect_delegate| object that the caller passed will be | 83 // which case the |connect_delegate| object that the caller passed will be |
83 // deleted without any of its methods being called. Unless cancellation is | 84 // deleted without any of its methods being called. Unless cancellation is |
84 // required, the caller should keep the WebSocketStreamRequest object alive | 85 // required, the caller should keep the WebSocketStreamRequest object alive |
85 // until connect_delegate->OnSuccess() or OnFailure() have been called, then | 86 // until connect_delegate->OnSuccess() or OnFailure() have been called, then |
86 // it is safe to delete. | 87 // it is safe to delete. |
87 static scoped_ptr<WebSocketStreamRequest> CreateAndConnectStream( | 88 static scoped_ptr<WebSocketStreamRequest> CreateAndConnectStream( |
88 const GURL& socket_url, | 89 const GURL& socket_url, |
89 const std::vector<std::string>& requested_subprotocols, | 90 const std::vector<std::string>& requested_subprotocols, |
90 const GURL& origin, | 91 const SerializedOrigin& origin, |
91 URLRequestContext* url_request_context, | 92 URLRequestContext* url_request_context, |
92 const BoundNetLog& net_log, | 93 const BoundNetLog& net_log, |
93 scoped_ptr<ConnectDelegate> connect_delegate); | 94 scoped_ptr<ConnectDelegate> connect_delegate); |
94 | 95 |
95 // Derived classes must make sure Close() is called when the stream is not | 96 // Derived classes must make sure Close() is called when the stream is not |
96 // closed on destruction. | 97 // closed on destruction. |
97 virtual ~WebSocketStream(); | 98 virtual ~WebSocketStream(); |
98 | 99 |
99 // Reads WebSocket frame data. This operation finishes when new frame data | 100 // Reads WebSocket frame data. This operation finishes when new frame data |
100 // becomes available. | 101 // becomes available. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 protected: | 177 protected: |
177 WebSocketStream(); | 178 WebSocketStream(); |
178 | 179 |
179 private: | 180 private: |
180 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); | 181 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); |
181 }; | 182 }; |
182 | 183 |
183 } // namespace net | 184 } // namespace net |
184 | 185 |
185 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ | 186 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
OLD | NEW |