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

Side by Side Diff: content/common/websocket.mojom

Issue 2119973002: Port WebSockets to Mojo IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2016 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 module content.mojom;
6
7 import "url/mojo/origin.mojom";
8 import "url/mojo/url.mojom";
9
10 enum WebSocketMessageType {
11 CONTINUATION,
12 TEXT,
13 BINARY,
14 LAST = BINARY
15 };
16
17 // TODO(darin): Move to a more general location.
18 struct HttpHeader {
19 string name;
20 string value;
21 };
22
23 // TODO(darin): Remove redundancy b/w |headers| and |headers_text|.
24
25 struct WebSocketHandshakeRequest {
26 url.mojom.Url url;
27 array<HttpHeader> headers;
28 string headers_text;
29 };
30
31 struct WebSocketHandshakeResponse {
32 url.mojom.Url url;
33 int32 status_code;
34 string status_text;
35 array<HttpHeader> headers;
36 string headers_text;
37 };
38
39 interface WebSocketClient {
40 OnFailChannel(string reason);
41
42 // Notify the renderer that the browser has started an opening handshake.
43 // This message is for showing the request in the inspector and
44 // can be omitted if the inspector is not active.
45 OnStartOpeningHandshake(WebSocketHandshakeRequest request);
46
47 // Notify the renderer that the browser has finished an opening handshake.
48 // This message precedes AddChannelResponse.
49 // This message is for showing the response in the inspector and
50 // can be omitted if the inspector is not active.
51 OnFinishOpeningHandshake(WebSocketHandshakeResponse response);
52
53 // Response to an AddChannelRequest. |selected_protocol| is the sub-protocol
54 // the server selected, or empty if no sub-protocol was selected.
55 // |extensions| is the list of extensions negotiated for the connection.
56 OnAddChannelResponse(string selected_protocol, string extensions);
57
58 // Indicates tbat the current Blob has finished sending. The renderer can
59 // release its reference on the Blob, and may now use SendFrame or SendBlob to
60 // send more messages.
61 OnBlobSent();
62
63 // Send a non-control frame to the channel.
64 // - If the sender is the renderer, it will be sent to the remote server.
65 // - If the sender is the browser, it comes from the remote server.
66 //
67 // - |fin| indicates that this frame is the last in the current message.
68 // - |type| is the type of the message. On the first frame of a message, it
69 // must be set to either WEB_SOCKET_MESSAGE_TYPE_TEXT or
70 // WEB_SOCKET_MESSAGE_TYPE_BINARY. On subsequent frames, it must be set to
71 // WEB_SOCKET_MESSAGE_TYPE_CONTINUATION, and the type is the same as that of
72 // the first message. If |type| is WEB_SOCKET_MESSAGE_TYPE_TEXT, then the
73 // concatenation of the |data| from every frame in the message must be valid
74 // UTF-8. If |fin| is not set, |data| must be non-empty.
75 OnDataFrame(bool fin, WebSocketMessageType type, array<uint8> data);
76
77 // Add |quota| tokens of send quota for the channel. |quota| must be a positiv e
78 // integer. Both the browser and the renderer set send quota for the other
79 // side, and check that quota has not been exceeded when receiving messages.
80 // Both sides start a new channel with a quota of 0, and must wait for a
81 // FlowControl message before calling SendFrame. The total available quota on
82 // one side must never exceed 0x7FFFFFFFFFFFFFFF tokens.
83 //
84 // During "blob sending mode", ie. between the renderer sending a
85 // WebSocketHostMsg_SendBlob IPC and receiving a WebSocketMsg_BlobSendComplete
86 // IPC, quota is used up in the browser process to send the blob, but
87 // FlowControl IPCs for that quota are still sent to the renderer. The render
88 // process needs to take into account that quota equal to the size of the Blob
89 // has already been used when calculating how much send quota it has left afte r
90 // receiving BlobSendComplete.
91 OnFlowControl(int64 quota);
92
93 // Drop the channel.
94 //
95 // When sent by the renderer, this will cause a Close message will be sent and
96 // the TCP/IP connection will be closed.
97 //
98 // When sent by the browser, this indicates that a Close has been received, th e
99 // connection was closed, or a network or protocol error occurred.
100 //
101 // - |code| is one of the reason codes specified in RFC6455.
102 // - |reason|, if non-empty, is a UTF-8 encoded string which may be useful for
103 // debugging but is not necessarily human-readable, as supplied by the serve r
104 // in the Close message.
105 // - If |was_clean| is false, then the WebSocket connection was not closed
106 // cleanly.
107 OnDropChannel(bool was_clean, uint16 code, string reason);
108
109 // Notify the renderer that a closing handshake has been initiated by the
110 // server, so that it can set the Javascript readyState to CLOSING.
111 OnClosingHandshake();
112 };
113
114 interface WebSocket {
115 // Must be called prior to any of the other methods.
116 Initialize(WebSocketClient client);
117
118 // Open new WebSocket connection to |socket_url|. |requested_protocols| is a
119 // list of tokens identifying sub-protocols the renderer would like to use,
120 // as described in RFC6455 "Subprotocols Using the WebSocket Protocol".
121 AddChannelRequest(url.mojom.Url url,
122 array<string> requested_protocols,
123 url.mojom.Origin origin);
124
125 // Send a complete binary WebSocket message consisting of the Blob identified
126 // by |uuid|. The message will be split into frames as necessary.
127 // |expected_size| must match the browser's idea of the size of the Blob to
128 // prevent flow control from becoming desynchronised. If it does not match
129 // the connection will be terminated with a NotifyFailure message. On
130 // success, the browser will have consumed |expected_size| bytes of flow
131 // control send quota and the renderer needs to subtract that from its
132 // running total of flow control send quota. See the design doc at
133 // https://docs.google.com/document/d/1CDiXB9pBumhFVVfmIn1CRI6v6byxyqWu2urEE9x p714/edit
134 // SendFrame or SendBlob messages must not be sent by the renderer until the
135 // BlobSendComplete message has been received from the browser. The renderer
136 // should retain a reference to the Blob until either a BlobSendComplete or
137 // NotifyFailure IPC is received.
138 // XXX need to handle race condition with Blob registration
139 SendBlob(string uuid, uint64 expected_size);
140
141 // Send a non-control frame to the channel.
142 // - If the sender is the renderer, it will be sent to the remote server.
143 // - If the sender is the browser, it comes from the remote server.
144 //
145 // - |fin| indicates that this frame is the last in the current message.
146 // - |type| is the type of the message. On the first frame of a message, it
147 // must be set to either WEB_SOCKET_MESSAGE_TYPE_TEXT or
148 // WEB_SOCKET_MESSAGE_TYPE_BINARY. On subsequent frames, it must be set to
149 // WEB_SOCKET_MESSAGE_TYPE_CONTINUATION, and the type is the same as that of
150 // the first message. If |type| is WEB_SOCKET_MESSAGE_TYPE_TEXT, then the
151 // concatenation of the |data| from every frame in the message must be valid
152 // UTF-8. If |fin| is not set, |data| must be non-empty.
153 SendFrame(bool fin, WebSocketMessageType type, array<uint8> data);
154
155 // Add |quota| tokens of send quota for the channel. |quota| must be a positiv e
156 // integer. Both the browser and the renderer set send quota for the other
157 // side, and check that quota has not been exceeded when receiving messages.
158 // Both sides start a new channel with a quota of 0, and must wait for a
159 // FlowControl message before calling SendFrame. The total available quota on
160 // one side must never exceed 0x7FFFFFFFFFFFFFFF tokens.
161 //
162 // During "blob sending mode", ie. between the renderer sending a
163 // WebSocketHostMsg_SendBlob IPC and receiving a WebSocketMsg_BlobSendComplete
164 // IPC, quota is used up in the browser process to send the blob, but
165 // FlowControl IPCs for that quota are still sent to the renderer. The render
166 // process needs to take into account that quota equal to the size of the Blob
167 // has already been used when calculating how much send quota it has left afte r
168 // receiving BlobSendComplete.
169 SendFlowControl(int64 quota);
170
171 // Close the channel gracefully.
172 //
173 // When sent by the renderer, this will cause a Close message will be sent and
174 // the TCP/IP connection will be closed.
175 //
176 // - |code| is one of the reason codes specified in RFC6455.
177 // - |reason|, if non-empty, is a UTF-8 encoded string which may be useful for
178 // debugging but is not necessarily human-readable, as supplied by the serve r
179 // in the Close message.
180 StartClosingHandshake(uint16 code, string reason);
181 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698