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 22 matching lines...) Expand all Loading... |
33 UNKNOWN, | 33 UNKNOWN, |
34 }; | 34 }; |
35 | 35 |
36 struct PresentationError { | 36 struct PresentationError { |
37 PresentationErrorType error_type; | 37 PresentationErrorType error_type; |
38 string message; | 38 string message; |
39 }; | 39 }; |
40 | 40 |
41 enum PresentationMessageType { | 41 enum PresentationMessageType { |
42 TEXT, | 42 TEXT, |
43 ARRAY_BUFFER, | 43 BINARY, |
44 BLOB, | |
45 }; | 44 }; |
46 | 45 |
47 struct SessionMessage { | 46 struct ConnectionMessage { |
48 PresentationMessageType type; | 47 PresentationMessageType type; |
49 // Used when message type is TEXT. | 48 // Used when message type is TEXT. |
50 string? message; | 49 string? message; |
51 // Used when message type is ARRAY_BUFFER or BLOB. | 50 // Used when message type is BINARY. |
| 51 // TODO(lethalantidote): Make this a mojo union. |
| 52 // See https://crbug.com/632623. |
52 array<uint8>? data; | 53 array<uint8>? data; |
53 }; | 54 }; |
54 | 55 |
55 interface PresentationService { | 56 interface PresentationService { |
56 // Sets the PresentationServiceClient. | 57 // Sets the PresentationServiceClient. |
57 SetClient(PresentationServiceClient client); | 58 SetClient(PresentationServiceClient client); |
58 | 59 |
59 // Called when the frame sets or changes the default presentation URLs. | 60 // Called when the frame sets or changes the default presentation URLs. |
60 // When the default presentation is started on this frame, | 61 // When the default presentation is started on this frame, |
61 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. | 62 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. |
(...skipping 26 matching lines...) Expand all Loading... |
88 // session (i.e. when the page navigates or the user opens another tab) | 89 // session (i.e. when the page navigates or the user opens another tab) |
89 // silently and without user action. | 90 // silently and without user action. |
90 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) | 91 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) |
91 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 92 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
92 | 93 |
93 // Called when send() is called by the frame. The true in the | 94 // Called when send() is called by the frame. The true in the |
94 // result callback notifies that the service is ready for next message. | 95 // result callback notifies that the service is ready for next message. |
95 // The false in the result callback notifies the renderer to stop sending | 96 // The false in the result callback notifies the renderer to stop sending |
96 // the send requests and invalidate all pending requests. This occurs | 97 // the send requests and invalidate all pending requests. This occurs |
97 // for eg., when frame is deleted or navigated away. | 98 // for eg., when frame is deleted or navigated away. |
98 SendSessionMessage(PresentationSessionInfo sessionInfo, | 99 SendConnectionMessage(PresentationSessionInfo sessionInfo, |
99 SessionMessage message_request) => (bool success); | 100 ConnectionMessage message_request) => (bool success); |
100 | 101 |
101 // Called when close() is called by the frame. | 102 // Called when close() is called by the frame. |
102 CloseConnection(url.mojom.Url presentation_url, string presentation_id); | 103 CloseConnection(url.mojom.Url presentation_url, string presentation_id); |
103 | 104 |
104 // Called when terminate() is called by the frame. | 105 // Called when terminate() is called by the frame. |
105 Terminate(url.mojom.Url presentation_url, string presentation_id); | 106 Terminate(url.mojom.Url presentation_url, string presentation_id); |
106 | 107 |
107 // Starts listening for messages for session with |sessionInfo|. | 108 // Starts listening for messages for session with |sessionInfo|. |
108 // Messages will be received in | 109 // Messages will be received in |
109 // PresentationServiceClient::OnSessionMessagesReceived. | 110 // PresentationServiceClient::OnConnectionMessagesReceived. |
110 // This is called after a presentation session is created. | 111 // This is called after a presentation session is created. |
111 ListenForSessionMessages(PresentationSessionInfo sessionInfo); | 112 ListenForConnectionMessages(PresentationSessionInfo sessionInfo); |
112 }; | 113 }; |
113 | 114 |
114 interface PresentationServiceClient { | 115 interface PresentationServiceClient { |
115 // Called when the client tries to listen for screen availability changes for | 116 // Called when the client tries to listen for screen availability changes for |
116 // presentation of |url| but it is not supported by the device or underlying | 117 // presentation of |url| but it is not supported by the device or underlying |
117 // platform. This can also be called if the device is currently in a mode | 118 // platform. This can also be called if the device is currently in a mode |
118 // where it can't do screen discoveries (eg. low battery). | 119 // where it can't do screen discoveries (eg. low battery). |
119 OnScreenAvailabilityNotSupported(url.mojom.Url url); | 120 OnScreenAvailabilityNotSupported(url.mojom.Url url); |
120 | 121 |
121 // Called when the client is listening for screen availability for | 122 // Called when the client is listening for screen availability for |
122 // presentation of |url| and the state changes. When the client starts to | 123 // presentation of |url| and the state changes. When the client starts to |
123 // listen for screen availability, this method will always be called to give | 124 // listen for screen availability, this method will always be called to give |
124 // the current known state. It will then be called to notify of state updates. | 125 // the current known state. It will then be called to notify of state updates. |
125 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); | 126 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); |
126 | 127 |
127 // Called when the state of PresentationConnection |connection| started on | 128 // Called when the state of PresentationConnection |connection| started on |
128 // this frame has changed to |newState|. | 129 // this frame has changed to |newState|. |
129 OnConnectionStateChanged(PresentationSessionInfo connection, | 130 OnConnectionStateChanged(PresentationSessionInfo connection, |
130 PresentationConnectionState newState); | 131 PresentationConnectionState newState); |
131 | 132 |
132 // Caled when the state of |connection| started on this frame has changed to | 133 // Caled when the state of |connection| started on this frame has changed to |
133 // CLOSED. | 134 // CLOSED. |
134 OnConnectionClosed(PresentationSessionInfo connection, | 135 OnConnectionClosed(PresentationSessionInfo connection, |
135 PresentationConnectionCloseReason reason, | 136 PresentationConnectionCloseReason reason, |
136 string message); | 137 string message); |
137 | 138 |
138 // See PresentationService::ListenForSessionMessages. | 139 // See PresentationService::ListenForConnectionMessages. |
139 OnSessionMessagesReceived(PresentationSessionInfo sessionInfo, | 140 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, |
140 array<SessionMessage> messages); | 141 array<ConnectionMessage> messages); |
141 | 142 |
142 // See PresentationService::SetDefaultPresentationURL. | 143 // See PresentationService::SetDefaultPresentationURL. |
143 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); | 144 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); |
144 | 145 |
145 // See PresentationService::OnReceiverConnectionAvailable. | 146 // See PresentationService::OnReceiverConnectionAvailable. |
146 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo); | 147 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo); |
147 }; | 148 }; |
OLD | NEW |