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

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

Issue 2556353004: Mojo JS bindings: code generator maps interface ptr and request to InterfacePtr and InterfaceReques… (Closed)
Patch Set: . Created 4 years 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
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 AdapterBroker, served from 6 * Javascript for AdapterBroker, served from
7 * chrome://bluetooth-internals/. 7 * chrome://bluetooth-internals/.
8 */ 8 */
9 cr.define('adapter_broker', function() { 9 cr.define('adapter_broker', function() {
10 /** 10 /**
(...skipping 28 matching lines...) Expand all
39 // messages. 39 // messages.
40 var ConnectResult = interfaces.BluetoothAdapter.ConnectResult; 40 var ConnectResult = interfaces.BluetoothAdapter.ConnectResult;
41 var errorString = Object.keys(ConnectResult).find(function(key) { 41 var errorString = Object.keys(ConnectResult).find(function(key) {
42 return ConnectResult[key] === response.result; 42 return ConnectResult[key] === response.result;
43 }); 43 });
44 44
45 throw new Error(errorString); 45 throw new Error(errorString);
46 } 46 }
47 47
48 return interfaces.Connection.bindHandleToProxy( 48 return interfaces.Connection.bindHandleToProxy(
49 response.device, 49 response.device.ptr.passInterface().handle,
50 interfaces.BluetoothDevice.Device); 50 interfaces.BluetoothDevice.Device);
51 }); 51 });
52 }, 52 },
53 53
54 /** 54 /**
55 * Sets client of Adapter service. 55 * Sets client of Adapter service.
56 * @param {!interfaces.BluetoothAdapter.AdapterClient} adapterClient 56 * @param {!interfaces.BluetoothAdapter.AdapterClient} adapterClient
57 */ 57 */
58 setClient: function(adapterClient) { 58 setClient: function(adapterClient) {
59 this.adapter_.setClient(interfaces.Connection.bindStubDerivedImpl( 59 adapterClient.binding = new interfaces.Bindings.Binding(
60 adapterClient)); 60 interfaces.BluetoothAdapter.AdapterClient,
61 adapterClient);
62
63 this.adapter_.setClient(
64 adapterClient.binding.createInterfacePtrAndBind());
61 }, 65 },
62 66
63 /** 67 /**
64 * Gets an array of currently detectable devices from the Adapter service. 68 * Gets an array of currently detectable devices from the Adapter service.
65 * @return {!Array<!interfaces.BluetoothDevice.DeviceInfo>} 69 * @return {!Array<!interfaces.BluetoothDevice.DeviceInfo>}
66 */ 70 */
67 getDevices: function() { 71 getDevices: function() {
68 return this.adapter_.getDevices(); 72 return this.adapter_.getDevices();
69 }, 73 },
70 74
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 interfaces.BluetoothAdapter.AdapterClient.stubClass.prototype; 150 interfaces.BluetoothAdapter.AdapterClient.stubClass.prototype;
147 151
148 var adapterFactory = interfaces.Connection.bindHandleToProxy( 152 var adapterFactory = interfaces.Connection.bindHandleToProxy(
149 interfaces.FrameInterfaces.getInterface( 153 interfaces.FrameInterfaces.getInterface(
150 interfaces.BluetoothAdapter.AdapterFactory.name), 154 interfaces.BluetoothAdapter.AdapterFactory.name),
151 interfaces.BluetoothAdapter.AdapterFactory); 155 interfaces.BluetoothAdapter.AdapterFactory);
152 156
153 // Get an Adapter service. 157 // Get an Adapter service.
154 return adapterFactory.getAdapter(); 158 return adapterFactory.getAdapter();
155 }).then(function(response) { 159 }).then(function(response) {
156 if (!response.adapter) { 160 if (!response.adapter.ptr.isBound()) {
157 throw new Error('Bluetooth Not Supported on this platform.'); 161 throw new Error('Bluetooth Not Supported on this platform.');
158 } 162 }
159 163
160 var adapter = interfaces.Connection.bindHandleToProxy( 164 var adapter = interfaces.Connection.bindHandleToProxy(
161 response.adapter, 165 response.adapter.ptr.passInterface().handle,
162 interfaces.BluetoothAdapter.Adapter); 166 interfaces.BluetoothAdapter.Adapter);
163 167
164 adapterBroker = new AdapterBroker(adapter); 168 adapterBroker = new AdapterBroker(adapter);
165 return adapterBroker; 169 return adapterBroker;
166 }); 170 });
167 } 171 }
168 172
169 return { 173 return {
170 getAdapterBroker: getAdapterBroker, 174 getAdapterBroker: getAdapterBroker,
171 }; 175 };
172 }); 176 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698