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

Unified Diff: third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java

Issue 1157573002: Revert "Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
Index: third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
diff --git a/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java b/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
index 868eab6e9be5dec8618bb96357815692aae01f7d..81cbc9871e756207cc046272f375ce74183c2d7d 100644
--- a/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
+++ b/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
@@ -5,6 +5,7 @@
package org.chromium.mojo.bindings;
import org.chromium.mojo.bindings.Interface.Proxy;
+import org.chromium.mojo.bindings.Struct.DataHeader;
import org.chromium.mojo.system.DataPipe;
import org.chromium.mojo.system.Handle;
import org.chromium.mojo.system.InvalidHandle;
@@ -113,60 +114,26 @@ public class Decoder {
}
/**
- * Deserializes a {@link DataHeader} at the current position.
+ * Deserializes a {@link DataHeader} at the given offset.
*/
public DataHeader readDataHeader() {
// Claim the memory for the header.
mValidator.claimMemory(mBaseOffset, mBaseOffset + DataHeader.HEADER_SIZE);
- DataHeader result = readDataHeaderAtOffset(0, false);
- // Claim the rest of the memory.
- mValidator.claimMemory(mBaseOffset + DataHeader.HEADER_SIZE, mBaseOffset + result.size);
- return result;
- }
-
- /**
- * Deserializes a {@link DataHeader} for an union at the given offset.
- */
- public DataHeader readDataHeaderForUnion(int offset) {
- DataHeader result = readDataHeaderAtOffset(offset, true);
- if (result.size == 0) {
- if (result.elementsOrVersion != 0) {
- throw new DeserializationException(
- "Unexpected version tag for a null union. Expecting 0, found: "
- + result.elementsOrVersion);
- }
- } else if (result.size != BindingsHelper.UNION_SIZE) {
- throw new DeserializationException(
- "Unexpected size of an union. The size must be 0 for a null union, or 16 for "
- + "a non-null union.");
- }
- return result;
- }
-
- /**
- * @returns a decoder suitable to decode an union defined as the root object of a message.
- */
- public Decoder decoderForSerializedUnion() {
- mValidator.claimMemory(0, BindingsHelper.UNION_SIZE);
- return this;
- }
-
- /**
- * Deserializes a {@link DataHeader} at the given offset.
- */
- private DataHeader readDataHeaderAtOffset(int offset, boolean isUnion) {
- int size = readInt(offset + DataHeader.SIZE_OFFSET);
- int elementsOrVersion = readInt(offset + DataHeader.ELEMENTS_OR_VERSION_OFFSET);
+ int size = readInt(DataHeader.SIZE_OFFSET);
+ int elementsOrVersion = readInt(DataHeader.ELEMENTS_OR_VERSION_OFFSET);
if (size < 0) {
throw new DeserializationException(
"Negative size. Unsigned integers are not valid for java.");
}
- if (elementsOrVersion < 0 && (!isUnion || elementsOrVersion != -1)) {
+ if (elementsOrVersion < 0) {
throw new DeserializationException(
"Negative elements or version. Unsigned integers are not valid for java.");
}
- return new DataHeader(size, elementsOrVersion);
+ // Claim the remaining memory.
+ mValidator.claimMemory(mBaseOffset + DataHeader.HEADER_SIZE, mBaseOffset + size);
+ DataHeader res = new DataHeader(size, elementsOrVersion);
+ return res;
}
public DataHeader readAndValidateDataHeader(DataHeader[] versionArray) {
@@ -196,18 +163,10 @@ public class Decoder {
/**
* Deserializes a {@link DataHeader} at the given offset and checks if it is correct for an
- * array where elements are pointers.
+ * array where element have the given size.
*/
public DataHeader readDataHeaderForPointerArray(int expectedLength) {
- return readDataHeaderForArray(BindingsHelper.POINTER_SIZE, expectedLength);
- }
-
- /**
- * Deserializes a {@link DataHeader} at the given offset and checks if it is correct for an
- * array where elements are unions.
- */
- public DataHeader readDataHeaderForUnionArray(int expectedLength) {
- return readDataHeaderForArray(BindingsHelper.UNION_SIZE, expectedLength);
+ return readDataHeaderForArray(8, expectedLength);
}
/**

Powered by Google App Engine
This is Rietveld 408576698