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

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

Issue 488173006: Integrate Mojo JS validation bindings with the Router (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final changes 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 | « no previous file | mojo/public/js/bindings/router.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/router", 6 "mojo/public/js/bindings/router",
7 ], function(router) { 7 ], function(router) {
8 8
9 function Connection(handle, localFactory, remoteFactory) { 9 function Connection(handle, localFactory, remoteFactory) {
10 this.router_ = new router.Router(handle); 10 this.router_ = new router.Router(handle);
11 this.remote = new remoteFactory(this.router_); 11 this.remote = new remoteFactory(this.router_);
12 this.local = new localFactory(this.remote); 12 this.local = new localFactory(this.remote);
13 this.router_.setIncomingReceiver(this.local); 13 this.router_.setIncomingReceiver(this.local);
14
15 var validateRequest = localFactory.prototype.validator;
16 var validateResponse = remoteFactory.prototype.validator;
17 var payloadValidators = [];
18 if (validateRequest)
19 payloadValidators.push(validateRequest);
20 if (validateResponse)
21 payloadValidators.push(validateResponse);
22 this.router_.setPayloadValidators(payloadValidators);
14 } 23 }
15 24
16 Connection.prototype.close = function() { 25 Connection.prototype.close = function() {
17 this.router_.close(); 26 this.router_.close();
18 this.router_ = null; 27 this.router_ = null;
19 this.local = null; 28 this.local = null;
20 this.remote = null; 29 this.remote = null;
21 }; 30 };
22 31
23 Connection.prototype.encounteredError = function() { 32 Connection.prototype.encounteredError = function() {
24 return this.router_.encounteredError(); 33 return this.router_.encounteredError();
25 }; 34 };
26 35
27 var exports = {}; 36 var exports = {};
28 exports.Connection = Connection; 37 exports.Connection = Connection;
29 return exports; 38 return exports;
30 }); 39 });
OLDNEW
« no previous file with comments | « no previous file | mojo/public/js/bindings/router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698