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

Unified Diff: mojo/bindings/java/src/org/chromium/mojo/bindings/Struct.java

Issue 371603003: Adding a router class to handle messages that expect responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix findbugs issue Created 6 years, 5 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/bindings/java/src/org/chromium/mojo/bindings/RouterImpl.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/bindings/java/src/org/chromium/mojo/bindings/Struct.java
diff --git a/mojo/bindings/java/src/org/chromium/mojo/bindings/Struct.java b/mojo/bindings/java/src/org/chromium/mojo/bindings/Struct.java
index f7c16a2decb0fa75c54e0684ed020a1b6bfa9163..dc1742a3491a87a1b6385abc2dd65084fa1ede3a 100644
--- a/mojo/bindings/java/src/org/chromium/mojo/bindings/Struct.java
+++ b/mojo/bindings/java/src/org/chromium/mojo/bindings/Struct.java
@@ -42,6 +42,35 @@ public abstract class Struct {
this.size = size;
this.numFields = numFields;
}
+
+ /**
+ * @see Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + numFields;
+ 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 (numFields == other.numFields &&
+ size == other.size);
+ }
}
/**
@@ -73,4 +102,18 @@ public abstract class Struct {
return encoder.getMessage();
}
+ /**
+ * Returns the serialization of the struct prepended with the given header.
+ *
+ * @param header the header to prepend to the returned message.
+ * @param core the |Core| implementation used to generate handles. Only used if the |Struct|
+ * being encoded contains interfaces, can be |null| otherwise.
+ */
+ public MessageWithHeader serializeWithHeader(Core core, MessageHeader header) {
+ Encoder encoder = new Encoder(core, mEncodedBaseSize + header.getSize());
+ header.encode(encoder);
+ encode(encoder);
+ return new MessageWithHeader(encoder.getMessage(), header);
+ }
+
}
« no previous file with comments | « mojo/bindings/java/src/org/chromium/mojo/bindings/RouterImpl.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698