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

Unified Diff: third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.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/Struct.java
diff --git a/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java b/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
index 85cc97cbf6ebf047960f5494d4bbd5f116aac2ee..16ae80198dbc8b17459e41a8ae92e9326b575a0a 100644
--- a/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
+++ b/third_party/mojo/src/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
@@ -10,10 +10,79 @@ import org.chromium.mojo.system.Core;
* Base class for all mojo structs.
*/
public abstract class Struct {
+
/**
- * The base size of the encoded struct.
+ * The header for a mojo complex element.
*/
- private final int mEncodedBaseSize;
+ public static final class DataHeader {
+ /**
+ * The size of a serialized header, in bytes.
+ */
+ public static final int HEADER_SIZE = 8;
+
+ /**
+ * The offset of the size field.
+ */
+ public static final int SIZE_OFFSET = 0;
+
+ /**
+ * The offset of the number of fields field.
+ */
+ public static final int ELEMENTS_OR_VERSION_OFFSET = 4;
+
+ /**
+ * The size of the object owning this header.
+ */
+ public final int size;
+
+ /**
+ * Number of element (for an array) or version (for a struct) of the object owning this
+ * header.
+ */
+ public final int elementsOrVersion;
+
+ /**
+ * Constructor.
+ */
+ public DataHeader(int size, int elementsOrVersion) {
+ super();
+ this.size = size;
+ this.elementsOrVersion = elementsOrVersion;
+ }
+
+ /**
+ * @see Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + elementsOrVersion;
+ result = prime * result + size;
+ return result;
+ }
+
+ /**
+ * @see Object#equals(Object)
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (object == this)
+ return true;
+ if (object == null)
+ return false;
+ if (getClass() != object.getClass())
+ return false;
+
+ DataHeader other = (DataHeader) object;
+ return (elementsOrVersion == other.elementsOrVersion && size == other.size);
+ }
+ }
+
+ /**
+ * The base size of the struct.
+ */
+ protected final int mEncodedBaseSize;
/**
* The version of the struct.
@@ -39,8 +108,8 @@ public abstract class Struct {
/**
* Returns the serialization of the struct. This method can close Handles.
*
- * @param core the |Core| implementation used to generate handles. Only used if the data
- * structure being encoded contains interfaces, can be |null| otherwise.
+ * @param core the |Core| implementation used to generate handles. Only used if the |Struct|
+ * being encoded contains interfaces, can be |null| otherwise.
*/
public Message serialize(Core core) {
Encoder encoder = new Encoder(core, mEncodedBaseSize);
@@ -63,7 +132,7 @@ public abstract class Struct {
}
/**
- * Use the given encoder to serialize this data structure.
+ * Use the given encoder to serialize this struct.
*/
protected abstract void encode(Encoder encoder);
}

Powered by Google App Engine
This is Rietveld 408576698