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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Callback holding the result of a channel operation. | 127 // Callback holding the result of a channel operation. |
128 callback ChannelInfoCallback = void (ChannelInfo result); | 128 callback ChannelInfoCallback = void (ChannelInfo result); |
129 | 129 |
| 130 // Callback from <code>getLogs</code> method. |
| 131 // |log|: compressed serialized raw bytes containing the logs. |
| 132 // The log is formatted using protocol buffer. |
| 133 // See extensions/browser/api/cast_channel/logging.proto for definition. |
| 134 // Compression is in gzip format. |
| 135 callback GetLogsCallback = void (ArrayBuffer log); |
| 136 |
130 interface Functions { | 137 interface Functions { |
131 // Opens a new channel to the Cast receiver specified by connectInfo. Only | 138 // Opens a new channel to the Cast receiver specified by connectInfo. Only |
132 // one channel may be connected to same receiver from the same extension at | 139 // one channel may be connected to same receiver from the same extension at |
133 // a time. If the open request is successful, the callback will be invoked | 140 // a time. If the open request is successful, the callback will be invoked |
134 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the | 141 // with a ChannelInfo with readyState == 'connecting'. If unsuccessful, the |
135 // callback will be invoked with a ChannelInfo with channel.readyState == | 142 // callback will be invoked with a ChannelInfo with channel.readyState == |
136 // 'closed' and channel.errorState will be set to the error condition. | 143 // 'closed' and channel.errorState will be set to the error condition. |
137 // | 144 // |
138 // TODO(mfoltz): Convert 'any' to ConnectInfo once all clients are updated | 145 // TODO(mfoltz): Convert 'any' to ConnectInfo once all clients are updated |
139 // to not send URLs. | 146 // to not send URLs. |
140 static void open(any connectInfo, | 147 static void open(any connectInfo, |
141 ChannelInfoCallback callback); | 148 ChannelInfoCallback callback); |
142 | 149 |
143 // Sends a message on the channel and invokes callback with the resulting | 150 // Sends a message on the channel and invokes callback with the resulting |
144 // channel status. The channel must be in readyState == 'open'. If | 151 // channel status. The channel must be in readyState == 'open'. If |
145 // unsuccessful, channel.readyState will be set to 'closed', | 152 // unsuccessful, channel.readyState will be set to 'closed', |
146 // channel.errorState will be set to the error condition. | 153 // channel.errorState will be set to the error condition. |
147 static void send(ChannelInfo channel, | 154 static void send(ChannelInfo channel, |
148 MessageInfo message, | 155 MessageInfo message, |
149 ChannelInfoCallback callback); | 156 ChannelInfoCallback callback); |
150 | 157 |
151 // Requests that the channel be closed and invokes callback with the | 158 // Requests that the channel be closed and invokes callback with the |
152 // resulting channel status. The channel must be in readyState == 'open' or | 159 // resulting channel status. The channel must be in readyState == 'open' or |
153 // 'connecting'. If successful, onClose will be fired with readyState == | 160 // 'connecting'. If successful, onClose will be fired with readyState == |
154 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed', | 161 // 'closed'. If unsuccessful, channel.readyState will be set to 'closed', |
155 // and channel.errorState will be set to the error condition. | 162 // and channel.errorState will be set to the error condition. |
156 static void close(ChannelInfo channel, | 163 static void close(ChannelInfo channel, |
157 ChannelInfoCallback callback); | 164 ChannelInfoCallback callback); |
| 165 |
| 166 // Get logs in compressed serialized format. See GetLogsCallback for |
| 167 // details. |
| 168 // |callback|: If successful, |callback| is invoked with data. Otherwise, |
| 169 // an error will be raised. |
| 170 static void getLogs(GetLogsCallback callback); |
158 }; | 171 }; |
159 | 172 |
160 // Events on the channel. | 173 // Events on the channel. |
161 interface Events { | 174 interface Events { |
162 // Fired when a message is received on an open channel. | 175 // Fired when a message is received on an open channel. |
163 static void onMessage(ChannelInfo channel, | 176 static void onMessage(ChannelInfo channel, |
164 MessageInfo message); | 177 MessageInfo message); |
165 | 178 |
166 // Fired when an error occurs as a result of a channel method or a network | 179 // Fired when an error occurs as a result of a channel method or a network |
167 // event. | 180 // event. |
168 static void onError(ChannelInfo channel); | 181 static void onError(ChannelInfo channel); |
169 }; | 182 }; |
170 }; | 183 }; |
OLD | NEW |