Chromium Code Reviews| 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) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 for (var key in DEFAULT_CLIENT_OPTIONS) { | 115 for (var key in DEFAULT_CLIENT_OPTIONS) { |
| 116 this.options_[key] = DEFAULT_CLIENT_OPTIONS[key]; | 116 this.options_[key] = DEFAULT_CLIENT_OPTIONS[key]; |
| 117 } | 117 } |
| 118 this.setClientOptions_(options); | 118 this.setClientOptions_(options); |
| 119 } | 119 } |
| 120 | 120 |
| 121 Connection.create = function(path, options) { | 121 Connection.create = function(path, options) { |
| 122 options = options || {}; | 122 options = options || {}; |
| 123 var serviceOptions = getServiceOptions(options); | 123 var serviceOptions = getServiceOptions(options); |
| 124 var pipe = core.createMessagePipe(); | 124 var pipe = core.createMessagePipe(); |
| 125 service.connect(path, serviceOptions, pipe.handle0); | 125 var sendPipe = core.createMessagePipe(); |
| 126 var receivePipe = core.createMessagePipe(); | |
| 127 service.connect(path, | |
| 128 serviceOptions, | |
| 129 pipe.handle0, | |
| 130 sendPipe.handle0, | |
| 131 receivePipe.handle0); | |
| 132 core.close(sendPipe.handle1); | |
|
raymes
2014/08/22 04:57:43
Make a note that you will be implementing this in
Sam McNally
2014/08/22 08:12:12
Done.
| |
| 133 core.close(receivePipe.handle1); | |
| 126 var router = new routerModule.Router(pipe.handle1); | 134 var router = new routerModule.Router(pipe.handle1); |
| 127 var connection = new serialMojom.ConnectionProxy(router); | 135 var connection = new serialMojom.ConnectionProxy(router); |
| 128 return connection.getInfo().then(convertServiceInfo).then( | 136 return connection.getInfo().then(convertServiceInfo).then( |
| 129 function(info) { | 137 function(info) { |
| 130 return Promise.all([info, allocateConnectionId()]); | 138 return Promise.all([info, allocateConnectionId()]); |
| 131 }).catch(function(e) { | 139 }).catch(function(e) { |
| 132 router.close(); | 140 router.close(); |
| 133 throw e; | 141 throw e; |
| 134 }).then(function(results) { | 142 }).then(function(results) { |
| 135 var info = results[0]; | 143 var info = results[0]; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 return Promise.resolve(nextConnectionId_++); | 273 return Promise.resolve(nextConnectionId_++); |
| 266 } | 274 } |
| 267 | 275 |
| 268 return { | 276 return { |
| 269 getDevices: getDevices, | 277 getDevices: getDevices, |
| 270 createConnection: Connection.create, | 278 createConnection: Connection.create, |
| 271 getConnection: getConnection, | 279 getConnection: getConnection, |
| 272 getConnections: getConnections, | 280 getConnections: getConnections, |
| 273 }; | 281 }; |
| 274 }); | 282 }); |
| OLD | NEW |