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

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

Issue 2744963002: Introduce InterfaceEndpointClient(IEC), InterfaceEndpointHandle and (Closed)
Patch Set: Throw the error with the string being the stack trace needed to debug layouts which don't output an… Created 3 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
« no previous file with comments | « mojo/public/js/bindings.js ('k') | mojo/public/js/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/codec", [ 5 define("mojo/public/js/codec", [
6 "mojo/public/js/buffer", 6 "mojo/public/js/buffer",
7 "mojo/public/js/interface_types", 7 "mojo/public/js/interface_types",
8 "mojo/public/js/unicode", 8 "mojo/public/js/unicode",
9 ], function(buffer, types, unicode) { 9 ], function(buffer, types, unicode) {
10 10
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 }; 446 };
447 447
448 Message.prototype.getName = function() { 448 Message.prototype.getName = function() {
449 return this.buffer.getUint32(kMessageNameOffset); 449 return this.buffer.getUint32(kMessageNameOffset);
450 }; 450 };
451 451
452 Message.prototype.getFlags = function() { 452 Message.prototype.getFlags = function() {
453 return this.buffer.getUint32(kMessageFlagsOffset); 453 return this.buffer.getUint32(kMessageFlagsOffset);
454 }; 454 };
455 455
456 Message.prototype.getInterfaceId = function() {
457 return this.buffer.getUint32(kMessageInterfaceIdOffset);
458 };
459
456 Message.prototype.isResponse = function() { 460 Message.prototype.isResponse = function() {
457 return (this.getFlags() & kMessageIsResponse) != 0; 461 return (this.getFlags() & kMessageIsResponse) != 0;
458 }; 462 };
459 463
460 Message.prototype.expectsResponse = function() { 464 Message.prototype.expectsResponse = function() {
461 return (this.getFlags() & kMessageExpectsResponse) != 0; 465 return (this.getFlags() & kMessageExpectsResponse) != 0;
462 }; 466 };
463 467
464 Message.prototype.setRequestID = function(requestID) { 468 Message.prototype.setRequestID = function(requestID) {
465 // TODO(darin): Verify that space was reserved for this field! 469 // TODO(darin): Verify that space was reserved for this field!
466 this.buffer.setUint64(kMessageRequestIDOffset, requestID); 470 this.buffer.setUint64(kMessageRequestIDOffset, requestID);
467 }; 471 };
468 472
473 Message.prototype.setInterfaceId = function(interfaceId) {
474 this.buffer.setUint32(kMessageInterfaceIdOffset, interfaceId);
475 };
476
469 477
470 // MessageBuilder ----------------------------------------------------------- 478 // MessageBuilder -----------------------------------------------------------
471 479
472 function MessageBuilder(messageName, payloadSize) { 480 function MessageBuilder(messageName, payloadSize) {
473 // Currently, we don't compute the payload size correctly ahead of time. 481 // Currently, we don't compute the payload size correctly ahead of time.
474 // Instead, we resize the buffer at the end. 482 // Instead, we resize the buffer at the end.
475 var numberOfBytes = kMessageHeaderSize + payloadSize; 483 var numberOfBytes = kMessageHeaderSize + payloadSize;
476 this.buffer = new buffer.Buffer(numberOfBytes); 484 this.buffer = new buffer.Buffer(numberOfBytes);
477 this.handles = []; 485 this.handles = [];
478 var encoder = this.createEncoder(kMessageHeaderSize); 486 var encoder = this.createEncoder(kMessageHeaderSize);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 MessageWithRequestIDBuilder; 538 MessageWithRequestIDBuilder;
531 539
532 // MessageReader ------------------------------------------------------------ 540 // MessageReader ------------------------------------------------------------
533 541
534 function MessageReader(message) { 542 function MessageReader(message) {
535 this.decoder = new Decoder(message.buffer, message.handles, 0); 543 this.decoder = new Decoder(message.buffer, message.handles, 0);
536 var messageHeaderSize = this.decoder.readUint32(); 544 var messageHeaderSize = this.decoder.readUint32();
537 this.payloadSize = message.buffer.byteLength - messageHeaderSize; 545 this.payloadSize = message.buffer.byteLength - messageHeaderSize;
538 var version = this.decoder.readUint32(); 546 var version = this.decoder.readUint32();
539 var interface_id = this.decoder.readUint32(); 547 var interface_id = this.decoder.readUint32();
540 if (interface_id != 0) {
541 throw new Error("Receiving non-zero interface ID. Associated interfaces " +
542 "are not yet supported.");
543 }
544 this.messageName = this.decoder.readUint32(); 548 this.messageName = this.decoder.readUint32();
545 this.flags = this.decoder.readUint32(); 549 this.flags = this.decoder.readUint32();
546 // Skip the padding. 550 // Skip the padding.
547 this.decoder.skip(4); 551 this.decoder.skip(4);
548 if (version >= 1) 552 if (version >= 1)
549 this.requestID = this.decoder.readUint64(); 553 this.requestID = this.decoder.readUint64();
550 this.decoder.skip(messageHeaderSize - this.decoder.next); 554 this.decoder.skip(messageHeaderSize - this.decoder.next);
551 } 555 }
552 556
553 MessageReader.prototype.decodeStruct = function(cls) { 557 MessageReader.prototype.decodeStruct = function(cls) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 exports.Handle = Handle; 917 exports.Handle = Handle;
914 exports.NullableHandle = NullableHandle; 918 exports.NullableHandle = NullableHandle;
915 exports.Interface = Interface; 919 exports.Interface = Interface;
916 exports.NullableInterface = NullableInterface; 920 exports.NullableInterface = NullableInterface;
917 exports.InterfaceRequest = InterfaceRequest; 921 exports.InterfaceRequest = InterfaceRequest;
918 exports.NullableInterfaceRequest = NullableInterfaceRequest; 922 exports.NullableInterfaceRequest = NullableInterfaceRequest;
919 exports.MapOf = MapOf; 923 exports.MapOf = MapOf;
920 exports.NullableMapOf = NullableMapOf; 924 exports.NullableMapOf = NullableMapOf;
921 return exports; 925 return exports;
922 }); 926 });
OLDNEW
« no previous file with comments | « mojo/public/js/bindings.js ('k') | mojo/public/js/connector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698