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 |
11 struct PresentationSessionInfo { | 11 struct PresentationSessionInfo { |
12 url.mojom.Url url; | 12 url.mojom.Url url; |
13 string id; | 13 string id; |
| 14 bool is_offscreen; |
14 }; | 15 }; |
15 | 16 |
16 enum PresentationConnectionState { | 17 enum PresentationConnectionState { |
17 CONNECTING, | 18 CONNECTING, |
18 CONNECTED, | 19 CONNECTED, |
19 CLOSED, | 20 CLOSED, |
20 TERMINATED | 21 TERMINATED |
21 }; | 22 }; |
22 | 23 |
23 enum PresentationConnectionCloseReason { | 24 enum PresentationConnectionCloseReason { |
(...skipping 21 matching lines...) Expand all Loading... |
45 }; | 46 }; |
46 | 47 |
47 struct SessionMessage { | 48 struct SessionMessage { |
48 PresentationMessageType type; | 49 PresentationMessageType type; |
49 // Used when message type is TEXT. | 50 // Used when message type is TEXT. |
50 string? message; | 51 string? message; |
51 // Used when message type is ARRAY_BUFFER or BLOB. | 52 // Used when message type is ARRAY_BUFFER or BLOB. |
52 array<uint8>? data; | 53 array<uint8>? data; |
53 }; | 54 }; |
54 | 55 |
| 56 interface PresentationConnection { |
| 57 // TODO(zhaobin): migrate SendSessionMessage from PresenationService => |
| 58 // PresentationConnection.Send(). http://crbug.com/658474 |
| 59 |
| 60 // Called to set the PresentationConnection that is the destination for |
| 61 // messages sent and the source of messages received by this connection. |
| 62 SetTargetConnection(PresentationConnection connection); |
| 63 |
| 64 // Called when a message is sent by the target connection. |
| 65 OnMessage(SessionMessage message); |
| 66 }; |
| 67 |
55 interface PresentationService { | 68 interface PresentationService { |
56 // Sets the PresentationServiceClient. | 69 // Sets the PresentationServiceClient. |
57 SetClient(PresentationServiceClient client); | 70 SetClient(PresentationServiceClient client); |
58 | 71 |
| 72 /////////////Functions here are for the controller part of the API./////////// |
| 73 |
59 // Called when the frame sets or changes the default presentation URLs. | 74 // Called when the frame sets or changes the default presentation URLs. |
60 // When the default presentation is started on this frame, | 75 // When the default presentation is started on this frame, |
61 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. | 76 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. |
62 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); | 77 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); |
63 | 78 |
64 // Starts listening for screen availability for presentation of | 79 // Starts listening for screen availability for presentation of |
65 // |availability_url|. Availability results will be returned to the client via | 80 // |availability_url|. Availability results will be returned to the client via |
66 // PresentationServiceClient::OnScreenAvailabilityUpdated. | 81 // PresentationServiceClient::OnScreenAvailabilityUpdated. |
67 ListenForScreenAvailability(url.mojom.Url availability_url); | 82 ListenForScreenAvailability(url.mojom.Url availability_url); |
68 | 83 |
(...skipping 14 matching lines...) Expand all Loading... |
83 StartSession(array<url.mojom.Url> presentation_urls) | 98 StartSession(array<url.mojom.Url> presentation_urls) |
84 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 99 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
85 | 100 |
86 // Called when joinSession() is called by the frame. The result callback | 101 // Called when joinSession() is called by the frame. The result callback |
87 // works the same as for the method above. JoinSession will join a known | 102 // works the same as for the method above. JoinSession will join a known |
88 // session (i.e. when the page navigates or the user opens another tab) | 103 // session (i.e. when the page navigates or the user opens another tab) |
89 // silently and without user action. | 104 // silently and without user action. |
90 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) | 105 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) |
91 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 106 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
92 | 107 |
| 108 // Called in StartSession's callback function for 1-UA presentations only. It |
| 109 // sends controlling frame's PresentationConnection to PresentationService. |
| 110 SetPresentationConnection(PresentationSessionInfo sessionInfo, |
| 111 PresentationConnection connection); |
| 112 |
| 113 ////////////////////////////////////////////////////////////////////////////// |
| 114 |
93 // Called when send() is called by the frame. The true in the | 115 // Called when send() is called by the frame. The true in the |
94 // result callback notifies that the service is ready for next message. | 116 // result callback notifies that the service is ready for next message. |
95 // The false in the result callback notifies the renderer to stop sending | 117 // The false in the result callback notifies the renderer to stop sending |
96 // the send requests and invalidate all pending requests. This occurs | 118 // the send requests and invalidate all pending requests. This occurs |
97 // for eg., when frame is deleted or navigated away. | 119 // for eg., when frame is deleted or navigated away. |
98 SendSessionMessage(PresentationSessionInfo sessionInfo, | 120 SendSessionMessage(PresentationSessionInfo sessionInfo, |
99 SessionMessage message_request) => (bool success); | 121 SessionMessage message_request) => (bool success); |
100 | 122 |
101 // Called when close() is called by the frame. | 123 // Called when close() is called by the frame. |
102 CloseConnection(url.mojom.Url presentation_url, string presentation_id); | 124 CloseConnection(url.mojom.Url presentation_url, string presentation_id); |
103 | 125 |
104 // Called when terminate() is called by the frame. | 126 // Called when terminate() is called by the frame. |
105 Terminate(url.mojom.Url presentation_url, string presentation_id); | 127 Terminate(url.mojom.Url presentation_url, string presentation_id); |
106 | 128 |
107 // Starts listening for messages for session with |sessionInfo|. | 129 // Starts listening for messages for session with |sessionInfo|. |
108 // Messages will be received in | 130 // Messages will be received in |
109 // PresentationServiceClient::OnSessionMessagesReceived. | 131 // PresentationServiceClient::OnSessionMessagesReceived. |
110 // This is called after a presentation session is created. | 132 // This is called after a presentation session is created. |
111 ListenForSessionMessages(PresentationSessionInfo sessionInfo); | 133 ListenForSessionMessages(PresentationSessionInfo sessionInfo); |
112 }; | 134 }; |
113 | 135 |
114 interface PresentationServiceClient { | 136 interface PresentationServiceClient { |
| 137 |
| 138 ////////////Functions here are called only on the controlling page./////////// |
| 139 |
115 // Called when the client tries to listen for screen availability changes for | 140 // 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 | 141 // 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 | 142 // 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). | 143 // where it can't do screen discoveries (eg. low battery). |
119 OnScreenAvailabilityNotSupported(url.mojom.Url url); | 144 OnScreenAvailabilityNotSupported(url.mojom.Url url); |
120 | 145 |
121 // Called when the client is listening for screen availability for | 146 // Called when the client is listening for screen availability for |
122 // presentation of |url| and the state changes. When the client starts to | 147 // 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 | 148 // 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. | 149 // the current known state. It will then be called to notify of state updates. |
125 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); | 150 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); |
126 | 151 |
| 152 // See PresentationService::SetDefaultPresentationURL. |
| 153 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); |
| 154 |
| 155 ////////////////////////////////////////////////////////////////////////////// |
| 156 |
127 // Called when the state of PresentationConnection |connection| started on | 157 // Called when the state of PresentationConnection |connection| started on |
128 // this frame has changed to |newState|. | 158 // this frame has changed to |newState|. |
129 OnConnectionStateChanged(PresentationSessionInfo connection, | 159 OnConnectionStateChanged(PresentationSessionInfo connection, |
130 PresentationConnectionState newState); | 160 PresentationConnectionState newState); |
131 | 161 |
132 // Caled when the state of |connection| started on this frame has changed to | 162 // Caled when the state of |connection| started on this frame has changed to |
133 // CLOSED. | 163 // CLOSED. |
134 OnConnectionClosed(PresentationSessionInfo connection, | 164 OnConnectionClosed(PresentationSessionInfo connection, |
135 PresentationConnectionCloseReason reason, | 165 PresentationConnectionCloseReason reason, |
136 string message); | 166 string message); |
137 | 167 |
138 // See PresentationService::ListenForSessionMessages. | 168 // See PresentationService::ListenForSessionMessages. |
139 OnSessionMessagesReceived(PresentationSessionInfo sessionInfo, | 169 OnSessionMessagesReceived(PresentationSessionInfo sessionInfo, |
140 array<SessionMessage> messages); | 170 array<SessionMessage> messages); |
141 | 171 |
142 // See PresentationService::SetDefaultPresentationURL. | 172 // Called on a presentation receiver when the first presentation connection is |
143 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); | 173 // available from the controlling page. |
144 | 174 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo, |
145 // See PresentationService::ListeningForReceiverPageRendered. | 175 PresentationConnection connection); |
146 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo); | |
147 }; | 176 }; |
OLD | NEW |