Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: net/websockets/websocket_channel.h

Issue 1820233002: [WebSocket] Incoming close frame should not overtake data frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/websocket_host.cc ('k') | net/websockets/websocket_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_channel.h
diff --git a/net/websockets/websocket_channel.h b/net/websockets/websocket_channel.h
index 97db65f1eb8d39bf01c5cf56991fd28eecdcb69d..666b6203a2fd6e90f6d3a89bdcc38c33693130d5 100644
--- a/net/websockets/websocket_channel.h
+++ b/net/websockets/websocket_channel.h
@@ -90,7 +90,11 @@ class NET_EXPORT WebSocketChannel {
// Sends |quota| units of flow control to the remote side. If the underlying
// transport has a concept of |quota|, then it permits the remote server to
// send up to |quota| units of data.
- void SendFlowControl(int64_t quota);
+ //
+ // Calling this function may result in synchronous calls to |event_interface_|
+ // which may result in this object being deleted. In that case, the return
+ // value will be CHANNEL_DELETED.
+ ChannelState SendFlowControl(int64_t quota) WARN_UNUSED_RESULT;
// Starts the closing handshake for a client-initiated shutdown of the
// connection. There is no API to close the connection without a closing
@@ -98,10 +102,11 @@ class NET_EXPORT WebSocketChannel {
// effectively do that. |code| must be in the range 1000-4999. |reason| should
// be a valid UTF-8 string or empty.
//
- // This does *not* trigger the event OnClosingHandshake(). The caller should
- // assume that the closing handshake has started and perform the equivalent
- // processing to OnClosingHandshake() if necessary.
- void StartClosingHandshake(uint16_t code, const std::string& reason);
+ // Calling this function may result in synchronous calls to |event_interface_|
+ // which may result in this object being deleted. In that case, the return
+ // value will be CHANNEL_DELETED.
+ ChannelState StartClosingHandshake(uint16_t code, const std::string& reason)
+ WARN_UNUSED_RESULT;
// Returns the current send quota. This value is unsafe to use outside of the
// browser IO thread because it changes asynchronously. The value is only
@@ -273,7 +278,7 @@ class NET_EXPORT WebSocketChannel {
const scoped_refptr<IOBuffer>& data_buffer,
uint64_t size) WARN_UNUSED_RESULT;
- // Forward a received data frame to the renderer, if connected. If
+ // Forwards a received data frame to the renderer, if connected. If
// |expecting_continuation| is not equal to |expecting_to_read_continuation_|,
// will fail the channel. Also checks the UTF-8 validity of text frames.
ChannelState HandleDataFrame(WebSocketFrameHeader::OpCode opcode,
@@ -281,6 +286,13 @@ class NET_EXPORT WebSocketChannel {
const scoped_refptr<IOBuffer>& data_buffer,
uint64_t size) WARN_UNUSED_RESULT;
+ // Handles an incoming close frame with |code| and |reason|.
+ ChannelState HandleCloseFrame(uint16_t code,
+ const std::string& reason) WARN_UNUSED_RESULT;
+
+ // Responds to a closing handshake initiated by the server.
+ ChannelState RespondToClosingHandshake() WARN_UNUSED_RESULT;
+
// Low-level method to send a single frame. Used for both data and control
// frames. Either sends the frame immediately or buffers it to be scheduled
// when the current write finishes. |fin| and |op_code| are defined as for
« no previous file with comments | « content/browser/renderer_host/websocket_host.cc ('k') | net/websockets/websocket_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698