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

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

Issue 511543005: Revert of mojo: generate Proxies and Stubs for java bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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: mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
index 8295c5eed3202d0a3efa2a81b6adbecdce7f280a..02b5c9f129e93e410046a17c60c9045f1a0dc15a 100644
--- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
@@ -4,7 +4,6 @@
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;
@@ -42,16 +41,10 @@
private final long mMaxMemory;
/**
- * The number of handles in the message.
- */
- private final long mNumberOfHandles;
-
- /**
* Constructor.
*/
- Validator(long maxMemory, int numberOfHandles) {
+ Validator(long maxMemory) {
mMaxMemory = maxMemory;
- mNumberOfHandles = numberOfHandles;
}
public void claimHandle(int handle) {
@@ -59,9 +52,6 @@
throw new DeserializationException(
"Trying to access handle out of order.");
}
- if (handle >= mNumberOfHandles) {
- throw new DeserializationException("Trying to access non present handle.");
- }
mMinNextClaimedHandle = handle + 1;
}
@@ -103,7 +93,7 @@
* @param message The message to decode.
*/
public Decoder(Message message) {
- this(message, new Validator(message.buffer.limit(), message.handles.size()), 0);
+ this(message, new Validator(message.buffer.limit()), 0);
}
private Decoder(Message message, Validator validator, int baseOffset) {
@@ -329,53 +319,44 @@
* Deserializes a |ConsumerHandle| at the given offset.
*/
public DataPipe.ConsumerHandle readConsumerHandle(int offset) {
- return readUntypedHandle(offset).toDataPipeConsumerHandle();
+ return readHandle(offset).toUntypedHandle().toDataPipeConsumerHandle();
}
/**
* Deserializes a |ProducerHandle| at the given offset.
*/
public DataPipe.ProducerHandle readProducerHandle(int offset) {
- return readUntypedHandle(offset).toDataPipeProducerHandle();
+ return readHandle(offset).toUntypedHandle().toDataPipeProducerHandle();
}
/**
* Deserializes a |MessagePipeHandle| at the given offset.
*/
public MessagePipeHandle readMessagePipeHandle(int offset) {
- return readUntypedHandle(offset).toMessagePipeHandle();
+ return readHandle(offset).toUntypedHandle().toMessagePipeHandle();
}
/**
* Deserializes a |SharedBufferHandle| at the given offset.
*/
public SharedBufferHandle readSharedBufferHandle(int offset) {
- return readUntypedHandle(offset).toSharedBufferHandle();
- }
-
- /**
- * Deserializes an interface at the given offset.
- *
- * @return a proxy to the service.
- */
- public <P extends Proxy> P readServiceInterface(int offset,
- Interface.Manager<?, P> manager) {
- MessagePipeHandle handle = readMessagePipeHandle(offset);
- if (!handle.isValid()) {
- return null;
- }
- return manager.attachProxy(handle);
+ return readHandle(offset).toUntypedHandle().toSharedBufferHandle();
+ }
+
+ /**
+ * Deserializes a |ServiceHandle| at the given offset.
+ */
+ public <S extends Interface> S readServiceInterface(int offset, Object builder) {
+ // TODO(qsr): To be implemented when interfaces proxy and stubs are implemented.
+ throw new UnsupportedOperationException("Unimplemented operation");
}
/**
* Deserializes a |InterfaceRequest| at the given offset.
*/
- public <I extends Interface> InterfaceRequest<I> readInterfaceRequest(int offset) {
- MessagePipeHandle handle = readMessagePipeHandle(offset);
- if (handle == null) {
- return null;
- }
- return new InterfaceRequest<I>(handle);
+ public <S extends Interface> InterfaceRequest<S> readInterfaceRequest(int offset) {
+ // TODO(qsr): To be implemented when interfaces proxy and stubs are implemented.
+ throw new UnsupportedOperationException("Unimplemented operation");
}
/**
@@ -407,23 +388,6 @@
}
/**
- * Deserializes an array of |UntypedHandle| at the given offset.
- */
- public UntypedHandle[] readUntypedHandles(int offset) {
- Decoder d = readPointer(offset);
- if (d == null) {
- return null;
- }
- DataHeader si = d.readDataHeader();
- UntypedHandle[] result = new UntypedHandle[si.numFields];
- for (int i = 0; i < result.length; ++i) {
- result[i] = d.readUntypedHandle(
- DataHeader.HEADER_SIZE + BindingsHelper.SERIALIZED_HANDLE_SIZE * i);
- }
- return result;
- }
-
- /**
* Deserializes an array of |ConsumerHandle| at the given offset.
*/
public DataPipe.ConsumerHandle[] readConsumerHandles(int offset) {
@@ -497,36 +461,22 @@
/**
* Deserializes an array of |ServiceHandle| at the given offset.
*/
- public <S extends Interface, P extends Proxy> S[] readServiceInterfaces(int offset,
- Interface.Manager<S, P> manager) {
- Decoder d = readPointer(offset);
- if (d == null) {
- return null;
- }
- DataHeader si = d.readDataHeader();
- S[] result = manager.buildArray(si.numFields);
- for (int i = 0; i < result.length; ++i) {
- // This cast is necessary because java 6 doesn't handle wildcard correctly when using
- // Manager<S, ? extends S>
- @SuppressWarnings("unchecked")
- S value = (S) d.readServiceInterface(
- DataHeader.HEADER_SIZE + BindingsHelper.SERIALIZED_HANDLE_SIZE * i, manager);
- result[i] = value;
- }
- return result;
+ public <S extends Interface> S[] readServiceInterfaces(int offset, Object builder) {
+ // TODO(qsr): To be implemented when interfaces proxy and stubs are implemented.
+ throw new UnsupportedOperationException("Unimplemented operation");
}
/**
* Deserializes an array of |InterfaceRequest| at the given offset.
*/
- public <I extends Interface> InterfaceRequest<I>[] readInterfaceRequests(int offset) {
+ public <S extends Interface> InterfaceRequest<S>[] readInterfaceRequests(int offset) {
Decoder d = readPointer(offset);
if (d == null) {
return null;
}
DataHeader si = d.readDataHeader();
@SuppressWarnings("unchecked")
- InterfaceRequest<I>[] result = new InterfaceRequest[si.numFields];
+ InterfaceRequest<S>[] result = new InterfaceRequest[si.numFields];
for (int i = 0; i < result.length; ++i) {
result[i] = d.readInterfaceRequest(
DataHeader.HEADER_SIZE + BindingsHelper.SERIALIZED_HANDLE_SIZE * i);

Powered by Google App Engine
This is Rietveld 408576698