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

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

Issue 250713003: Test sending corrupt mojo messages back from javascript. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Uint32 => Uint8 for consistency. Created 6 years, 8 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 ], function(codec, connector) { 8 ], function(codec, connector) {
9 9
10 function Router(handle) { 10 function Router(handle) {
11 this.connector_ = new connector.Connector(handle); 11 this.connector_ = new connector.Connector(handle);
12 this.incomingReceiver_ = null; 12 this.incomingReceiver_ = null;
13 this.nextRequestID_ = 0; 13 this.nextRequestID_ = 0;
14 this.responders_ = {}; 14 this.responders_ = {};
15 15
16 this.connector_.setIncomingReceiver({ 16 this.connector_.setIncomingReceiver({
17 accept: this.handleIncomingMessage_.bind(this), 17 accept: this.handleIncomingMessage_.bind(this),
18 }); 18 });
19 this.connector_.setErrorHandler({ 19 this.connector_.setErrorHandler({
20 onError: this.handleConnectionError_.bind(this), 20 onError: this.handleConnectionError_.bind(this),
21 }); 21 });
22 } 22 }
23 23
24 Router.prototype.close = function() { 24 Router.prototype.close = function() {
25 this.responders_ = {}; // Drop any responders. 25 this.responders_ = {}; // Drop any responders.
26 this.connector_.close(); 26 this.connector_.close();
27 }; 27 };
28 28
29 Router.prototype.setFuzzer = function(fuzzer) {
30 this.connector_.setFuzzer(fuzzer);
31 }
32
29 Router.prototype.accept = function(message) { 33 Router.prototype.accept = function(message) {
30 this.connector_.accept(message); 34 this.connector_.accept(message);
31 }; 35 };
32 36
33 Router.prototype.reject = function(message) { 37 Router.prototype.reject = function(message) {
34 // TODO(mpcomplete): no way to trasmit errors over a Connection. 38 // TODO(mpcomplete): no way to trasmit errors over a Connection.
35 }; 39 };
36 40
37 Router.prototype.acceptWithResponder = function(message, responder) { 41 Router.prototype.acceptWithResponder = function(message, responder) {
38 // Reserve 0 in case we want it to convey special meaning in the future. 42 // Reserve 0 in case we want it to convey special meaning in the future.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 Router.prototype.handleConnectionError_ = function(result) { 88 Router.prototype.handleConnectionError_ = function(result) {
85 for (var each in this.responders_) 89 for (var each in this.responders_)
86 this.responders_[each].reject(result); 90 this.responders_[each].reject(result);
87 this.close(); 91 this.close();
88 }; 92 };
89 93
90 var exports = {}; 94 var exports = {};
91 exports.Router = Router; 95 exports.Router = Router;
92 return exports; 96 return exports;
93 }); 97 });
OLDNEW
« mojo/public/js/bindings/connection.js ('K') | « mojo/public/js/bindings/connector.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698