| Index: mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
|
| diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
|
| index 85cc97cbf6ebf047960f5494d4bbd5f116aac2ee..14f4e1e7261cd32657b023af5bbee52dfadff690 100644
|
| --- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
|
| +++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
|
| @@ -6,6 +6,8 @@ package org.chromium.mojo.bindings;
|
|
|
| import org.chromium.mojo.system.Core;
|
|
|
| +import java.nio.ByteBuffer;
|
| +
|
| /**
|
| * Base class for all mojo structs.
|
| */
|
| @@ -49,6 +51,23 @@ public abstract class Struct {
|
| }
|
|
|
| /**
|
| + * Similar to the method above, but returns the serialization result as |ByteBuffer|.
|
| + *
|
| + * @throws UnsupportedOperationException if the struct contains interfaces or handles.
|
| + * @throws SerializationException on serialization failure.
|
| + */
|
| + public ByteBuffer serialize() {
|
| + // If the struct contains interfaces which require a non-null |Core| instance, it will throw
|
| + // UnsupportedOperationException.
|
| + Message message = serialize(null);
|
| +
|
| + if (!message.getHandles().isEmpty())
|
| + throw new UnsupportedOperationException("Handles are discarded.");
|
| +
|
| + return message.getData();
|
| + }
|
| +
|
| + /**
|
| * Returns the serialization of the struct prepended with the given header.
|
| *
|
| * @param header the header to prepend to the returned message.
|
|
|