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_CHANNEL_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 const std::vector<std::string>& requested_protocols, | 146 const std::vector<std::string>& requested_protocols, |
147 const GURL& origin, | 147 const GURL& origin, |
148 const WebSocketStreamCreator& creator); | 148 const WebSocketStreamCreator& creator); |
149 | 149 |
150 // Success callback from WebSocketStream::CreateAndConnectStream(). Reports | 150 // Success callback from WebSocketStream::CreateAndConnectStream(). Reports |
151 // success to the event interface. May delete |this|. | 151 // success to the event interface. May delete |this|. |
152 void OnConnectSuccess(scoped_ptr<WebSocketStream> stream); | 152 void OnConnectSuccess(scoped_ptr<WebSocketStream> stream); |
153 | 153 |
154 // Failure callback from WebSocketStream::CreateAndConnectStream(). Reports | 154 // Failure callback from WebSocketStream::CreateAndConnectStream(). Reports |
155 // failure to the event interface. May delete |this|. | 155 // failure to the event interface. May delete |this|. |
156 void OnConnectFailure(uint16 websocket_error); | 156 void OnConnectFailure(const std::string& message); |
157 | 157 |
158 // Returns true if state_ is SEND_CLOSED, CLOSE_WAIT or CLOSED. | 158 // Returns true if state_ is SEND_CLOSED, CLOSE_WAIT or CLOSED. |
159 bool InClosingState() const; | 159 bool InClosingState() const; |
160 | 160 |
161 // Calls WebSocketStream::WriteFrames() with the appropriate arguments | 161 // Calls WebSocketStream::WriteFrames() with the appropriate arguments |
162 ChannelState WriteFrames() WARN_UNUSED_RESULT; | 162 ChannelState WriteFrames() WARN_UNUSED_RESULT; |
163 | 163 |
164 // Callback from WebSocketStream::WriteFrames. Sends pending data or adjusts | 164 // Callback from WebSocketStream::WriteFrames. Sends pending data or adjusts |
165 // the send quota of the renderer channel as appropriate. |result| is a net | 165 // the send quota of the renderer channel as appropriate. |result| is a net |
166 // error code, usually OK. If |synchronous| is true, then OnWriteDone() is | 166 // error code, usually OK. If |synchronous| is true, then OnWriteDone() is |
(...skipping 25 matching lines...) Expand all Loading... | |
192 // Low-level method to send a single frame. Used for both data and control | 192 // Low-level method to send a single frame. Used for both data and control |
193 // frames. Either sends the frame immediately or buffers it to be scheduled | 193 // frames. Either sends the frame immediately or buffers it to be scheduled |
194 // when the current write finishes. |fin| and |op_code| are defined as for | 194 // when the current write finishes. |fin| and |op_code| are defined as for |
195 // SendFrame() above, except that |op_code| may also be a control frame | 195 // SendFrame() above, except that |op_code| may also be a control frame |
196 // opcode. | 196 // opcode. |
197 ChannelState SendIOBuffer(bool fin, | 197 ChannelState SendIOBuffer(bool fin, |
198 WebSocketFrameHeader::OpCode op_code, | 198 WebSocketFrameHeader::OpCode op_code, |
199 const scoped_refptr<IOBuffer>& buffer, | 199 const scoped_refptr<IOBuffer>& buffer, |
200 size_t size) WARN_UNUSED_RESULT; | 200 size_t size) WARN_UNUSED_RESULT; |
201 | 201 |
202 // TODO(yhirano): This is not the "Fail" operation but the (unclean) "Close" | |
203 // operation. Needs renaming & refactoring. | |
Adam Rice
2013/12/06 07:02:31
It is certainly intended to implement the "Fail th
yhirano
2013/12/06 08:54:56
My understanding is that "_Fail the WebSocket Conn
Adam Rice
2013/12/09 01:21:41
The spec goes on to say "In this case, it MAY use
yhirano
2013/12/09 06:11:14
Discussed offline.
I deleted the comment.
http://c
| |
202 // Performs the "Fail the WebSocket Connection" operation as defined in | 204 // Performs the "Fail the WebSocket Connection" operation as defined in |
203 // RFC6455. The supplied code and reason are sent back to the renderer in an | 205 // RFC6455. The supplied code and reason are sent back to the renderer in an |
204 // OnDropChannel message. If state_ is CONNECTED then a Close message is sent | 206 // OnDropChannel message. If state_ is CONNECTED then a Close message is sent |
205 // to the remote host. If |expose| is SEND_REAL_ERROR then the remote host is | 207 // to the remote host. If |expose| is SEND_REAL_ERROR then the remote host is |
206 // given the same status code passed to the renderer; otherwise it is sent a | 208 // given the same status code passed to the renderer; otherwise it is sent a |
207 // fixed "Going Away" code. Closes the stream_ and sets state_ to CLOSED. | 209 // fixed "Going Away" code. Closes the stream_ and sets state_ to CLOSED. |
208 // FailChannel() always returns CHANNEL_DELETED. It is not valid to access any | 210 // FailChannel() always returns CHANNEL_DELETED. It is not valid to access any |
209 // member variables or methods after calling FailChannel(). | 211 // member variables or methods after calling FailChannel(). |
210 ChannelState FailChannel(ExposeError expose, | 212 ChannelState FailChannel(ExposeError expose, |
211 uint16 code, | 213 uint16 code, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // The current state of the channel. Mainly used for sanity checking, but also | 288 // The current state of the channel. Mainly used for sanity checking, but also |
287 // used to track the close state. | 289 // used to track the close state. |
288 State state_; | 290 State state_; |
289 | 291 |
290 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); | 292 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); |
291 }; | 293 }; |
292 | 294 |
293 } // namespace net | 295 } // namespace net |
294 | 296 |
295 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ | 297 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
OLD | NEW |