Index: content/common/web_socket_messages.h |
diff --git a/content/common/web_socket_messages.h b/content/common/web_socket_messages.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2cfcf63290e13058752b035803b26ff0b180271f |
--- /dev/null |
+++ b/content/common/web_socket_messages.h |
@@ -0,0 +1,117 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Multiply-included message file, hence no include guard. |
+ |
+// This file defines the IPCs for the browser-side implementation of |
+// WebSockets. For the legacy renderer-side implementation, see |
+// socket_stream_messages.h. |
+// TODO(ricea): Fix this comment when the legacy implementation has been |
+// removed. |
+// |
+// This IPC interface is based on the WebSocket multiplexing draft spec, |
+// http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-09 |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/basictypes.h" |
+#include "content/common/content_export.h" |
+#include "content/common/web_socket.h" |
+#include "googleurl/src/gurl.h" |
+#include "ipc/ipc_message_macros.h" |
+#include "ipc/ipc_param_traits.h" |
+ |
+#undef IPC_MESSAGE_EXPORT |
+#define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
+#define IPC_MESSAGE_START SocketStreamMsgStart |
+ |
+// WebSocket messages sent from the renderer to the browser. |
+ |
+// Open new virtual WebSocket connection to |socket_url|. |channel_id| is an |
+// identifier chosen by the renderer for the new channel. It cannot correspond |
+// to an existing open channel, and must be between 1 and |
+// 0x7FFFFFFF. |requested_protocols| is a list of tokens identifying |
+// sub-protocols the renderer would like to use, as described in RFC6455 |
+// "Subprotocols Using the WebSocket Protocol". |
+// |
+// The browser process will not send |channel_id| as-is to the remote server; it |
+// will try to use a short id on the wire. This saves the renderer from |
+// having to try to choose the ids cleverly. |
+IPC_MESSAGE_CONTROL4(WebSocketHostMsg_AddChannelRequest, |
+ int /* channel_id */, |
+ GURL /* socket_url */, |
+ std::vector<std::string> /* requested_protocols */, |
+ GURL /* origin */); |
+ |
+// Web Socket messages sent from the browser to the renderer. |
+ |
+// Respond to an AddChannelRequest for channel |channel_id|. |channel_id| is |
+// scoped to the renderer process; while it is unique per-renderer, the browser |
+// may have multiple renderers using the same id. If |fail| is true, the channel |
+// could not be established (the cause of the failure is not provided to the |
+// renderer in order to limit its ability to abuse WebSockets to perform network |
+// probing, etc.). If |fail| is set then the |channel_id| is available for |
+// re-use. |selected_protocol| is the sub-protocol the server selected, |
+// or empty if no sub-protocol was selected. |
+IPC_MESSAGE_CONTROL3(WebSocketMsg_AddChannelResponse, |
+ int /* channel_id */, |
+ bool /* fail */, |
+ std::string /* selected_protocol */); |
+ |
+// Tell the renderer how many AddChannelRequest messages it may send before the |
+// next NewChannelSlot message. |new_slots| is a positive integer indicating the |
+// number of message slots to add. |new_channel_quota| is the initial send quota |
+// for a new channel. |
+// The network protocol contains a "fallback" field that indicates that new |
+// channels should be established over a new connection; this is omitted here as |
+// the mapping of virtual connections to physical connections is not exposed to |
+// the renderer. |
+IPC_MESSAGE_CONTROL2(WebSocketMsg_NewChannelSlot, |
+ int64 /* new_slots */, |
+ int64 /* new_channel_quota */); |
+ |
+// WebSocket messages that can be sent in either direction. |
+ |
+IPC_ENUM_TRAITS(content::WebSocketMessageType); |
+ |
+// Send a frame on |channel_id|. If the sender is the renderer, it will be sent |
+// to the remote server. If the sender is the browser, it comes from the remote |
+// server. |fin| indicates that this frame is the last in the current |
+// message. |type| is the type of the message. On the first frame of a message, |
+// it must be set to either kWebSocketText or kWebSocketBinary. On subsequent |
+// frames, it must be set to kWebSocketContinuation, and the type is the same as |
+// that of the first message. If |type| is kWebSocketText, then the |
+// concatenation of the |data| from every frame in the message must be valid |
+// UTF-8. If |fin| is not set, |data| must be non-empty. |
+IPC_MESSAGE_CONTROL4(WebSocketBidiMsg_SendFrame, |
tyoshino (SeeGerritForStatus)
2013/05/17 19:46:27
Thanks for clarifying that this message is used fo
Adam Rice
2013/05/20 03:56:20
I thought that since "SomethingMsg" usually means
|
+ int /* channel_id */, |
+ bool /* fin */, |
+ content::WebSocketMessageType /* type */, |
+ std::vector<char> /* data */); |
+ |
+// Add |quota| tokens of send quota for channel |channel_id|. |quota| must be a |
+// positive integer. The total available quota must never exceed |
+// 0x7FFFFFFFFFFFFFFF tokens. |
+IPC_MESSAGE_CONTROL2(WebSocketBidiMsg_FlowControl, |
+ int /* channel_id */, |
+ int64 /* quota */); |
+ |
+// Drop the channel. |
+// When sent by the renderer, this will cause a DropChannel message to be sent |
+// if the multiplex extension is in use, otherwise a Close message will be sent |
+// and the TCP/IP connection will be closed. |
+// When sent by the browser, this indicates that a Close or DropChannel has been |
+// received, the connection was closed, or a network or protocol error |
+// occurred. On receiving DropChannel, the renderer process may consider the |
+// |channel_id| available for reuse by a new AddChannelRequest. |
+// |reason| is one of the reason codes specified in RFC6455 or |
+// draft-ietf-hybi-websocket-multiplexing-09. |reason_text|, if non-empty, is a |
+// UTF-8 encoded string which may be useful for debugging but is not necessarily |
+// human-readable, as supplied by the server in the Close or DropChannel |
+// message. |
+IPC_MESSAGE_CONTROL3(WebSocketBidiMsg_DropChannel, |
+ int /* channel_id */, |
+ unsigned short /* reason */, |
+ std::string /* reason_text */); |