Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: chrome/browser/resources/bluetooth_internals/bluetooth_internals.js

Issue 2388533003: bluetooth: Add AdapterInfo in Bluetooth adapter service. (Closed)
Patch Set: Update mojom comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | device/bluetooth/adapter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 } 32 }
33 }; 33 };
34 34
35 (function() { 35 (function() {
36 var adapterFactory = null; 36 var adapterFactory = null;
37 var adapter = null; 37 var adapter = null;
38 var adapterClient = null; 38 var adapterClient = null;
39 39
40 /** 40 /**
41 * TODO: Move to shared location. See crbug.com/652361. 41 * TODO: Move to shared location. See crbug.com/652361.
42 * Logs basic information retrieved from the adapter.
43 */
44 function logAdapterInfo() {
45 console.log('Getting adapter info');
46
47 adapter.getInfo().then(function(response) { console.log(response.info); });
ortuno 2016/10/06 01:52:21 Q: Did you mean to return the promise here? Or is
mbrunson 2016/10/06 17:45:01 I didn't return it because I didn't care what orde
48 }
49
50 /**
42 * 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.
43 * @param {!Array<string>} moduleNames 52 * @param {!Array<string>} moduleNames
44 * @return {!Promise} 53 * @return {!Promise}
45 */ 54 */
46 function importModules(moduleNames) { 55 function importModules(moduleNames) {
47 return new Promise(function(resolve, reject) { 56 return new Promise(function(resolve, reject) {
48 define(moduleNames, function(var_args) { 57 define(moduleNames, function(var_args) {
49 resolve(Array.prototype.slice.call(arguments, 0)); 58 resolve(Array.prototype.slice.call(arguments, 0));
50 }); 59 });
51 }); 60 });
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Create a message pipe and bind one end to client 92 // Create a message pipe and bind one end to client
84 // implementation and the other to the Adapter service. 93 // implementation and the other to the Adapter service.
85 adapterClient = new AdapterClient(); 94 adapterClient = new AdapterClient();
86 adapter.setClient(connection.bindStubDerivedImpl(adapterClient)); 95 adapter.setClient(connection.bindStubDerivedImpl(adapterClient));
87 }); 96 });
88 }); 97 });
89 } 98 }
90 99
91 document.addEventListener('DOMContentLoaded', function() { 100 document.addEventListener('DOMContentLoaded', function() {
92 initializeProxies() 101 initializeProxies()
102 .then(function() { logAdapterInfo(); })
ortuno 2016/10/06 01:52:21 nit: Can you just do: .then(logAdapterInfo) ?
mbrunson 2016/10/06 17:45:01 Done.
93 .then(function() { return adapter.getDevices(); }) 103 .then(function() { return adapter.getDevices(); })
94 .then(function(response) { console.log(response.devices); }) 104 .then(function(response) { console.log(response.devices); })
95 .catch(function(error) { console.error(error); }); 105 .catch(function(error) { console.error(error); });
96 }); 106 });
97 })(); 107 })();
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698