OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.mojo.system; |
| 6 |
| 7 import java.nio.ByteBuffer; |
| 8 |
| 9 /** |
| 10 * A buffer that can be shared between applications. |
| 11 */ |
| 12 public interface SharedBufferHandle extends Handle { |
| 13 |
| 14 /** |
| 15 * Flags for the shared buffer creation operation. |
| 16 */ |
| 17 public static class CreateFlags extends Flags<CreateFlags> { |
| 18 private static final int FLAG_NONE = 0; |
| 19 |
| 20 /** |
| 21 * Dedicated constructor. |
| 22 * |
| 23 * @param flags initial value of the flags. |
| 24 */ |
| 25 protected CreateFlags(int flags) { |
| 26 super(flags); |
| 27 } |
| 28 |
| 29 /** |
| 30 * @return flags with no bit set. |
| 31 */ |
| 32 public static CreateFlags none() { |
| 33 return new CreateFlags(FLAG_NONE); |
| 34 } |
| 35 |
| 36 } |
| 37 |
| 38 /** |
| 39 * Used to specify creation parameters for a shared buffer to |Core#createSh
aredBuffer()|. |
| 40 */ |
| 41 public static class CreateOptions { |
| 42 private CreateFlags mFlags = CreateFlags.none(); |
| 43 |
| 44 /** |
| 45 * @return the flags |
| 46 */ |
| 47 public CreateFlags getFlags() { |
| 48 return mFlags; |
| 49 } |
| 50 |
| 51 } |
| 52 |
| 53 /** |
| 54 * Flags for the shared buffer duplication operation. |
| 55 */ |
| 56 public static class DuplicateFlags extends Flags<DuplicateFlags> { |
| 57 private static final int FLAG_NONE = 0; |
| 58 |
| 59 /** |
| 60 * Dedicated constructor. |
| 61 * |
| 62 * @param flags initial value of the flags. |
| 63 */ |
| 64 protected DuplicateFlags(int flags) { |
| 65 super(flags); |
| 66 } |
| 67 |
| 68 /** |
| 69 * @return flags with no bit set. |
| 70 */ |
| 71 public static DuplicateFlags none() { |
| 72 return new DuplicateFlags(FLAG_NONE); |
| 73 } |
| 74 |
| 75 } |
| 76 |
| 77 /** |
| 78 * Used to specify parameters in duplicating access to a shared buffer to |
| 79 * |SharedBufferHandle#duplicate| |
| 80 */ |
| 81 public static class DuplicateOptions { |
| 82 private DuplicateFlags mFlags = DuplicateFlags.none(); |
| 83 |
| 84 /** |
| 85 * @return the flags |
| 86 */ |
| 87 public DuplicateFlags getFlags() { |
| 88 return mFlags; |
| 89 } |
| 90 |
| 91 } |
| 92 |
| 93 /** |
| 94 * TODO(qsr): Insert description here. |
| 95 */ |
| 96 public static class MapFlags extends Flags<MapFlags> { |
| 97 private static final int FLAG_NONE = 0; |
| 98 |
| 99 /** |
| 100 * Dedicated constructor. |
| 101 * |
| 102 * @param flags initial value of the flags. |
| 103 */ |
| 104 protected MapFlags(int flags) { |
| 105 super(flags); |
| 106 } |
| 107 |
| 108 /** |
| 109 * @return flags with no bit set. |
| 110 */ |
| 111 public static MapFlags none() { |
| 112 return new MapFlags(FLAG_NONE); |
| 113 } |
| 114 |
| 115 } |
| 116 |
| 117 /** |
| 118 * Duplicates the handle. This creates another handle (returned on success),
which can then be |
| 119 * sent to another application over a message pipe, while retaining access t
o this handle (and |
| 120 * any mappings that it may have). |
| 121 */ |
| 122 public SharedBufferHandle duplicate(DuplicateOptions options); |
| 123 |
| 124 /** |
| 125 * Map the part (at offset |offset| of length |numBytes|) of the buffer give
n by this handle |
| 126 * into memory. |offset + numBytes| must be less than or equal to the size o
f the buffer. On |
| 127 * success, the returned buffer points to memory with the requested part of
the buffer. A single |
| 128 * buffer handle may have multiple active mappings (possibly depending on th
e buffer type). The |
| 129 * permissions (e.g., writable or executable) of the returned memory may dep
end on the |
| 130 * properties of the buffer and properties attached to the buffer handle as
well as |flags|. |
| 131 */ |
| 132 public ByteBuffer map(long offset, long numBytes, MapFlags flags); |
| 133 |
| 134 /** |
| 135 * Unmap a buffer pointer that was mapped by |map()|. |
| 136 */ |
| 137 public void unmap(ByteBuffer buffer); |
| 138 |
| 139 } |
OLD | NEW |