| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // An API for discovery of devices that support DIAL. |
| 6 // Protocol specification: http://www.dial-multiscreen.org/ |
| 7 // |
| 8 // The API is backed by a service that multicasts discovery requests on the |
| 9 // local network to discover DIAL-capable devices and maintains a list of |
| 10 // devices that have responded. Adding an onDeviceList listener causes the |
| 11 // service to periodically issue discovery requests to maintain the device list. |
| 12 // (No polling is done when there are no onDeviceList listeners.) |
| 13 // |
| 14 // The onDeviceList event is fired when discovery respnses are received and in |
| 15 // other circumstances; see the documentation for onDeviceList. |
| 16 // |
| 17 // The client can request that network discovery can be done immediately by |
| 18 // invoking discoverNow() which is useful for presenting the user with an |
| 19 // updated list of devices. |
| 20 // |
| 21 // On-demand use (updates when discoverNow() is called): |
| 22 // chrome.dial.onDeviceList.addListener(function (list) { updateMenu(list); }); |
| 23 // chrome.dial.discoverNow(); |
| 24 // (Remember to remove the listener when the menu closes.) |
| 25 // |
| 26 // Background use (updates only when periodic polling happens): |
| 27 // var myList; |
| 28 // chrome.dial.onDeviceList.addListener(function (list) { myList = list; }); |
| 29 // |
| 30 // These can be combined to poll for devices to prime the device menu, then |
| 31 // refresh the menu when it is displayed. |
| 32 |
| 33 namespace dial { |
| 34 |
| 35 // Represents a unique device that responded to a DIAL discovery request. |
| 36 dictionary DialDevice { |
| 37 |
| 38 // A label identifying the device within this instance of the browser. |
| 39 // Not guaranteed to persist beyond browser instances. |
| 40 DOMString deviceLabel; |
| 41 |
| 42 // A URL pointing to the device description resource for the device. |
| 43 DOMString deviceDescriptionUrl; |
| 44 |
| 45 // The uPnP configuration ID reported by the device. Corresponds to the |
| 46 // CONFIGID.UPNP.ORG header in the M-SEARCH response. |
| 47 long? configId; |
| 48 }; |
| 49 |
| 50 callback BooleanCallback = void (boolean result); |
| 51 |
| 52 interface Functions { |
| 53 |
| 54 // Requests that DIAL discovery happen immediately. The request may not be |
| 55 // honored as discovery may already be happening in the background. The |
| 56 // callback is invoked with |true| if discovery was initiated or |false| |
| 57 // otherwise. |
| 58 static void discoverNow(BooleanCallback callback); |
| 59 }; |
| 60 |
| 61 interface Events { |
| 62 |
| 63 // Event fired to inform clients of the current, complete set of responsive |
| 64 // devices. Clients should only need to store the list from the most recent |
| 65 // event. May be fired in response to multiple circumstances: |
| 66 // |
| 67 // (1) The DIAL service refreshed its device list through periodic polling. |
| 68 // (2) A client invoked discoverNow(). |
| 69 // (3) An event happened that should invalidate the device list |
| 70 // (e.g., a network interface went offline), in which case it is fired |
| 71 // with an empty array. |
| 72 // |
| 73 // TODO(mfoltz): Rename to onDeviceListReady. |
| 74 static void onDeviceList(DialDevice[] result); |
| 75 }; |
| 76 }; |
| OLD | NEW |