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