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

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

Issue 2284473002: Move WebSocketHandleImpl into Blink (take 2) (Closed)
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « content/common/BUILD.gn ('k') | content/content_common_mojo_bindings.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Receive a non-control frame from the remote server.
59 // - |fin| indicates that this frame is the last in the current message.
60 // - |type| is the type of the message. On the first frame of a message, it
61 // must be set to either WebSocketMessageType.TEXT or
62 // WebSocketMessageType.BINARY. On subsequent frames, it must be set to
63 // WebSocketMessageType.CONTINUATION, and the type is the same as that of
64 // the first message. If |type| is WebSocketMessageType.TEXT, then the
65 // concatenation of the |data| from every frame in the message must be valid
66 // UTF-8. If |fin| is not set, |data| must be non-empty.
67 OnDataFrame(bool fin, WebSocketMessageType type, array<uint8> data);
68
69 // Add |quota| tokens of send quota for the channel. |quota| must be a
70 // positive integer. Both the browser and the renderer set send quota for the
71 // other side, and check that quota has not been exceeded when receiving
72 // messages. Both sides start a new channel with a quota of 0, and must wait
73 // for a FlowControl message before calling SendFrame. The total available
74 // quota on one side must never exceed 0x7FFFFFFFFFFFFFFF tokens.
75 OnFlowControl(int64 quota);
76
77 // Drop the channel.
78 //
79 // When sent by the renderer, this will cause a Close message will be sent and
80 // the TCP/IP connection will be closed.
81 //
82 // When sent by the browser, this indicates that a Close has been received,
83 // the connection was closed, or a network or protocol error occurred.
84 //
85 // - |code| is one of the reason codes specified in RFC6455.
86 // - |reason|, if non-empty, is a UTF-8 encoded string which may be useful
87 // for debugging but is not necessarily human-readable, as supplied by the
88 // server in the Close message.
89 // - If |was_clean| is false, then the WebSocket connection was not closed
90 // cleanly.
91 OnDropChannel(bool was_clean, uint16 code, string reason);
92
93 // Notify the renderer that a closing handshake has been initiated by the
94 // server, so that it can set the Javascript readyState to CLOSING.
95 OnClosingHandshake();
96 };
97
98 interface WebSocket {
99 // Open new WebSocket connection to |socket_url|. |requested_protocols| is a
100 // list of tokens identifying sub-protocols the renderer would like to use,
101 // as described in RFC6455 "Subprotocols Using the WebSocket Protocol".
102 AddChannelRequest(url.mojom.Url url,
103 array<string> requested_protocols,
104 url.mojom.Origin origin,
105 url.mojom.Url first_party_for_cookies,
106 string user_agent_override,
107 WebSocketClient client);
108
109 // Send a non-control frame to the remote server.
110 // - |fin| indicates that this frame is the last in the current message.
111 // - |type| is the type of the message. On the first frame of a message, it
112 // must be set to either WebSocketMessageType.TEXT or
113 // WebSocketMessageType.BINARY. On subsequent frames, it must be set to
114 // WebSocketMessageType.CONTINUATION, and the type is the same as that of
115 // the first message. If |type| is WebSocketMessageType.TEXT, then the
116 // concatenation of the |data| from every frame in the message must be valid
117 // UTF-8. If |fin| is not set, |data| must be non-empty.
118 SendFrame(bool fin, WebSocketMessageType type, array<uint8> data);
119
120 // Add |quota| tokens of send quota for the channel. |quota| must be a
121 // positive integer. Both the browser and the renderer set send quota for the
122 // other side, and check that quota has not been exceeded when receiving
123 // messages. Both sides start a new channel with a quota of 0, and must wait
124 // for a FlowControl message before calling SendFrame. The total available
125 // quota on one side must never exceed 0x7FFFFFFFFFFFFFFF tokens.
126 SendFlowControl(int64 quota);
127
128 // Close the channel gracefully.
129 //
130 // When sent by the renderer, this will cause a Close message will be sent and
131 // the TCP/IP connection will be closed.
132 //
133 // - |code| is one of the reason codes specified in RFC6455.
134 // - |reason|, if non-empty, is a UTF-8 encoded string which may be useful for
135 // debugging but is not necessarily human-readable, as supplied by the
136 // server in the Close message.
137 StartClosingHandshake(uint16 code, string reason);
138 };
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/content_common_mojo_bindings.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698