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

Side by Side Diff: mojo/public/js/bindings/connection.js

Issue 628763002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed template indentation Created 6 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
OLDNEW
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("mojo/public/js/bindings/connection", [ 5 define("mojo/public/js/bindings/connection", [
6 "mojo/public/js/bindings/connector", 6 "mojo/public/js/bindings/connector",
7 "mojo/public/js/bindings/router", 7 "mojo/public/js/bindings/router",
8 ], function(connector, router) { 8 ], function(connector, router) {
9 9
10 function Connection( 10 function Connection(
11 handle, localFactory, remoteFactory, routerFactory, connectorFactory) { 11 handle, localFactory, remoteFactory, routerFactory, connectorFactory) {
12 if (routerFactory === undefined) 12 if (routerFactory === undefined)
13 routerFactory = router.Router; 13 routerFactory = router.Router;
14 this.router_ = new routerFactory(handle, connectorFactory); 14 this.router_ = new routerFactory(handle, connectorFactory);
15 this.remote = new remoteFactory(this.router_); 15 this.remote = new remoteFactory(this.router_);
16 this.local = new localFactory(this.remote); 16 this.local = new localFactory(this.remote);
17 this.router_.setIncomingReceiver(this.local); 17 this.router_.setIncomingReceiver(this.local);
18 18
19 // Validate incoming messages: remote responses and local requests.
19 var validateRequest = localFactory.prototype.validator; 20 var validateRequest = localFactory.prototype.validator;
20 var validateResponse = remoteFactory.prototype.validator; 21 var validateResponse = remoteFactory.prototype.validator;
21 var payloadValidators = []; 22 var payloadValidators = [];
22 if (validateRequest) 23 if (validateRequest)
23 payloadValidators.push(validateRequest); 24 payloadValidators.push(validateRequest);
24 if (validateResponse) 25 if (validateResponse)
25 payloadValidators.push(validateResponse); 26 payloadValidators.push(validateResponse);
26 this.router_.setPayloadValidators(payloadValidators); 27 this.router_.setPayloadValidators(payloadValidators);
27 } 28 }
28 29
(...skipping 19 matching lines...) Expand all
48 connector.TestConnector); 49 connector.TestConnector);
49 } 50 }
50 51
51 TestConnection.prototype = Object.create(Connection.prototype); 52 TestConnection.prototype = Object.create(Connection.prototype);
52 53
53 var exports = {}; 54 var exports = {};
54 exports.Connection = Connection; 55 exports.Connection = Connection;
55 exports.TestConnection = TestConnection; 56 exports.TestConnection = TestConnection;
56 return exports; 57 return exports;
57 }); 58 });
OLDNEW
« no previous file with comments | « mojo/public/interfaces/bindings/tests/test_structs.mojom ('k') | mojo/public/js/bindings/struct_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698