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 | 21 |
| 22 namespace url { |
| 23 class Origin; |
| 24 } // namespace url |
| 25 |
22 namespace net { | 26 namespace net { |
23 | 27 |
24 class BoundNetLog; | 28 class BoundNetLog; |
25 class URLRequestContext; | 29 class URLRequestContext; |
26 struct WebSocketFrame; | 30 struct WebSocketFrame; |
27 | 31 |
28 // WebSocketStreamRequest is the caller's handle to the process of creation of a | 32 // WebSocketStreamRequest is the caller's handle to the process of creation of a |
29 // WebSocketStream. Deleting the object before the OnSuccess or OnFailure | 33 // WebSocketStream. Deleting the object before the OnSuccess or OnFailure |
30 // callbacks are called will cancel the request (and neither callback will be | 34 // callbacks are called will cancel the request (and neither callback will be |
31 // called). After OnSuccess or OnFailure have been called, this object may be | 35 // called). After OnSuccess or OnFailure have been called, this object may be |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // is called with a WebSocket result code corresponding to the error. Deleting | 84 // is called with a WebSocket result code corresponding to the error. Deleting |
81 // the returned WebSocketStreamRequest object will cancel the connection, in | 85 // the returned WebSocketStreamRequest object will cancel the connection, in |
82 // which case the |connect_delegate| object that the caller passed will be | 86 // which case the |connect_delegate| object that the caller passed will be |
83 // deleted without any of its methods being called. Unless cancellation is | 87 // deleted without any of its methods being called. Unless cancellation is |
84 // required, the caller should keep the WebSocketStreamRequest object alive | 88 // required, the caller should keep the WebSocketStreamRequest object alive |
85 // until connect_delegate->OnSuccess() or OnFailure() have been called, then | 89 // until connect_delegate->OnSuccess() or OnFailure() have been called, then |
86 // it is safe to delete. | 90 // it is safe to delete. |
87 static scoped_ptr<WebSocketStreamRequest> CreateAndConnectStream( | 91 static scoped_ptr<WebSocketStreamRequest> CreateAndConnectStream( |
88 const GURL& socket_url, | 92 const GURL& socket_url, |
89 const std::vector<std::string>& requested_subprotocols, | 93 const std::vector<std::string>& requested_subprotocols, |
90 const GURL& origin, | 94 const url::Origin& origin, |
91 URLRequestContext* url_request_context, | 95 URLRequestContext* url_request_context, |
92 const BoundNetLog& net_log, | 96 const BoundNetLog& net_log, |
93 scoped_ptr<ConnectDelegate> connect_delegate); | 97 scoped_ptr<ConnectDelegate> connect_delegate); |
94 | 98 |
95 // Derived classes must make sure Close() is called when the stream is not | 99 // Derived classes must make sure Close() is called when the stream is not |
96 // closed on destruction. | 100 // closed on destruction. |
97 virtual ~WebSocketStream(); | 101 virtual ~WebSocketStream(); |
98 | 102 |
99 // Reads WebSocket frame data. This operation finishes when new frame data | 103 // Reads WebSocket frame data. This operation finishes when new frame data |
100 // becomes available. | 104 // becomes available. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 protected: | 184 protected: |
181 WebSocketStream(); | 185 WebSocketStream(); |
182 | 186 |
183 private: | 187 private: |
184 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); | 188 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); |
185 }; | 189 }; |
186 | 190 |
187 } // namespace net | 191 } // namespace net |
188 | 192 |
189 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ | 193 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
OLD | NEW |