OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 define('serial_service', [ | 5 define('serial_service', [ |
6 'content/public/renderer/service_provider', | 6 'content/public/renderer/service_provider', |
7 'device/serial/serial.mojom', | 7 'device/serial/serial.mojom', |
8 'mojo/public/js/bindings/core', | 8 'mojo/public/js/bindings/core', |
9 'mojo/public/js/bindings/router', | 9 'mojo/public/js/bindings/router', |
10 ], function(serviceProvider, serialMojom, core, routerModule) { | 10 ], function(serviceProvider, serialMojom, core, routerModule) { |
11 /** | 11 /** |
12 * A Javascript client for the serial service and connection Mojo services. | 12 * A Javascript client for the serial service and connection Mojo services. |
13 * | 13 * |
14 * This provides a thick client around the Mojo services, exposing a JS-style | 14 * This provides a thick client around the Mojo services, exposing a JS-style |
15 * interface to serial connections and information about serial devices. This | 15 * interface to serial connections and information about serial devices. This |
16 * converts parameters and result between the Apps serial API types and the | 16 * converts parameters and result between the Apps serial API types and the |
17 * Mojo types. | 17 * Mojo types. |
18 */ | 18 */ |
19 | 19 |
20 var service = new serialMojom.SerialServiceProxy(new routerModule.Router( | 20 var unloadEvent = require('unload_event'); |
21 serviceProvider.connectToService(serialMojom.SerialServiceProxy.NAME_))); | 21 var serviceRouter = new routerModule.Router( |
22 serviceProvider.connectToService(serialMojom.SerialServiceProxy.NAME_)); | |
23 var service = new serialMojom.SerialServiceProxy(serviceRouter); | |
24 unloadEvent.addListener(function() { | |
25 serviceRouter.close(); | |
26 }); | |
not at google - send to devlin
2014/08/27 19:28:58
Hm, why does the destruction of |serviceRouter| (v
Sam McNally
2014/08/28 07:06:51
It appears "kFullGarbageCollection" doesn't mean w
| |
22 | 27 |
23 function getDevices() { | 28 function getDevices() { |
24 return service.getDevices().then(function(response) { | 29 return service.getDevices().then(function(response) { |
25 return $Array.map(response.devices, function(device) { | 30 return $Array.map(response.devices, function(device) { |
26 var result = {path: device.path || ''}; | 31 var result = {path: device.path || ''}; |
27 if (device.has_vendor_id) | 32 if (device.has_vendor_id) |
28 result.vendorId = device.vendor_id; | 33 result.vendorId = device.vendor_id; |
29 if (device.has_product_id) | 34 if (device.has_product_id) |
30 result.productId = device.product_id; | 35 result.productId = device.product_id; |
31 if (device.display_name) | 36 if (device.display_name) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 return Promise.resolve(nextConnectionId_++); | 270 return Promise.resolve(nextConnectionId_++); |
266 } | 271 } |
267 | 272 |
268 return { | 273 return { |
269 getDevices: getDevices, | 274 getDevices: getDevices, |
270 createConnection: Connection.create, | 275 createConnection: Connection.create, |
271 getConnection: getConnection, | 276 getConnection: getConnection, |
272 getConnections: getConnections, | 277 getConnections: getConnections, |
273 }; | 278 }; |
274 }); | 279 }); |
OLD | NEW |