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

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

Issue 2405093003: [WIP] Mojo native bindings interface.
Patch Set: cleanup 2 Created 4 years, 1 month 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/router", [ 5 define("mojo/public/js/router", [
6 "mojo/public/js/codec", 6 "mojo/public/js/codec",
7 "mojo/public/js/core",
8 "mojo/public/js/connector", 7 "mojo/public/js/connector",
9 "mojo/public/js/validator", 8 "mojo/public/js/validator",
10 ], function(codec, core, connector, validator) { 9 ], function(codec, connector, validator) {
11 10
12 var Connector = connector.Connector; 11 var Connector = connector.Connector;
13 var MessageReader = codec.MessageReader; 12 var MessageReader = codec.MessageReader;
14 var Validator = validator.Validator; 13 var Validator = validator.Validator;
15 14
16 function Router(handle, connectorFactory) { 15 function Router(handle, connectorFactory) {
17 if (!core.isHandle(handle)) 16 if (!(handle instanceof MojoHandle))
18 throw new Error("Router constructor: Not a handle"); 17 throw new Error("Router constructor: Not a handle");
18
19 if (connectorFactory === undefined) 19 if (connectorFactory === undefined)
20 connectorFactory = Connector; 20 connectorFactory = Connector;
21 this.connector_ = new connectorFactory(handle); 21 this.connector_ = new connectorFactory(handle);
22 this.incomingReceiver_ = null; 22 this.incomingReceiver_ = null;
23 this.errorHandler_ = null; 23 this.errorHandler_ = null;
24 this.nextRequestID_ = 0; 24 this.nextRequestID_ = 0;
25 this.completers_ = new Map(); 25 this.completers_ = new Map();
26 this.payloadValidators_ = []; 26 this.payloadValidators_ = [];
27 27
28 this.connector_.setIncomingReceiver({ 28 this.connector_.setIncomingReceiver({
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 TestRouter.prototype.handleInvalidIncomingMessage_ = 143 TestRouter.prototype.handleInvalidIncomingMessage_ =
144 function(message, error) { 144 function(message, error) {
145 this.validationErrorHandler(error); 145 this.validationErrorHandler(error);
146 }; 146 };
147 147
148 var exports = {}; 148 var exports = {};
149 exports.Router = Router; 149 exports.Router = Router;
150 exports.TestRouter = TestRouter; 150 exports.TestRouter = TestRouter;
151 return exports; 151 return exports;
152 }); 152 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698