| 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 // The state of the channel. | 8 // The state of the channel. |
| 9 enum ReadyState { | 9 enum ReadyState { |
| 10 // The channel is connecting. | 10 // The channel is connecting. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // defined in net/base/net_error_list.h. | 161 // defined in net/base/net_error_list.h. |
| 162 long? netReturnValue; | 162 long? netReturnValue; |
| 163 | 163 |
| 164 // An error code returned by NSS. Values are defined in secerr.h. | 164 // An error code returned by NSS. Values are defined in secerr.h. |
| 165 long? nssErrorCode; | 165 long? nssErrorCode; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 // Callback holding the result of a channel operation. | 168 // Callback holding the result of a channel operation. |
| 169 callback ChannelInfoCallback = void (ChannelInfo result); | 169 callback ChannelInfoCallback = void (ChannelInfo result); |
| 170 | 170 |
| 171 // Callback from <code>getLogs</code> method. | |
| 172 // |log|: compressed serialized raw bytes containing the logs. | |
| 173 // The log is formatted using protocol buffer. | |
| 174 // See extensions/browser/api/cast_channel/logging.proto for definition. | |
| 175 // Compression is in gzip format. | |
| 176 callback GetLogsCallback = void (ArrayBuffer log); | |
| 177 | |
| 178 // Callback from <code>setAuthorityKeys</code> method. | |
| 179 callback SetAuthorityKeysCallback = void (); | |
| 180 | |
| 181 interface Functions { | 171 interface Functions { |
| 182 // Opens a new channel to the Cast receiver specified by connectInfo. Only | 172 // Opens a new channel to the Cast receiver specified by connectInfo. Only |
| 183 // one channel may be connected to same receiver from the same extension at | 173 // one channel may be connected to same receiver from the same extension at |
| 184 // a time. If the open request is successful, the callback will be invoked | 174 // a time. If the open request is successful, the callback will be invoked |
| 185 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the | 175 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the |
| 186 // callback will be invoked with a ChannelInfo with channel.readyState == | 176 // callback will be invoked with a ChannelInfo with channel.readyState == |
| 187 // 'closed', channel.errorState will be set to the error condition, and | 177 // 'closed', channel.errorState will be set to the error condition, and |
| 188 // onError will be fired with error details. | 178 // onError will be fired with error details. |
| 189 static void open(ConnectInfo connectInfo, | 179 static void open(ConnectInfo connectInfo, |
| 190 ChannelInfoCallback callback); | 180 ChannelInfoCallback callback); |
| 191 | 181 |
| 192 // Sends a message on the channel and invokes callback with the resulting | 182 // Sends a message on the channel and invokes callback with the resulting |
| 193 // channel status. The channel must be in readyState == 'open'. If | 183 // channel status. The channel must be in readyState == 'open'. If |
| 194 // unsuccessful, channel.readyState will be set to 'closed', | 184 // unsuccessful, channel.readyState will be set to 'closed', |
| 195 // channel.errorState will be set to the error condition, and onError will | 185 // channel.errorState will be set to the error condition, and onError will |
| 196 // be fired with error details. | 186 // be fired with error details. |
| 197 static void send(ChannelInfo channel, | 187 static void send(ChannelInfo channel, |
| 198 MessageInfo message, | 188 MessageInfo message, |
| 199 ChannelInfoCallback callback); | 189 ChannelInfoCallback callback); |
| 200 | 190 |
| 201 // Requests that the channel be closed and invokes callback with the | 191 // Requests that the channel be closed and invokes callback with the |
| 202 // resulting channel status. The channel must be in readyState == 'open' or | 192 // resulting channel status. The channel must be in readyState == 'open' or |
| 203 // 'connecting'. If successful, onClose will be fired with readyState == | 193 // 'connecting'. If successful, onClose will be fired with readyState == |
| 204 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed', | 194 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed', |
| 205 // and channel.errorState will be set to the error condition. | 195 // and channel.errorState will be set to the error condition. |
| 206 static void close(ChannelInfo channel, | 196 static void close(ChannelInfo channel, |
| 207 ChannelInfoCallback callback); | 197 ChannelInfoCallback callback); |
| 208 | |
| 209 // Get logs in compressed serialized format. See GetLogsCallback for | |
| 210 // details. | |
| 211 // |callback|: If successful, |callback| is invoked with data. Otherwise, | |
| 212 // an error will be raised. | |
| 213 static void getLogs(GetLogsCallback callback); | |
| 214 | |
| 215 // Sets trusted certificate authorities where |signature| is a base64 | |
| 216 // encoded RSA-PSS signature and |keys| is base64 encoded AuthorityKeys | |
| 217 // protobuf. | |
| 218 static void setAuthorityKeys(DOMString keys, | |
| 219 DOMString signature, | |
| 220 SetAuthorityKeysCallback callback); | |
| 221 }; | 198 }; |
| 222 | 199 |
| 223 // Events on the channel. | 200 // Events on the channel. |
| 224 interface Events { | 201 interface Events { |
| 225 // Fired when a message is received on an open channel. | 202 // Fired when a message is received on an open channel. |
| 226 static void onMessage(ChannelInfo channel, | 203 static void onMessage(ChannelInfo channel, |
| 227 MessageInfo message); | 204 MessageInfo message); |
| 228 | 205 |
| 229 // Fired when an error occurs as a result of a channel operation or a | 206 // Fired when an error occurs as a result of a channel operation or a |
| 230 // network event. |error| contains details of the error. | 207 // network event. |error| contains details of the error. |
| 231 static void onError(ChannelInfo channel, ErrorInfo error); | 208 static void onError(ChannelInfo channel, ErrorInfo error); |
| 232 }; | 209 }; |
| 233 }; | 210 }; |
| OLD | NEW |