Home | History | Annotate | Download | only in impl
      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.ConsumerHandle;
      8 import org.chromium.mojo.system.DataPipe.ReadFlags;
      9 import org.chromium.mojo.system.ResultAnd;
     10 
     11 import java.nio.ByteBuffer;
     12 
     13 /**
     14  * Implementation of {@link ConsumerHandle}.
     15  */
     16 class DataPipeConsumerHandleImpl extends HandleBase implements ConsumerHandle {
     17     /**
     18      * @see HandleBase#HandleBase(CoreImpl, int)
     19      */
     20     DataPipeConsumerHandleImpl(CoreImpl core, int mojoHandle) {
     21         super(core, mojoHandle);
     22     }
     23 
     24     /**
     25      * @see HandleBase#HandleBase(HandleBase)
     26      */
     27     DataPipeConsumerHandleImpl(HandleBase other) {
     28         super(other);
     29     }
     30 
     31     /**
     32      * @see org.chromium.mojo.system.Handle#pass()
     33      */
     34     @Override
     35     public ConsumerHandle pass() {
     36         return new DataPipeConsumerHandleImpl(this);
     37     }
     38 
     39     /**
     40      * @see ConsumerHandle#discardData(int, ReadFlags)
     41      */
     42     @Override
     43     public int discardData(int numBytes, ReadFlags flags) {
     44         return mCore.discardData(this, numBytes, flags);
     45     }
     46 
     47     /**
     48      * @see ConsumerHandle#readData(ByteBuffer, ReadFlags)
     49      */
     50     @Override
     51     public ResultAnd<Integer> readData(ByteBuffer elements, ReadFlags flags) {
     52         return mCore.readData(this, elements, flags);
     53     }
     54 
     55     /**
     56      * @see ConsumerHandle#beginReadData(int, ReadFlags)
     57      */
     58     @Override
     59     public ByteBuffer beginReadData(int numBytes, ReadFlags flags) {
     60         return mCore.beginReadData(this, numBytes, flags);
     61     }
     62 
     63     /**
     64      * @see ConsumerHandle#endReadData(int)
     65      */
     66     @Override
     67     public void endReadData(int numBytesRead) {
     68         mCore.endReadData(this, numBytesRead);
     69     }
     70 }
     71