| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // TODO(crbug.com/647290): Rename "Session" to "Connection" | 5 // TODO(crbug.com/647290): Rename "Session" to "Connection" |
| 6 | 6 |
| 7 module blink.mojom; | 7 module blink.mojom; |
| 8 | 8 |
| 9 import "url/mojo/url.mojom"; | 9 import "url/mojo/url.mojom"; |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 NO_PRESENTATION_FOUND, | 32 NO_PRESENTATION_FOUND, |
| 33 PREVIOUS_START_IN_PROGRESS, | 33 PREVIOUS_START_IN_PROGRESS, |
| 34 UNKNOWN, | 34 UNKNOWN, |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 struct PresentationError { | 37 struct PresentationError { |
| 38 PresentationErrorType error_type; | 38 PresentationErrorType error_type; |
| 39 string message; | 39 string message; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 enum PresentationMessageType { | 42 union PresentationConnectionMessage { |
| 43 TEXT, | 43 string message; |
| 44 BINARY, | 44 array<uint8> data; |
| 45 }; | |
| 46 | |
| 47 struct ConnectionMessage { | |
| 48 PresentationMessageType type; | |
| 49 // Used when message type is TEXT. | |
| 50 string? message; | |
| 51 // Used when message type is BINARY. | |
| 52 // TODO(lethalantidote): Make this a mojo union. | |
| 53 // See https://crbug.com/632623. | |
| 54 array<uint8>? data; | |
| 55 }; | 45 }; |
| 56 | 46 |
| 57 interface PresentationConnection { | 47 interface PresentationConnection { |
| 58 // TODO(zhaobin): migrate SendConnectionMessage from PresentationService => | 48 // TODO(zhaobin): migrate SendConnectionMessage from PresentationService => |
| 59 // PresentationConnection.Send(). http://crbug.com/658474 | 49 // PresentationConnection.Send(). http://crbug.com/658474 |
| 60 | 50 |
| 61 // Called when a message is sent by the target connection. | 51 // Called when a message is sent by the target connection. |
| 62 OnMessage(ConnectionMessage message) => (bool success); | 52 OnMessage(PresentationConnectionMessage message) => (bool success); |
| 63 | 53 |
| 64 // Called when target connection notifies connection state change. | 54 // Called when target connection notifies connection state change. |
| 65 DidChangeState(PresentationConnectionState state); | 55 DidChangeState(PresentationConnectionState state); |
| 66 }; | 56 }; |
| 67 | 57 |
| 68 interface PresentationService { | 58 interface PresentationService { |
| 69 // Sets the PresentationServiceClient. | 59 // Sets the PresentationServiceClient. |
| 70 SetClient(PresentationServiceClient client); | 60 SetClient(PresentationServiceClient client); |
| 71 | 61 |
| 72 ///////////// Functions here are for the controller part of the API. ///////// | 62 ///////////// Functions here are for the controller part of the API. ///////// |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 PresentationConnection& receiver_connection_request); | 104 PresentationConnection& receiver_connection_request); |
| 115 | 105 |
| 116 ////////////////////////////////////////////////////////////////////////////// | 106 ////////////////////////////////////////////////////////////////////////////// |
| 117 | 107 |
| 118 // Called when send() is called by the frame. The true in the | 108 // Called when send() is called by the frame. The true in the |
| 119 // result callback notifies that the service is ready for next message. | 109 // result callback notifies that the service is ready for next message. |
| 120 // The false in the result callback notifies the renderer to stop sending | 110 // The false in the result callback notifies the renderer to stop sending |
| 121 // the send requests and invalidate all pending requests. This occurs | 111 // the send requests and invalidate all pending requests. This occurs |
| 122 // for eg., when frame is deleted or navigated away. | 112 // for eg., when frame is deleted or navigated away. |
| 123 SendConnectionMessage(PresentationSessionInfo sessionInfo, | 113 SendConnectionMessage(PresentationSessionInfo sessionInfo, |
| 124 ConnectionMessage message_request) => (bool success); | 114 PresentationConnectionMessage message) => (bool success)
; |
| 125 | 115 |
| 126 // Called when close() is called by the frame. | 116 // Called when close() is called by the frame. |
| 127 CloseConnection(url.mojom.Url presentation_url, string presentation_id); | 117 CloseConnection(url.mojom.Url presentation_url, string presentation_id); |
| 128 | 118 |
| 129 // Called when terminate() is called by the frame. | 119 // Called when terminate() is called by the frame. |
| 130 Terminate(url.mojom.Url presentation_url, string presentation_id); | 120 Terminate(url.mojom.Url presentation_url, string presentation_id); |
| 131 | 121 |
| 132 // Starts listening for messages for session with |sessionInfo|. | 122 // Starts listening for messages for session with |sessionInfo|. |
| 133 // Messages will be received in | 123 // Messages will be received in |
| 134 // PresentationServiceClient::OnConnectionMessagesReceived. | 124 // PresentationServiceClient::OnConnectionMessagesReceived. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 163 PresentationConnectionState newState); | 153 PresentationConnectionState newState); |
| 164 | 154 |
| 165 // Caled when the state of |connection| started on this frame has changed to | 155 // Caled when the state of |connection| started on this frame has changed to |
| 166 // CLOSED. | 156 // CLOSED. |
| 167 OnConnectionClosed(PresentationSessionInfo connection, | 157 OnConnectionClosed(PresentationSessionInfo connection, |
| 168 PresentationConnectionCloseReason reason, | 158 PresentationConnectionCloseReason reason, |
| 169 string message); | 159 string message); |
| 170 | 160 |
| 171 // See PresentationService::ListenForConnectionMessages. | 161 // See PresentationService::ListenForConnectionMessages. |
| 172 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, | 162 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, |
| 173 array<ConnectionMessage> messages); | 163 array<PresentationConnectionMessage> messages); |
| 174 | 164 |
| 175 // Called on a presentation receiver when presentation connection is available | 165 // Called on a presentation receiver when presentation connection is available |
| 176 // from the controlling page. | 166 // from the controlling page. |
| 177 OnReceiverConnectionAvailable( | 167 OnReceiverConnectionAvailable( |
| 178 PresentationSessionInfo sessionInfo, | 168 PresentationSessionInfo sessionInfo, |
| 179 PresentationConnection controller_connection_ptr, | 169 PresentationConnection controller_connection_ptr, |
| 180 PresentationConnection& receiver_connection_request); | 170 PresentationConnection& receiver_connection_request); |
| 181 }; | 171 }; |
| OLD | NEW |