Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 struct ConnectionMessage { | 46 struct ConnectionMessage { |
| 47 PresentationMessageType type; | 47 PresentationMessageType type; |
| 48 // Used when message type is TEXT. | 48 // Used when message type is TEXT. |
| 49 string? message; | 49 string? message; |
| 50 // Used when message type is BINARY. | 50 // Used when message type is BINARY. |
| 51 // TODO(lethalantidote): Make this a mojo union. | 51 // TODO(lethalantidote): Make this a mojo union. |
| 52 // See https://crbug.com/632623. | 52 // See https://crbug.com/632623. |
| 53 array<uint8>? data; | 53 array<uint8>? data; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 interface PresentationConnection { | |
| 57 // TODO(zhaobin): migrate SendConnectionMessage from PresentationService => | |
| 58 // PresentationConnection.Send(). http://crbug.com/658474 | |
| 59 | |
| 60 // Called when a message is sent by the target connection. | |
| 61 OnMessage(ConnectionMessage message) => (bool success); | |
| 62 | |
| 63 // Called when target connection notifies connection state change. | |
| 64 DidChangeState(PresentationConnectionState state); | |
| 65 }; | |
| 66 | |
| 56 interface PresentationService { | 67 interface PresentationService { |
| 57 // Sets the PresentationServiceClient. | 68 // Sets the PresentationServiceClient. |
| 58 SetClient(PresentationServiceClient client); | 69 SetClient(PresentationServiceClient client); |
| 59 | 70 |
| 71 ///////////// Functions here are for the controller part of the API. ///////// | |
| 72 | |
| 60 // Called when the frame sets or changes the default presentation URLs. | 73 // Called when the frame sets or changes the default presentation URLs. |
| 61 // When the default presentation is started on this frame, | 74 // When the default presentation is started on this frame, |
| 62 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. | 75 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. |
| 63 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); | 76 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); |
| 64 | 77 |
| 65 // Starts listening for screen availability for presentation of | 78 // Starts listening for screen availability for presentation of |
| 66 // |availability_url|. Availability results will be returned to the client via | 79 // |availability_url|. Availability results will be returned to the client via |
| 67 // PresentationServiceClient::OnScreenAvailabilityUpdated. | 80 // PresentationServiceClient::OnScreenAvailabilityUpdated. |
| 68 ListenForScreenAvailability(url.mojom.Url availability_url); | 81 ListenForScreenAvailability(url.mojom.Url availability_url); |
| 69 | 82 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 84 StartSession(array<url.mojom.Url> presentation_urls) | 97 StartSession(array<url.mojom.Url> presentation_urls) |
| 85 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 98 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
| 86 | 99 |
| 87 // Called when joinSession() is called by the frame. The result callback | 100 // Called when joinSession() is called by the frame. The result callback |
| 88 // works the same as for the method above. JoinSession will join a known | 101 // works the same as for the method above. JoinSession will join a known |
| 89 // session (i.e. when the page navigates or the user opens another tab) | 102 // session (i.e. when the page navigates or the user opens another tab) |
| 90 // silently and without user action. | 103 // silently and without user action. |
| 91 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) | 104 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) |
| 92 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 105 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
| 93 | 106 |
| 107 // Called in StartSession's callback function for offscreen presentation only. | |
| 108 // It passes in controlling frame's PresentationConnection and | |
| 109 // PresentationConnectionRequest to PresentationService. | |
| 110 SetPresentationConnection(PresentationSessionInfo sessionInfo, | |
| 111 PresentationConnection controller_conn_ptr, | |
|
dcheng
2017/01/10 06:46:59
Nit: conn => connection here and below. Same below
zhaobin
2017/01/10 21:49:54
Done.
| |
| 112 PresentationConnection& receiver_conn_request); | |
| 113 | |
| 114 ////////////////////////////////////////////////////////////////////////////// | |
| 115 | |
| 94 // Called when send() is called by the frame. The true in the | 116 // Called when send() is called by the frame. The true in the |
| 95 // result callback notifies that the service is ready for next message. | 117 // result callback notifies that the service is ready for next message. |
| 96 // The false in the result callback notifies the renderer to stop sending | 118 // The false in the result callback notifies the renderer to stop sending |
| 97 // the send requests and invalidate all pending requests. This occurs | 119 // the send requests and invalidate all pending requests. This occurs |
| 98 // for eg., when frame is deleted or navigated away. | 120 // for eg., when frame is deleted or navigated away. |
| 99 SendConnectionMessage(PresentationSessionInfo sessionInfo, | 121 SendConnectionMessage(PresentationSessionInfo sessionInfo, |
| 100 ConnectionMessage message_request) => (bool success); | 122 ConnectionMessage message_request) => (bool success); |
| 101 | 123 |
| 102 // Called when close() is called by the frame. | 124 // Called when close() is called by the frame. |
| 103 CloseConnection(url.mojom.Url presentation_url, string presentation_id); | 125 CloseConnection(url.mojom.Url presentation_url, string presentation_id); |
| 104 | 126 |
| 105 // Called when terminate() is called by the frame. | 127 // Called when terminate() is called by the frame. |
| 106 Terminate(url.mojom.Url presentation_url, string presentation_id); | 128 Terminate(url.mojom.Url presentation_url, string presentation_id); |
| 107 | 129 |
| 108 // Starts listening for messages for session with |sessionInfo|. | 130 // Starts listening for messages for session with |sessionInfo|. |
| 109 // Messages will be received in | 131 // Messages will be received in |
| 110 // PresentationServiceClient::OnConnectionMessagesReceived. | 132 // PresentationServiceClient::OnConnectionMessagesReceived. |
| 111 // This is called after a presentation session is created. | 133 // This is called after a presentation session is created. |
| 112 ListenForConnectionMessages(PresentationSessionInfo sessionInfo); | 134 ListenForConnectionMessages(PresentationSessionInfo sessionInfo); |
| 113 }; | 135 }; |
| 114 | 136 |
| 115 interface PresentationServiceClient { | 137 interface PresentationServiceClient { |
| 138 | |
| 139 ////////////Functions here are called only on the controlling page./////////// | |
| 140 | |
| 116 // Called when the client tries to listen for screen availability changes for | 141 // Called when the client tries to listen for screen availability changes for |
| 117 // presentation of |url| but it is not supported by the device or underlying | 142 // presentation of |url| but it is not supported by the device or underlying |
| 118 // platform. This can also be called if the device is currently in a mode | 143 // platform. This can also be called if the device is currently in a mode |
| 119 // where it can't do screen discoveries (eg. low battery). | 144 // where it can't do screen discoveries (eg. low battery). |
| 120 OnScreenAvailabilityNotSupported(url.mojom.Url url); | 145 OnScreenAvailabilityNotSupported(url.mojom.Url url); |
| 121 | 146 |
| 122 // Called when the client is listening for screen availability for | 147 // Called when the client is listening for screen availability for |
| 123 // presentation of |url| and the state changes. When the client starts to | 148 // presentation of |url| and the state changes. When the client starts to |
| 124 // listen for screen availability, this method will always be called to give | 149 // listen for screen availability, this method will always be called to give |
| 125 // the current known state. It will then be called to notify of state updates. | 150 // the current known state. It will then be called to notify of state updates. |
| 126 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); | 151 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); |
| 127 | 152 |
| 153 // See PresentationService::SetDefaultPresentationURL. | |
| 154 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); | |
| 155 | |
| 156 ////////////////////////////////////////////////////////////////////////////// | |
| 157 | |
| 128 // Called when the state of PresentationConnection |connection| started on | 158 // Called when the state of PresentationConnection |connection| started on |
| 129 // this frame has changed to |newState|. | 159 // this frame has changed to |newState|. |
| 130 OnConnectionStateChanged(PresentationSessionInfo connection, | 160 OnConnectionStateChanged(PresentationSessionInfo connection, |
| 131 PresentationConnectionState newState); | 161 PresentationConnectionState newState); |
| 132 | 162 |
| 133 // Caled when the state of |connection| started on this frame has changed to | 163 // Caled when the state of |connection| started on this frame has changed to |
| 134 // CLOSED. | 164 // CLOSED. |
| 135 OnConnectionClosed(PresentationSessionInfo connection, | 165 OnConnectionClosed(PresentationSessionInfo connection, |
| 136 PresentationConnectionCloseReason reason, | 166 PresentationConnectionCloseReason reason, |
| 137 string message); | 167 string message); |
| 138 | 168 |
| 139 // See PresentationService::ListenForConnectionMessages. | 169 // See PresentationService::ListenForConnectionMessages. |
| 140 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, | 170 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, |
| 141 array<ConnectionMessage> messages); | 171 array<ConnectionMessage> messages); |
| 142 | 172 |
| 143 // See PresentationService::SetDefaultPresentationURL. | 173 // Called on a presentation receiver when the first presentation connection is |
|
dcheng
2017/01/10 06:46:58
What happens when subsequent connections are avail
zhaobin
2017/01/10 21:49:54
Done.
Outdated comments. It is invoked for all pr
| |
| 144 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); | 174 // available from the controlling page. |
| 145 | 175 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo, |
| 146 // See PresentationService::OnReceiverConnectionAvailable. | 176 PresentationConnection controller_conn_ptr, |
| 147 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo); | 177 PresentationConnection& receiver_conn_request); |
| 148 }; | 178 }; |
| OLD | NEW |