• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.impl;
6 
7 import org.chromium.mojo.system.DataPipe.ProducerHandle;
8 import org.chromium.mojo.system.DataPipe.WriteFlags;
9 import org.chromium.mojo.system.ResultAnd;
10 
11 import java.nio.ByteBuffer;
12 
13 /**
14  * Implementation of {@link ProducerHandle}.
15  */
16 class DataPipeProducerHandleImpl extends HandleBase implements ProducerHandle {
17 
18     /**
19      * @see HandleBase#HandleBase(CoreImpl, int)
20      */
DataPipeProducerHandleImpl(CoreImpl core, int mojoHandle)21     DataPipeProducerHandleImpl(CoreImpl core, int mojoHandle) {
22         super(core, mojoHandle);
23     }
24 
25     /**
26      * @see HandleBase#HandleBase(HandleBase)
27      */
DataPipeProducerHandleImpl(HandleBase handle)28     DataPipeProducerHandleImpl(HandleBase handle) {
29         super(handle);
30     }
31 
32     /**
33      * @see org.chromium.mojo.system.DataPipe.ProducerHandle#pass()
34      */
35     @Override
pass()36     public ProducerHandle pass() {
37         return new DataPipeProducerHandleImpl(this);
38     }
39 
40     /**
41      * @see ProducerHandle#writeData(ByteBuffer, WriteFlags)
42      */
43     @Override
writeData(ByteBuffer elements, WriteFlags flags)44     public ResultAnd<Integer> writeData(ByteBuffer elements, WriteFlags flags) {
45         return mCore.writeData(this, elements, flags);
46     }
47 
48     /**
49      * @see ProducerHandle#beginWriteData(int, WriteFlags)
50      */
51     @Override
beginWriteData(int numBytes, WriteFlags flags)52     public ByteBuffer beginWriteData(int numBytes, WriteFlags flags) {
53         return mCore.beginWriteData(this, numBytes, flags);
54     }
55 
56     /**
57      * @see ProducerHandle#endWriteData(int)
58      */
59     @Override
endWriteData(int numBytesWritten)60     public void endWriteData(int numBytesWritten) {
61         mCore.endWriteData(this, numBytesWritten);
62     }
63 
64 }
65