cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / extensions / common / api / cast_channel.idl
blob37999b2d67eec5ba1d4b774a45aeb440f27fa39c
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
3 // found in the LICENSE file.
5 // API for communicating with a Google Cast device over an authenticated
6 // channel.
7 namespace cast.channel {
8 // The state of the channel.
9 enum ReadyState {
10 // The channel is connecting.
11 connecting,
12 // The channel is open and available for messaging.
13 open,
14 // The channel is closing.
15 closing,
16 // The channel is closed.
17 closed
20 // Error conditions that the channel may encounter. All error conditions
21 // are terminal. When an error condition is encountered the API will:
22 // (1) Transition the channel to readyState == 'closed'.
23 // (2) Set ChannelInfo.lastError to the error condition.
24 // (3) Fire an onError event with the error condition.
25 // (4) Fire an onClose event.
26 enum ChannelError {
27 // cast.channel.send() was called when ChannelInfo.readyState != 'open'.
28 channel_not_open,
29 // Authentication was requested and the receiver could not be
30 // authenticated (invalid signature, invalid handhake, TLS error, etc.)
31 authentication_error,
32 // A new channel could not be created for reasons unrelated to
33 // authentication (e.g., there is already an open channel to the same URL).
34 connect_error,
35 // There was an error writing or reading from the underlying socket.
36 socket_error,
37 // A transport level occurred (like an unparseable message).
38 transport_error,
39 // The client attempted to send an unsupported message type through the
40 // channel.
41 invalid_message,
42 // An invalid channel id was passed.
43 invalid_channel_id,
44 // The connection could not be established before timing out.
45 connect_timeout,
46 // The receiving end became unresponsive.
47 ping_timeout,
48 // Unspecified error.
49 unknown
52 // Authentication methods that may be required to connect to a Cast receiver.
53 enum ChannelAuthType {
54 // SSL over TCP.
55 ssl,
56 // SSL over TCP with challenge and receiver signature verification.
57 ssl_verified
60 // Describes the information needed to connect to a Cast receiver.
61 // This replaces the prior use of cast:// and casts:// URLs.
62 dictionary ConnectInfo {
63 // The IPV4 address of the Cast receiver, e.g. '198.1.0.2'.
64 // TODO(mfoltz): Investigate whether IPV6 addresses "just work."
65 DOMString ipAddress;
67 // The port number to connect to, 0-65535.
68 long port;
70 // The amount of time to wait in milliseconds before stopping the
71 // connection process. Timeouts are disabled if the value is zero.
72 // The default timeout is 8000ms.
73 long? timeout;
75 // The authentication method required for the channel.
76 ChannelAuthType auth;
78 // ------------------------------------------------------------------------
79 // Both pingInterval and livenessTimeout must be set to enable keep-alive
80 // handling.
82 // The amount of time to wait in milliseconds before sending pings
83 // to idle channels.
84 long? pingInterval;
86 // The maximum amount of idle time allowed before a channel is closed.
87 long? livenessTimeout;
89 // If set, CastDeviceCapability bitmask values describing capability of the
90 // cast device.
91 long? capabilities;
94 // Describes the state of a channel to a Cast receiver.
95 dictionary ChannelInfo {
96 // Id for the channel.
97 long channelId;
99 // Connection information that was used to establish the channel to the
100 // receiver.
101 ConnectInfo connectInfo;
103 // The current state of the channel.
104 ReadyState readyState;
106 // If set, the last error condition encountered by the channel.
107 ChannelError? errorState;
109 // If true, keep-alive messages are handled automatically by the channel.
110 boolean keepAlive;
113 // Describes a message sent or received over the channel. Currently only
114 // string messages are supported, although ArrayBuffer and Blob types may be
115 // supported in the future.
116 dictionary MessageInfo {
117 // The message namespace. A namespace is a URN of the form
118 // urn:cast-x:<namespace> that is used to interpret and route Cast messages.
119 DOMString namespace_;
121 // source and destination ids identify the origin and destination of the
122 // message. They are used to route messages between endpoints that share a
123 // device-to-device channel.
125 // For messages between applications:
126 // - The sender application id is a unique identifier generated on behalf
127 // of the sender application.
128 // - The receiver id is always the the session id for the application.
130 // For messages to or from the sender or receiver platform, the special ids
131 // 'sender-0' and 'receiver-0' can be used.
133 // For messages intended for all endpoints using a given channel, the
134 // wildcard destination_id '*' can be used.
135 DOMString sourceId;
136 DOMString destinationId;
138 // The content of the message. Must be either a string or an ArrayBuffer.
139 any data;
142 // Describes a terminal error encountered by the channel with details of the
143 // error that caused the channel to be closed. One or more of the optional
144 // fields may be set with specific error codes from the underlying
145 // implementation.
146 dictionary ErrorInfo {
147 // The type of error encountered by the channel.
148 ChannelError errorState;
150 // The event that was occurring when the error happened. Values are defined
151 // in the enum EventType in logging.proto.
152 long? eventType;
154 // An error encountered when processing the authentication handshake.
155 // Values are defined in the enum ChallengeReplyErrorType in logging.proto.
156 long? challengeReplyErrorType;
158 // A return value from the underlying net:: socket libraries. Values are
159 // defined in net/base/net_error_list.h.
160 long? netReturnValue;
162 // An error code returned by NSS. Values are defined in secerr.h.
163 long? nssErrorCode;
166 // Callback holding the result of a channel operation.
167 callback ChannelInfoCallback = void (ChannelInfo result);
169 // Callback from <code>getLogs</code> method.
170 // |log|: compressed serialized raw bytes containing the logs.
171 // The log is formatted using protocol buffer.
172 // See extensions/browser/api/cast_channel/logging.proto for definition.
173 // Compression is in gzip format.
174 callback GetLogsCallback = void (ArrayBuffer log);
176 // Callback from <code>setAuthorityKeys</code> method.
177 callback SetAuthorityKeysCallback = void ();
179 interface Functions {
180 // Opens a new channel to the Cast receiver specified by connectInfo. Only
181 // one channel may be connected to same receiver from the same extension at
182 // a time. If the open request is successful, the callback will be invoked
183 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the
184 // callback will be invoked with a ChannelInfo with channel.readyState ==
185 // 'closed', channel.errorState will be set to the error condition, and
186 // onError will be fired with error details.
187 static void open(ConnectInfo connectInfo,
188 ChannelInfoCallback callback);
190 // Sends a message on the channel and invokes callback with the resulting
191 // channel status. The channel must be in readyState == 'open'. If
192 // unsuccessful, channel.readyState will be set to 'closed',
193 // channel.errorState will be set to the error condition, and onError will
194 // be fired with error details.
195 static void send(ChannelInfo channel,
196 MessageInfo message,
197 ChannelInfoCallback callback);
199 // Requests that the channel be closed and invokes callback with the
200 // resulting channel status. The channel must be in readyState == 'open' or
201 // 'connecting'. If successful, onClose will be fired with readyState ==
202 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed',
203 // and channel.errorState will be set to the error condition.
204 static void close(ChannelInfo channel,
205 ChannelInfoCallback callback);
207 // Get logs in compressed serialized format. See GetLogsCallback for
208 // details.
209 // |callback|: If successful, |callback| is invoked with data. Otherwise,
210 // an error will be raised.
211 static void getLogs(GetLogsCallback callback);
213 // Sets trusted certificate authorities where |signature| is a base64
214 // encoded RSA-PSS signature and |keys| is base64 encoded AuthorityKeys
215 // protobuf.
216 static void setAuthorityKeys(DOMString keys,
217 DOMString signature,
218 SetAuthorityKeysCallback callback);
221 // Events on the channel.
222 interface Events {
223 // Fired when a message is received on an open channel.
224 static void onMessage(ChannelInfo channel,
225 MessageInfo message);
227 // Fired when an error occurs as a result of a channel operation or a
228 // network event. |error| contains details of the error.
229 static void onError(ChannelInfo channel, ErrorInfo error);