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

Unified Diff: mojo/public/js/codec.js

Issue 2796253002: Associated Message Validation (Closed)
Patch Set: Fix formatting and add missing check_err() 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/js/associated_bindings.js ('k') | mojo/public/js/constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/codec.js
diff --git a/mojo/public/js/codec.js b/mojo/public/js/codec.js
index ce58a8cfd4aea874d6b752d9f8efe47f28268037..a7e76d8a1a225de8b2452df65576444555a40949 100644
--- a/mojo/public/js/codec.js
+++ b/mojo/public/js/codec.js
@@ -5,13 +5,15 @@
define("mojo/public/js/codec", [
"mojo/public/js/buffer",
"mojo/public/js/interface_types",
+ "mojo/public/js/lib/interface_endpoint_handle",
"mojo/public/js/unicode",
-], function(buffer, types, unicode) {
+], function(buffer, types, interfaceEndpointHandle, unicode) {
var kErrorUnsigned = "Passing negative value to unsigned";
var kErrorArray = "Passing non Array for array type";
var kErrorString = "Passing non String for string type";
var kErrorMap = "Passing non Map for map type";
+ var InterfaceEndpointHandle = interfaceEndpointHandle.InterfaceEndpointHandle;
// Memory -------------------------------------------------------------------
@@ -31,6 +33,7 @@ define("mojo/public/js/codec", [
var kStructHeaderSize = 8;
var kMessageHeaderSize = 24;
var kMessageWithRequestIDHeaderSize = 32;
+ var kMessageV2HeaderSize = 48;
var kMapStructPayloadSize = 16;
var kStructHeaderNumBytesOffset = 0;
@@ -457,6 +460,18 @@ define("mojo/public/js/codec", [
return this.buffer.getUint32(kMessageInterfaceIdOffset);
};
+ Message.prototype.getPayloadInterfaceIds = function() {
+ if (this.getHeaderVersion() < 2) {
+ throw new Error(
+ "Version of message does not support payload interface ids.");
+ }
+
+ var decoder = new Decoder(this.buffer, this.handles,
+ kMessageV2HeaderSize-8);
Ken Rockot(use gerrit already) 2017/04/10 22:20:17 nit: Perhaps this should be its own "constant" lik
wangjimmy 2017/04/11 00:21:24 var messageV2PayloadInterfaceIdsPointer = kMessage
+ var payloadInterfaceIds = decoder.decodeArrayPointer(Uint32);
+ return payloadInterfaceIds;
+ };
+
Message.prototype.isResponse = function() {
return (this.getFlags() & kMessageIsResponse) != 0;
};
@@ -838,6 +853,37 @@ define("mojo/public/js/codec", [
NullableInterface.prototype = Object.create(Interface.prototype);
+ function AssociatedInterfacePtrInfo() {
+ }
+
+ AssociatedInterfacePtrInfo.prototype.encodedSize = 8;
+
+ AssociatedInterfacePtrInfo.decode = function(decoder) {
+ return new types.AssociatedInterfacePtrInfo(
+ new InterfaceEndpointHandle(decoder.decodeHandle()),
+ decoder.readUint32());
+ };
+
+ AssociatedInterfacePtrInfo.encode = function(encoder, val) {
+ var associatedinterfacePtrInfo =
+ val ? val : new types.AssociatedInterfacePtrInfo(null, 0);
+ encoder.encodeHandle(
+ associatedinterfacePtrInfo.interfaceEndpointHandle.id());
+ encoder.writeUint32(associatedinterfacePtrInfo.version);
+ };
+
+ function NullableAssociatedInterfacePtrInfo() {
+ }
+
+ NullableAssociatedInterfacePtrInfo.encodedSize =
+ AssociatedInterfacePtrInfo.encodedSize;
+
+ NullableAssociatedInterfacePtrInfo.decode =
+ AssociatedInterfacePtrInfo.decode;
+
+ NullableAssociatedInterfacePtrInfo.encode =
+ AssociatedInterfacePtrInfo.encode;
+
function InterfaceRequest() {
}
@@ -860,6 +906,32 @@ define("mojo/public/js/codec", [
NullableInterfaceRequest.encode = InterfaceRequest.encode;
+ function AssociatedInterfaceRequest() {
+ }
+
+ AssociatedInterfaceRequest.encodedSize = 4;
+
+ AssociatedInterfaceRequest.decode = function(decoder) {
+ return new types.AssociatedInterfaceRequest(new InterfaceEndpointHandle(
+ decoder.decodeHandle()));
+ };
+
+ AssociatedInterfaceRequest.encode = function(encoder, val) {
+ encoder.encodeHandle(val ? val.interfaceEndpointHandle.id() : null);
+ };
+
+ function NullableAssociatedInterfaceRequest() {
+ }
+
+ NullableAssociatedInterfaceRequest.encodedSize =
+ AssociatedInterfaceRequest.encodedSize;
+
+ NullableAssociatedInterfaceRequest.decode =
+ AssociatedInterfaceRequest.decode;
+
+ NullableAssociatedInterfaceRequest.encode =
+ AssociatedInterfaceRequest.encode;
+
function MapOf(keyClass, valueClass) {
this.keyClass = keyClass;
this.valueClass = valueClass;
@@ -894,6 +966,7 @@ define("mojo/public/js/codec", [
exports.kEncodedInvalidHandleValue = kEncodedInvalidHandleValue;
exports.kMessageHeaderSize = kMessageHeaderSize;
exports.kMessageWithRequestIDHeaderSize = kMessageWithRequestIDHeaderSize;
+ exports.kMessageV2HeaderSize = kMessageV2HeaderSize;
exports.kMessageExpectsResponse = kMessageExpectsResponse;
exports.kMessageIsResponse = kMessageIsResponse;
exports.Int8 = Int8;
@@ -920,6 +993,12 @@ define("mojo/public/js/codec", [
exports.NullableInterface = NullableInterface;
exports.InterfaceRequest = InterfaceRequest;
exports.NullableInterfaceRequest = NullableInterfaceRequest;
+ exports.AssociatedInterfacePtrInfo = AssociatedInterfacePtrInfo;
+ exports.NullableAssociatedInterfacePtrInfo =
+ NullableAssociatedInterfacePtrInfo;
+ exports.AssociatedInterfaceRequest = AssociatedInterfaceRequest;
+ exports.NullableAssociatedInterfaceRequest =
+ NullableAssociatedInterfaceRequest;
exports.MapOf = MapOf;
exports.NullableMapOf = NullableMapOf;
return exports;
« no previous file with comments | « mojo/public/js/associated_bindings.js ('k') | mojo/public/js/constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698