OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Use the <code>chrome.dial</code> API to discover devices that support DIAL. | 5 // Use the <code>chrome.dial</code> API to discover devices that support DIAL. |
6 // Protocol specification: http://www.dial-multiscreen.org/ | 6 // Protocol specification: http://www.dial-multiscreen.org/ |
7 namespace dial { | 7 namespace dial { |
8 | 8 |
9 // Represents a unique device that responded to a DIAL discovery request. | 9 // Represents a unique device that responded to a DIAL discovery request. |
10 dictionary DialDevice { | 10 dictionary DialDevice { |
11 | 11 |
12 // A label identifying the device within this instance of the browser. | 12 // A label identifying the device within this instance of the browser. |
13 // Not guaranteed to persist beyond browser instances. | 13 // Not guaranteed to persist beyond browser instances. |
14 DOMString deviceLabel; | 14 DOMString deviceLabel; |
15 | 15 |
16 // A URL pointing to the device description resource for the device. | 16 // A URL pointing to the device description resource for the device. |
17 DOMString deviceDescriptionUrl; | 17 DOMString deviceDescriptionUrl; |
18 | 18 |
19 // The uPnP configuration ID reported by the device. Corresponds to the | 19 // The uPnP configuration ID reported by the device. Corresponds to the |
20 // CONFIGID.UPNP.ORG header in the M-SEARCH response. | 20 // CONFIGID.UPNP.ORG header in the M-SEARCH response. |
21 long? configId; | 21 long? configId; |
22 }; | 22 }; |
23 | 23 |
| 24 // Represents a device description resource successfully fetched from a |
| 25 // DIAL device. |
| 26 dictionary DialDeviceDescription { |
| 27 |
| 28 // The label of the device that the description was fetched for. |
| 29 DOMString deviceLabel; |
| 30 |
| 31 // The contents of the Application-URL header in the response. |
| 32 DOMString appUrl; |
| 33 |
| 34 // The content of the response body. This will be an XML document |
| 35 // (hopefully) conforming to section 2.3 of the UPnP spec. |
| 36 DOMString deviceDescription; |
| 37 }; |
| 38 |
24 enum DialErrorCode { | 39 enum DialErrorCode { |
25 no_listeners, | 40 no_listeners, |
26 no_valid_network_interfaces, | 41 no_valid_network_interfaces, |
27 network_disconnected, | 42 network_disconnected, |
28 cellular_network, | 43 cellular_network, |
29 socket_error, | 44 socket_error, |
30 unknown | 45 unknown |
31 }; | 46 }; |
32 | 47 |
33 dictionary DialError { | 48 dictionary DialError { |
34 DialErrorCode code; | 49 DialErrorCode code; |
35 }; | 50 }; |
36 | 51 |
37 callback BooleanCallback = void (boolean result); | 52 callback BooleanCallback = void (boolean result); |
| 53 callback DeviceDescriptionCallback = void (DialDeviceDescription result); |
38 | 54 |
39 interface Functions { | 55 interface Functions { |
40 | 56 |
41 // Requests that DIAL discovery happen immediately. The request may not be | 57 // Requests that DIAL discovery happen immediately. The request may not be |
42 // honored as discovery may already be happening in the background. The | 58 // honored as discovery may already be happening in the background. The |
43 // callback is invoked with |true| if discovery was initiated or |false| | 59 // callback is invoked with |true| if discovery was initiated or |false| |
44 // otherwise. | 60 // otherwise. |
45 static void discoverNow(BooleanCallback callback); | 61 static void discoverNow(BooleanCallback callback); |
| 62 |
| 63 // Fetches the device description for the DIAL device identified by |
| 64 // |deviceLabel|. If successful, the callback is invoked with a |
| 65 // DialDeviceDescription containing the content of the device description. |
| 66 // |
| 67 // If unsuccessful, callback is invoked with |null| and lastError is set to |
| 68 // an error message. If the error occurred during the HTTP fetch itself, |
| 69 // the message will begin with "HTTP XXX:" where XXX is the HTTP result |
| 70 // code. |
| 71 static void fetchDeviceDescription(DOMString deviceLabel, |
| 72 DeviceDescriptionCallback callback); |
46 }; | 73 }; |
47 | 74 |
48 interface Events { | 75 interface Events { |
49 | 76 |
50 // Event fired to inform clients of the current, complete set of responsive | 77 // Event fired to inform clients of the current, complete set of responsive |
51 // devices. Clients should only need to store the list from the most recent | 78 // devices. Clients should only need to store the list from the most recent |
52 // event. May be fired in response to multiple circumstances: | 79 // event. May be fired in response to multiple circumstances: |
53 // | 80 // |
54 // (1) The DIAL service refreshed its device list through periodic polling. | 81 // (1) The DIAL service refreshed its device list through periodic polling. |
55 // (2) A client invoked discoverNow(). | 82 // (2) A client invoked discoverNow(). |
56 // (3) An event happened that should invalidate the device list | 83 // (3) An event happened that should invalidate the device list |
57 // (e.g., a network interface went offline), in which case it is fired | 84 // (e.g., a network interface went offline), in which case it is fired |
58 // with an empty array. | 85 // with an empty array. |
59 static void onDeviceList(DialDevice[] result); | 86 static void onDeviceList(DialDevice[] result); |
60 | 87 |
61 // Event fired to inform clients on errors during device discovery. | 88 // Event fired to inform clients on errors during device discovery. |
62 static void onError(DialError error); | 89 static void onError(DialError error); |
63 }; | 90 }; |
64 }; | 91 }; |
OLD | NEW |