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