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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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/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
deleted file mode 100644
index 017d0ef595597509a4e943e27b7097ce04f02cb5..0000000000000000000000000000000000000000
--- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Struct.java
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.mojo.bindings;
-
-import org.chromium.mojo.system.Core;
-
-/**
- * Base class for all mojo structs.
- */
-public abstract class Struct {
-
- /**
- * The header for a mojo complex element.
- */
- 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 NUM_FIELDS_OFFSET = 4;
-
- public final int size;
- public final int numFields;
-
- /**
- * Constructor.
- */
- public DataHeader(int size, int numFields) {
- super();
- 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);
- }
- }
-
- /**
- * The base size of the struct.
- */
- protected final int mEncodedBaseSize;
-
- /**
- * Constructor.
- */
- protected Struct(int encodedBaseSize) {
- this.mEncodedBaseSize = encodedBaseSize;
- }
-
- /**
- * Use the given encoder to serialized this struct.
- */
- protected abstract void encode(Encoder encoder);
-
- /**
- * Returns the serialization of the struct. This method can close Handles.
- *
- * @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);
- encode(encoder);
- 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 ServiceMessage serializeWithHeader(Core core, MessageHeader header) {
- Encoder encoder = new Encoder(core, mEncodedBaseSize + header.getSize());
- header.encode(encoder);
- encode(encoder);
- return new ServiceMessage(encoder.getMessage(), header);
- }
-
-}

Powered by Google App Engine
This is Rietveld 408576698