| 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/frame_service_registry', | 6 'content/public/renderer/frame_service_registry', |
| 7 'data_receiver', | 7 'data_receiver', |
| 8 'data_sender', | 8 'data_sender', |
| 9 'device/serial/serial.mojom', | 9 'device/serial/serial.mojom', |
| 10 'device/serial/serial_serialization.mojom', | 10 'device/serial/serial_serialization.mojom', |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if ($Object.keys(serviceOptions).length == 0) | 278 if ($Object.keys(serviceOptions).length == 0) |
| 279 return true; | 279 return true; |
| 280 return this.remoteConnection_.setOptions(serviceOptions).then( | 280 return this.remoteConnection_.setOptions(serviceOptions).then( |
| 281 function(result) { | 281 function(result) { |
| 282 return !!result.success; | 282 return !!result.success; |
| 283 }).catch(function() { | 283 }).catch(function() { |
| 284 return false; | 284 return false; |
| 285 }); | 285 }); |
| 286 }; | 286 }; |
| 287 | 287 |
| 288 var calls = 0; |
| 288 Connection.prototype.getControlSignals = function() { | 289 Connection.prototype.getControlSignals = function() { |
| 290 // Creating this on any earlier call causes the handles to be lost and not |
| 291 // cleaned up. |
| 292 if (calls++ == 7) { |
| 293 var pipe = core.createMessagePipe(); |
| 294 core.close(pipe.handle1); |
| 295 core.close(pipe.handle0); |
| 296 } |
| 289 return this.remoteConnection_.getControlSignals().then(function(result) { | 297 return this.remoteConnection_.getControlSignals().then(function(result) { |
| 290 if (!result.signals) | 298 if (!result.signals) |
| 291 throw new Error('Failed to get control signals.'); | 299 throw new Error('Failed to get control signals.'); |
| 292 var signals = result.signals; | 300 var signals = result.signals; |
| 293 return { | 301 return { |
| 294 dcd: !!signals.dcd, | 302 dcd: !!signals.dcd, |
| 295 cts: !!signals.cts, | 303 cts: !!signals.cts, |
| 296 ri: !!signals.ri, | 304 ri: !!signals.ri, |
| 297 dsr: !!signals.dsr, | 305 dsr: !!signals.dsr, |
| 298 }; | 306 }; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 553 |
| 546 return { | 554 return { |
| 547 getDevices: getDevices, | 555 getDevices: getDevices, |
| 548 createConnection: Connection.create, | 556 createConnection: Connection.create, |
| 549 getConnection: getConnection, | 557 getConnection: getConnection, |
| 550 getConnections: getConnections, | 558 getConnections: getConnections, |
| 551 // For testing. | 559 // For testing. |
| 552 Connection: Connection, | 560 Connection: Connection, |
| 553 }; | 561 }; |
| 554 }); | 562 }); |
| OLD | NEW |