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

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

Issue 468713002: JavaScript bindings for Mojo message validation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Binding generator simplification for Arrays Created 6 years, 4 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 | Annotate | Revision Log
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/router", [ 5 define("mojo/public/js/bindings/router", [
6 "mojo/public/js/bindings/codec", 6 "mojo/public/js/bindings/codec",
7 "mojo/public/js/bindings/connector", 7 "mojo/public/js/bindings/connector",
8 "mojo/public/js/bindings/validator", 8 "mojo/public/js/bindings/validator",
9 ], function(codec, connector, validator) { 9 ], function(codec, connector, validator) {
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Router.prototype.setIncomingReceiver = function(receiver) { 55 Router.prototype.setIncomingReceiver = function(receiver) {
56 this.incomingReceiver_ = receiver; 56 this.incomingReceiver_ = receiver;
57 }; 57 };
58 58
59 Router.prototype.encounteredError = function() { 59 Router.prototype.encounteredError = function() {
60 return this.connector_.encounteredError(); 60 return this.connector_.encounteredError();
61 }; 61 };
62 62
63 Router.prototype.handleIncomingMessage_ = function(message) { 63 Router.prototype.handleIncomingMessage_ = function(message) {
64 var v = new validator.Validator(message); 64 var v = new validator.Validator(message);
65 if (v.validateMessage() !== validator.validationError.NONE) 65 if (v.validateMessageHeader() !== validator.validationError.NONE)
66 this.close(); 66 this.close();
67 67
68 if (message.expectsResponse()) { 68 if (message.expectsResponse()) {
69 if (this.incomingReceiver_) { 69 if (this.incomingReceiver_) {
70 this.incomingReceiver_.acceptWithResponder(message, this); 70 this.incomingReceiver_.acceptWithResponder(message, this);
71 } else { 71 } else {
72 // If we receive a request expecting a response when the client is not 72 // If we receive a request expecting a response when the client is not
73 // listening, then we have no choice but to tear down the pipe. 73 // listening, then we have no choice but to tear down the pipe.
74 this.close(); 74 this.close();
75 } 75 }
(...skipping 12 matching lines...) Expand all
88 Router.prototype.handleConnectionError_ = function(result) { 88 Router.prototype.handleConnectionError_ = function(result) {
89 for (var each in this.responders_) 89 for (var each in this.responders_)
90 this.responders_[each].reject(result); 90 this.responders_[each].reject(result);
91 this.close(); 91 this.close();
92 }; 92 };
93 93
94 var exports = {}; 94 var exports = {};
95 exports.Router = Router; 95 exports.Router = Router;
96 return exports; 96 return exports;
97 }); 97 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698