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 { |
(...skipping 20 matching lines...) Expand all Loading... |
31 // The contents of the Application-URL header in the response. | 31 // The contents of the Application-URL header in the response. |
32 DOMString appUrl; | 32 DOMString appUrl; |
33 | 33 |
34 // The content of the response body. This will be an XML document | 34 // The content of the response body. This will be an XML document |
35 // (hopefully) conforming to section 2.3 of the UPnP spec. | 35 // (hopefully) conforming to section 2.3 of the UPnP spec. |
36 DOMString deviceDescription; | 36 DOMString deviceDescription; |
37 }; | 37 }; |
38 | 38 |
39 enum DialErrorCode { | 39 enum DialErrorCode { |
40 no_listeners, | 40 no_listeners, |
| 41 // Deprecated. Use onNetworkIdChanged instead. |
41 no_valid_network_interfaces, | 42 no_valid_network_interfaces, |
| 43 // Deprecated. Use onNetworkIdChanged instead. |
42 network_disconnected, | 44 network_disconnected, |
43 cellular_network, | 45 cellular_network, |
44 socket_error, | 46 socket_error, |
45 unknown | 47 unknown |
46 }; | 48 }; |
47 | 49 |
48 dictionary DialError { | 50 dictionary DialError { |
49 DialErrorCode code; | 51 DialErrorCode code; |
50 }; | 52 }; |
51 | 53 |
52 callback BooleanCallback = void (boolean result); | 54 callback BooleanCallback = void (boolean result); |
53 callback DeviceDescriptionCallback = void (DialDeviceDescription result); | 55 callback DeviceDescriptionCallback = void (DialDeviceDescription result); |
| 56 callback NetworkIdCallback = void (DOMString result); |
54 | 57 |
55 interface Functions { | 58 interface Functions { |
56 | 59 |
57 // Requests that DIAL discovery happen immediately. The request may not be | 60 // Requests that DIAL discovery happen immediately. The request may not be |
58 // honored as discovery may already be happening in the background. The | 61 // honored as discovery may already be happening in the background. The |
59 // callback is invoked with |true| if discovery was initiated or |false| | 62 // callback is invoked with |true| if discovery was initiated or |false| |
60 // otherwise. | 63 // otherwise. |
61 static void discoverNow(BooleanCallback callback); | 64 static void discoverNow(BooleanCallback callback); |
62 | 65 |
63 // Fetches the device description for the DIAL device identified by | 66 // Fetches the device description for the DIAL device identified by |
64 // |deviceLabel|. If successful, the callback is invoked with a | 67 // |deviceLabel|. If successful, the callback is invoked with a |
65 // DialDeviceDescription containing the content of the device description. | 68 // DialDeviceDescription containing the content of the device description. |
66 // | 69 // |
67 // If unsuccessful, callback is invoked with |null| and lastError is set to | 70 // 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, | 71 // 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 | 72 // the message will begin with "HTTP XXX:" where XXX is the HTTP result |
70 // code. | 73 // code. |
71 static void fetchDeviceDescription(DOMString deviceLabel, | 74 static void fetchDeviceDescription(DOMString deviceLabel, |
72 DeviceDescriptionCallback callback); | 75 DeviceDescriptionCallback callback); |
| 76 |
| 77 // Returns the current discovery network identifier. See the documentation |
| 78 // for onNetworkIdChanged for details. |
| 79 static void getNetworkId(NetworkIdCallback callback); |
73 }; | 80 }; |
74 | 81 |
75 interface Events { | 82 interface Events { |
76 | 83 |
77 // Event fired to inform clients of the current, complete set of responsive | 84 // Event fired to inform clients of the current, complete set of responsive |
78 // devices. Clients should only need to store the list from the most recent | 85 // devices. Clients should only need to store the list from the most recent |
79 // event. May be fired in response to multiple circumstances: | 86 // event. May be fired in response to multiple circumstances: |
80 // | 87 // |
81 // (1) The DIAL service refreshed its device list through periodic polling. | 88 // (1) The DIAL service refreshed its device list through periodic polling. |
82 // (2) A client invoked discoverNow(). | 89 // (2) A client invoked discoverNow(). |
83 // (3) An event happened that should invalidate the device list | 90 // (3) An event happened that should invalidate the device list |
84 // (e.g., a network interface went offline), in which case it is fired | 91 // (e.g., a network interface went offline), in which case it is fired |
85 // with an empty array. | 92 // with an empty array. |
86 static void onDeviceList(DialDevice[] result); | 93 static void onDeviceList(DialDevice[] result); |
87 | 94 |
88 // Event fired to inform clients on errors during device discovery. | 95 // Event fired to inform clients on errors during device discovery. |
89 static void onError(DialError error); | 96 static void onError(DialError error); |
| 97 |
| 98 // Fired when the network being used for discovery has changed. |networkId| |
| 99 // contains a short signature combining information from network interface |
| 100 // and WiFi network identifiers to identify the current set of networks |
| 101 // being used for discovery. This can be used by clients to clear and |
| 102 // re-bootstrap device caches on a network change. |
| 103 // |
| 104 // |networkId| can take the following values: |
| 105 // - "hex-string" is a hash-style signature of the set of active networks. |
| 106 // - "disconnected" means there is no active network for discovery. |
| 107 // - "unknown" means there is an active network, but its signature |
| 108 // cannot be determined. |
| 109 // |
| 110 // This event may be throttled to prevent it from firing too frequently; it |
| 111 // is designed to be event-page friendly. |
| 112 static void onNetworkIdChanged(DOMString networkId); |
90 }; | 113 }; |
91 }; | 114 }; |
OLD | NEW |