OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 mojo; | |
6 | |
7 import "network/public/interfaces/network_error.mojom"; | |
8 | |
9 interface WebSocket { | |
10 enum MessageType { | |
11 CONTINUATION, | |
12 TEXT, | |
13 BINARY | |
14 }; | |
15 const uint16 kAbnormalCloseCode = 1006; // stolen from websocket_bridge | |
16 | |
17 // Initiates a WebSocket connection to the given url. |send_stream| is a data | |
18 // pipe which should remain open for the lifetime of the WebSocket. Data | |
19 // to send over the WebSocket should be written to the producer end of the | |
20 // |send_stream|. | |
21 Connect(string url, | |
22 array<string> protocols, | |
23 string origin, | |
24 handle<data_pipe_consumer> send_stream, | |
25 WebSocketClient client); | |
26 | |
27 // Called after writing |num_bytes| worth of data to the WebSocket's | |
28 // |send_stream|. | |
29 Send(bool fin, MessageType type, uint32 num_bytes); | |
30 | |
31 FlowControl(int64 quota); | |
32 | |
33 Close(uint16 code, string reason); | |
34 }; | |
35 | |
36 interface WebSocketClient { | |
37 // Called in response to a WebSocket.Connect call to indicate success | |
38 // |receive_stream| is a data pipe which where incoming data from | |
39 // the server is written. | |
40 DidConnect(string selected_subprotocol, | |
41 string extensions, | |
42 handle<data_pipe_consumer> receive_stream); | |
43 | |
44 // Called when there is |num_bytes| worth of incoming data available on the | |
45 // |receive_stream|. | |
46 DidReceiveData(bool fin, WebSocket.MessageType type, uint32 num_bytes); | |
47 | |
48 DidReceiveFlowControl(int64 quota); | |
49 | |
50 DidFail(string message); | |
51 | |
52 DidClose(bool was_clean, uint16 code, string reason); | |
53 | |
54 // Blink has 3 extra methods that we don't implement, because they are used | |
55 // for the inspector: | |
56 // didStartOpeningHandshake | |
57 // didFinishOpeningHandshake | |
58 // didStartClosingHandshake | |
59 }; | |
OLD | NEW |