Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * Javascript for bluetooth_internals.html, served from | 6 * Javascript for bluetooth_internals.html, served from |
| 7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 deviceRemoved: function(device) { | 29 deviceRemoved: function(device) { |
| 30 console.log('Device removed'); | 30 console.log('Device removed'); |
| 31 console.log(device); | 31 console.log(device); |
| 32 } | 32 } |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 (function() { | 35 (function() { |
| 36 var adapter, adapterClient; | 36 var adapter, adapterClient; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * TODO: Move to shared location. See crbug.com/652361. | 39 * Logs basic information retrieved from the adapter. |
| 40 */ | |
| 41 function logAdapterInfo() { | |
| 42 console.log('Getting adapter info'); | |
|
dcheng
2016/10/06 18:46:28
I'm not sure what our policy on logging code is in
mbrunson
2016/10/06 21:00:22
Eventually, this JS file will turn into a setup fi
| |
| 43 | |
| 44 return adapter.getInfo().then(function(response) { | |
| 45 console.log(response.info); | |
| 46 }); | |
| 47 } | |
| 48 | |
| 49 /** | |
| 50 * TODO: Move to shared location. See http://crbug.com/652361. | |
| 40 * Helper to convert callback-based define() API to a promise-based API. | 51 * Helper to convert callback-based define() API to a promise-based API. |
| 41 * @param {!Array<string>} moduleNames | 52 * @param {!Array<string>} moduleNames |
| 42 * @return {!Promise} | 53 * @return {!Promise} |
| 43 */ | 54 */ |
| 44 function importModules(moduleNames) { | 55 function importModules(moduleNames) { |
| 45 return new Promise(function(resolve, reject) { | 56 return new Promise(function(resolve, reject) { |
| 46 define(moduleNames, function(var_args) { | 57 define(moduleNames, function(var_args) { |
| 47 resolve(Array.prototype.slice.call(arguments, 0)); | 58 resolve(Array.prototype.slice.call(arguments, 0)); |
| 48 }); | 59 }); |
| 49 }); | 60 }); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 // Create a message pipe and bind one end to client | 93 // Create a message pipe and bind one end to client |
| 83 // implementation and the other to the Adapter service. | 94 // implementation and the other to the Adapter service. |
| 84 adapterClient = new AdapterClient(); | 95 adapterClient = new AdapterClient(); |
| 85 adapter.setClient(connection.bindStubDerivedImpl(adapterClient)); | 96 adapter.setClient(connection.bindStubDerivedImpl(adapterClient)); |
| 86 }); | 97 }); |
| 87 }); | 98 }); |
| 88 } | 99 } |
| 89 | 100 |
| 90 document.addEventListener('DOMContentLoaded', function() { | 101 document.addEventListener('DOMContentLoaded', function() { |
| 91 initializeProxies() | 102 initializeProxies() |
| 103 .then(logAdapterInfo) | |
|
dpapad
2016/10/06 22:25:21
Let's be consistent within this file. Either
init
mbrunson
2016/10/07 00:48:11
Alright. Thanks for the link. Latter looks better
| |
| 92 .then(function() { return adapter.getDevices(); }) | 104 .then(function() { return adapter.getDevices(); }) |
| 93 .then(function(response) { console.log(response.devices); }) | 105 .then(function(response) { console.log(response.devices); }) |
| 94 .catch(function(error) { console.error(error); }); | 106 .catch(function(error) { console.error(error); }); |
| 95 }); | 107 }); |
| 96 })(); | 108 })(); |
| OLD | NEW |