package io.undertow.conduits;
import org.xnio.channels.StreamSinkChannel;
import org.xnio.conduits.AbstractStreamSourceConduit;
import org.xnio.conduits.StreamSourceConduit;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class BytesReceivedStreamSourceConduit extends AbstractStreamSourceConduit<StreamSourceConduit> {
private final ByteActivityCallback callback;
public BytesReceivedStreamSourceConduit(StreamSourceConduit next, ByteActivityCallback callback) {
super(next);
this.callback = callback;
}
@Override
public long transferTo(long position, long count, FileChannel target) throws IOException {
long l = super.transferTo(position, count, target);
callback.activity(l);
return l;
}
@Override
public long transferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) throws IOException {
long l = super.transferTo(count, throughBuffer, target);
callback.activity(l);
return l;
}
@Override
public int read(ByteBuffer dst) throws IOException {
int i = super.read(dst);
callback.activity(i);
return i;
}
@Override
public long read(ByteBuffer[] dsts, int offs, int len) throws IOException {
long l = super.read(dsts, offs, len);
callback.activity(l);
return l;
}
}