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

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

Issue 551293004: Mojo JS validation unit test should check Connection et al (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed GN build Created 6 years, 3 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
« no previous file with comments | « mojo/mojo_public_tests.gypi ('k') | mojo/public/js/bindings/connector.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/router", 7 "mojo/public/js/bindings/router",
7 ], function(router) { 8 ], function(connector, router) {
8 9
9 function Connection(handle, localFactory, remoteFactory) { 10 function Connection(
10 this.router_ = new router.Router(handle); 11 handle, localFactory, remoteFactory, routerFactory, connectorFactory) {
12 if (routerFactory === undefined)
13 routerFactory = router.Router;
14 this.router_ = new routerFactory(handle, connectorFactory);
11 this.remote = new remoteFactory(this.router_); 15 this.remote = new remoteFactory(this.router_);
12 this.local = new localFactory(this.remote); 16 this.local = new localFactory(this.remote);
13 this.router_.setIncomingReceiver(this.local); 17 this.router_.setIncomingReceiver(this.local);
14 18
15 var validateRequest = localFactory.prototype.validator; 19 var validateRequest = localFactory.prototype.validator;
16 var validateResponse = remoteFactory.prototype.validator; 20 var validateResponse = remoteFactory.prototype.validator;
17 var payloadValidators = []; 21 var payloadValidators = [];
18 if (validateRequest) 22 if (validateRequest)
19 payloadValidators.push(validateRequest); 23 payloadValidators.push(validateRequest);
20 if (validateResponse) 24 if (validateResponse)
21 payloadValidators.push(validateResponse); 25 payloadValidators.push(validateResponse);
22 this.router_.setPayloadValidators(payloadValidators); 26 this.router_.setPayloadValidators(payloadValidators);
23 } 27 }
24 28
25 Connection.prototype.close = function() { 29 Connection.prototype.close = function() {
26 this.router_.close(); 30 this.router_.close();
27 this.router_ = null; 31 this.router_ = null;
28 this.local = null; 32 this.local = null;
29 this.remote = null; 33 this.remote = null;
30 }; 34 };
31 35
32 Connection.prototype.encounteredError = function() { 36 Connection.prototype.encounteredError = function() {
33 return this.router_.encounteredError(); 37 return this.router_.encounteredError();
34 }; 38 };
35 39
40 // The TestConnection subclass is only intended to be used in unit tests.
41
42 function TestConnection(handle, localFactory, remoteFactory) {
43 Connection.call(this,
44 handle,
45 localFactory,
46 remoteFactory,
47 router.TestRouter,
48 connector.TestConnector);
49 }
50
51 TestConnection.prototype = Object.create(Connection.prototype);
52
36 var exports = {}; 53 var exports = {};
37 exports.Connection = Connection; 54 exports.Connection = Connection;
55 exports.TestConnection = TestConnection;
38 return exports; 56 return exports;
39 }); 57 });
OLDNEW
« no previous file with comments | « mojo/mojo_public_tests.gypi ('k') | mojo/public/js/bindings/connector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698