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

Side by Side Diff: content/common/web_socket_messages.h

Issue 12730003: Add IPC for new WebSocket impl. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add "origin" to the arguments for a new channel. Created 7 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Multiply-included message file, hence no include guard.
6
7 // This file defines the IPCs for the browser-side implementation of
8 // WebSockets. For the legacy renderer-side implementation, see
9 // socket_stream_messages.h.
10 // TODO(ricea): Fix this comment when the legacy implementation has been
11 // removed.
12 //
13 // This IPC interface is based on the WebSocket multiplexing draft spec,
14 // http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-09
15
16 #include <string>
17 #include <vector>
18
19 #include "base/basictypes.h"
20 #include "content/common/content_export.h"
21 #include "content/common/web_socket.h"
22 #include "googleurl/src/gurl.h"
23 #include "ipc/ipc_message_macros.h"
24 #include "ipc/ipc_param_traits.h"
25
26 #undef IPC_MESSAGE_EXPORT
27 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
28 #define IPC_MESSAGE_START SocketStreamMsgStart
29
30 // WebSocket messages sent from the renderer to the browser.
31
32 // Open new virtual WebSocket connection to |socket_url|. |channel_id| is an
33 // identifier chosen by the renderer for the new channel. It cannot correspond
34 // to an existing open channel, and must be between 1 and
35 // 0x7FFFFFFF. |requested_protocols| is a list of tokens identifying
36 // sub-protocols the renderer would like to use, as described in RFC6455
37 // "Subprotocols Using the WebSocket Protocol".
38 //
39 // The browser process will not send |channel_id| as-is to the remote server; it
40 // will try to use a short id on the wire. This saves the renderer from
41 // having to try to choose the ids cleverly.
42 IPC_MESSAGE_CONTROL4(WebSocketHostMsg_AddChannelRequest,
43 int /* channel_id */,
44 GURL /* socket_url */,
45 std::vector<std::string> /* requested_protocols */,
46 GURL /* origin */);
47
48 // Web Socket messages sent from the browser to the renderer.
49
50 // Respond to an AddChannelRequest for channel |channel_id|. |channel_id| is
51 // scoped to the renderer process; while it is unique per-renderer, the browser
52 // may have multiple renderers using the same id. If |fail| is true, the channel
53 // could not be established (the cause of the failure is not provided to the
54 // renderer in order to limit its ability to abuse WebSockets to perform network
55 // probing, etc.). If |fail| is set then the |channel_id| is available for
56 // re-use. |selected_protocol| is the sub-protocol the server selected,
57 // or empty if no sub-protocol was selected.
58 IPC_MESSAGE_CONTROL3(WebSocketMsg_AddChannelResponse,
59 int /* channel_id */,
60 bool /* fail */,
61 std::string /* selected_protocol */);
62
63 // Tell the renderer how many AddChannelRequest messages it may send before the
64 // next NewChannelSlot message. |new_slots| is a positive integer indicating the
65 // number of message slots to add. |new_channel_quota| is the initial send quota
66 // for a new channel.
67 // The network protocol contains a "fallback" field that indicates that new
68 // channels should be established over a new connection; this is omitted here as
69 // the mapping of virtual connections to physical connections is not exposed to
70 // the renderer.
71 IPC_MESSAGE_CONTROL2(WebSocketMsg_NewChannelSlot,
72 int64 /* new_slots */,
73 int64 /* new_channel_quota */);
74
75 // WebSocket messages that can be sent in either direction.
76
77 IPC_ENUM_TRAITS(content::WebSocketMessageType);
78
79 // Send a frame on |channel_id|. If the sender is the renderer, it will be sent
80 // to the remote server. If the sender is the browser, it comes from the remote
81 // server. |fin| indicates that this frame is the last in the current
82 // message. |type| is the type of the message. On the first frame of a message,
83 // it must be set to either kWebSocketText or kWebSocketBinary. On subsequent
84 // frames, it must be set to kWebSocketContinuation, and the type is the same as
85 // that of the first message. If |type| is kWebSocketText, then the
86 // concatenation of the |data| from every frame in the message must be valid
87 // UTF-8. If |fin| is not set, |data| must be non-empty.
88 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
89 int /* channel_id */,
90 bool /* fin */,
91 content::WebSocketMessageType /* type */,
92 std::vector<char> /* data */);
93
94 // Add |quota| tokens of send quota for channel |channel_id|. |quota| must be a
95 // positive integer. The total available quota must never exceed
96 // 0x7FFFFFFFFFFFFFFF tokens.
97 IPC_MESSAGE_CONTROL2(WebSocketBidiMsg_FlowControl,
98 int /* channel_id */,
99 int64 /* quota */);
100
101 // Drop the channel.
102 // When sent by the renderer, this will cause a DropChannel message to be sent
103 // if the multiplex extension is in use, otherwise a Close message will be sent
104 // and the TCP/IP connection will be closed.
105 // When sent by the browser, this indicates that a Close or DropChannel has been
106 // received, the connection was closed, or a network or protocol error
107 // occurred. On receiving DropChannel, the renderer process may consider the
108 // |channel_id| available for reuse by a new AddChannelRequest.
109 // |reason| is one of the reason codes specified in RFC6455 or
110 // draft-ietf-hybi-websocket-multiplexing-09. |reason_text|, if non-empty, is a
111 // UTF-8 encoded string which may be useful for debugging but is not necessarily
112 // human-readable, as supplied by the server in the Close or DropChannel
113 // message.
114 IPC_MESSAGE_CONTROL3(WebSocketBidiMsg_DropChannel,
115 int /* channel_id */,
116 unsigned short /* reason */,
117 std::string /* reason_text */);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698