| 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 // API for communicating with a Google Cast device over an authenticated | 5 // API for communicating with a Google Cast device over an authenticated |
| 6 // channel. | 6 // channel. |
| 7 namespace cast.channel { | 7 namespace cast.channel { |
| 8 | 8 |
| 9 // The state of the channel. | 9 // The state of the channel. |
| 10 enum ReadyState { | 10 enum ReadyState { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // DEPRECATED: The URL to the receiver. This field will be removed in a | 83 // DEPRECATED: The URL to the receiver. This field will be removed in a |
| 84 // future release. | 84 // future release. |
| 85 DOMString url; | 85 DOMString url; |
| 86 | 86 |
| 87 // Connection information that was used to establish the channel to the | 87 // Connection information that was used to establish the channel to the |
| 88 // receiver. | 88 // receiver. |
| 89 ConnectInfo connectInfo; | 89 ConnectInfo connectInfo; |
| 90 | 90 |
| 91 // The current state of the channel. | 91 // The current state of the channel. |
| 92 ReadyState readyState; | 92 ReadyState readyState; |
| 93 | 93 |
| 94 // If set, the last error condition encountered by the channel. | 94 // If set, the last error condition encountered by the channel. |
| 95 ChannelError? errorState; | 95 ChannelError? errorState; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 // Describes a message sent or received over the channel. Currently only | 98 // Describes a message sent or received over the channel. Currently only |
| 99 // string messages are supported, although ArrayBuffer and Blob types may be | 99 // string messages are supported, although ArrayBuffer and Blob types may be |
| 100 // supported in the future. | 100 // supported in the future. |
| 101 dictionary MessageInfo { | 101 dictionary MessageInfo { |
| 102 // The message namespace. A namespace is a URN of the form | 102 // The message namespace. A namespace is a URN of the form |
| 103 // urn:cast-x:<namespace> that is used to interpret and route Cast messages. | 103 // urn:cast-x:<namespace> that is used to interpret and route Cast messages. |
| 104 DOMString namespace_; | 104 DOMString namespace_; |
| 105 | 105 |
| 106 // source and destination ids identify the origin and destination of the | 106 // source and destination ids identify the origin and destination of the |
| 107 // message. They are used to route messages between endpoints that share a | 107 // message. They are used to route messages between endpoints that share a |
| 108 // device-to-device channel. | 108 // device-to-device channel. |
| 109 // | 109 // |
| 110 // For messages between applications: | 110 // For messages between applications: |
| 111 // - The sender application id is a unique identifier generated on behalf | 111 // - The sender application id is a unique identifier generated on behalf |
| 112 // of the sender application. | 112 // of the sender application. |
| 113 // - The receiver id is always the the session id for the application. | 113 // - The receiver id is always the the session id for the application. |
| 114 // | 114 // |
| 115 // For messages to or from the sender or receiver platform, the special ids | 115 // For messages to or from the sender or receiver platform, the special ids |
| 116 // 'sender-0' and 'receiver-0' can be used. | 116 // 'sender-0' and 'receiver-0' can be used. |
| 117 // | 117 // |
| 118 // For messages intended for all endpoints using a given channel, the | 118 // For messages intended for all endpoints using a given channel, the |
| 119 // wildcard destination_id '*' can be used. | 119 // wildcard destination_id '*' can be used. |
| 120 DOMString sourceId; | 120 DOMString sourceId; |
| 121 DOMString destinationId; | 121 DOMString destinationId; |
| 122 | 122 |
| 123 // The content of the message. Must be either a string or an ArrayBuffer. | 123 // The content of the message. Must be either a string or an ArrayBuffer. |
| 124 any data; | 124 any data; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 // Describes a terminal error encountered by the channel with details of the | 127 // Describes a terminal error encountered by the channel with details of the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 150 | 150 |
| 151 // Callback holding the result of a channel operation. | 151 // Callback holding the result of a channel operation. |
| 152 callback ChannelInfoCallback = void (ChannelInfo result); | 152 callback ChannelInfoCallback = void (ChannelInfo result); |
| 153 | 153 |
| 154 // Callback from <code>getLogs</code> method. | 154 // Callback from <code>getLogs</code> method. |
| 155 // |log|: compressed serialized raw bytes containing the logs. | 155 // |log|: compressed serialized raw bytes containing the logs. |
| 156 // The log is formatted using protocol buffer. | 156 // The log is formatted using protocol buffer. |
| 157 // See extensions/browser/api/cast_channel/logging.proto for definition. | 157 // See extensions/browser/api/cast_channel/logging.proto for definition. |
| 158 // Compression is in gzip format. | 158 // Compression is in gzip format. |
| 159 callback GetLogsCallback = void (ArrayBuffer log); | 159 callback GetLogsCallback = void (ArrayBuffer log); |
| 160 | 160 |
| 161 // Callback from <code>setAuthorityKeys</code> method. |
| 162 callback SetAuthorityKeysCallback = void (DOMString result); |
| 163 |
| 161 interface Functions { | 164 interface Functions { |
| 162 // Opens a new channel to the Cast receiver specified by connectInfo. Only | 165 // Opens a new channel to the Cast receiver specified by connectInfo. Only |
| 163 // one channel may be connected to same receiver from the same extension at | 166 // one channel may be connected to same receiver from the same extension at |
| 164 // a time. If the open request is successful, the callback will be invoked | 167 // a time. If the open request is successful, the callback will be invoked |
| 165 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the | 168 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the |
| 166 // callback will be invoked with a ChannelInfo with channel.readyState == | 169 // callback will be invoked with a ChannelInfo with channel.readyState == |
| 167 // 'closed', channel.errorState will be set to the error condition, and | 170 // 'closed', channel.errorState will be set to the error condition, and |
| 168 // onError will be fired with error details. | 171 // onError will be fired with error details. |
| 169 // | 172 // |
| 170 // TODO(mfoltz): Convert 'any' to ConnectInfo once all clients are updated | 173 // TODO(mfoltz): Convert 'any' to ConnectInfo once all clients are updated |
| (...skipping 10 matching lines...) Expand all Loading... |
| 181 MessageInfo message, | 184 MessageInfo message, |
| 182 ChannelInfoCallback callback); | 185 ChannelInfoCallback callback); |
| 183 | 186 |
| 184 // Requests that the channel be closed and invokes callback with the | 187 // Requests that the channel be closed and invokes callback with the |
| 185 // resulting channel status. The channel must be in readyState == 'open' or | 188 // resulting channel status. The channel must be in readyState == 'open' or |
| 186 // 'connecting'. If successful, onClose will be fired with readyState == | 189 // 'connecting'. If successful, onClose will be fired with readyState == |
| 187 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed', | 190 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed', |
| 188 // and channel.errorState will be set to the error condition. | 191 // and channel.errorState will be set to the error condition. |
| 189 static void close(ChannelInfo channel, | 192 static void close(ChannelInfo channel, |
| 190 ChannelInfoCallback callback); | 193 ChannelInfoCallback callback); |
| 191 | 194 |
| 192 // Get logs in compressed serialized format. See GetLogsCallback for | 195 // Get logs in compressed serialized format. See GetLogsCallback for |
| 193 // details. | 196 // details. |
| 194 // |callback|: If successful, |callback| is invoked with data. Otherwise, | 197 // |callback|: If successful, |callback| is invoked with data. Otherwise, |
| 195 // an error will be raised. | 198 // an error will be raised. |
| 196 static void getLogs(GetLogsCallback callback); | 199 static void getLogs(GetLogsCallback callback); |
| 200 |
| 201 // Sets trusted certificate authorities where |signature| is a base64 |
| 202 // encoded RSA-PSS signature and |keys| is base64 encoded AuthorityKeys |
| 203 // protobuf. |
| 204 static void setAuthorityKeys(DOMString signature, |
| 205 DOMString keys, |
| 206 SetAuthorityKeysCallback callback); |
| 197 }; | 207 }; |
| 198 | 208 |
| 199 // Events on the channel. | 209 // Events on the channel. |
| 200 interface Events { | 210 interface Events { |
| 201 // Fired when a message is received on an open channel. | 211 // Fired when a message is received on an open channel. |
| 202 static void onMessage(ChannelInfo channel, | 212 static void onMessage(ChannelInfo channel, |
| 203 MessageInfo message); | 213 MessageInfo message); |
| 204 | 214 |
| 205 // Fired when an error occurs as a result of a channel operation or a | 215 // Fired when an error occurs as a result of a channel operation or a |
| 206 // network event. |error| contains details of the error. | 216 // network event. |error| contains details of the error. |
| 207 static void onError(ChannelInfo channel, ErrorInfo error); | 217 static void onError(ChannelInfo channel, ErrorInfo error); |
| 208 }; | 218 }; |
| 209 }; | 219 }; |
| OLD | NEW |