| Index: components/cronet/android/api/src/org/chromium/net/BidirectionalStream.java
|
| diff --git a/components/cronet/android/api/src/org/chromium/net/BidirectionalStream.java b/components/cronet/android/api/src/org/chromium/net/BidirectionalStream.java
|
| index 5b6d04bfc427ba4052019ed18cb7c70cbb54004f..b7136a238d8267e50ac28b42c0e39ad9d61d6a97 100644
|
| --- a/components/cronet/android/api/src/org/chromium/net/BidirectionalStream.java
|
| +++ b/components/cronet/android/api/src/org/chromium/net/BidirectionalStream.java
|
| @@ -47,6 +47,8 @@ public abstract class BidirectionalStream {
|
| // Priority of the stream. Default is medium.
|
| @StreamPriority private int mPriority = STREAM_PRIORITY_MEDIUM;
|
|
|
| + private boolean mDisableAutoFlush;
|
| +
|
| /**
|
| * Creates a builder for {@link BidirectionalStream} objects. All callbacks for
|
| * generated {@code BidirectionalStream} objects will be invoked on
|
| @@ -160,6 +162,16 @@ public abstract class BidirectionalStream {
|
| }
|
|
|
| /**
|
| + * By default, data is flushed after every {@link #write write()}. This
|
| + * is to disable auto flush.
|
| + * @return the builder to facilitate chaining.
|
| + */
|
| + public Builder setDisableAutoFlush() {
|
| + mDisableAutoFlush = true;
|
| + return this;
|
| + }
|
| +
|
| + /**
|
| * Creates a {@link BidirectionalStream} using configuration from this
|
| * {@link Builder}. The returned {@code BidirectionalStream} can then be started
|
| * by calling {@link BidirectionalStream#start}.
|
| @@ -168,8 +180,8 @@ public abstract class BidirectionalStream {
|
| * this {@link Builder}
|
| */
|
| public BidirectionalStream build() {
|
| - return mCronetEngine.createBidirectionalStream(
|
| - mUrl, mCallback, mExecutor, mHttpMethod, mRequestHeaders, mPriority);
|
| + return mCronetEngine.createBidirectionalStream(mUrl, mCallback, mExecutor, mHttpMethod,
|
| + mRequestHeaders, mPriority, mDisableAutoFlush);
|
| }
|
| }
|
|
|
| @@ -178,12 +190,14 @@ public abstract class BidirectionalStream {
|
| */
|
| public abstract static class Callback {
|
| /**
|
| - * Invoked when request headers are sent. Indicates that stream has initiated the request.
|
| - * Consumer may call {@link BidirectionalStream#write write()} to start writing data.
|
| + * Invoked when the stream is ready for reading and writing.
|
| + * Consumer may call {@link BidirectionalStream#read read()} to start
|
| + * reading. Consumer may call {@link BidirectionalStream#write write()}
|
| + * to start writing data.
|
| *
|
| - * @param stream the stream on which request headers were sent
|
| + * @param stream the stream that is ready
|
| */
|
| - public abstract void onRequestHeadersSent(BidirectionalStream stream);
|
| + public abstract void onStreamReady(BidirectionalStream stream);
|
|
|
| /**
|
| * Invoked when initial response headers are received. Headers are available from
|
| @@ -340,7 +354,7 @@ public abstract class BidirectionalStream {
|
| /**
|
| * Attempts to write data from the provided buffer into the stream.
|
| * Must only be called at most once in response to each invocation of the
|
| - * {@link Callback#onRequestHeadersSent onRequestHeadersSent()} or {@link
|
| + * {@link Callback#onStreamReady onStreamReady()} or {@link
|
| * Callback#onWriteCompleted onWriteCompleted()} methods of the {@link Callback}.
|
| * Each call will result in an asynchronous call to one of the {@link Callback Callback}'s
|
| * {@link Callback#onWriteCompleted onWriteCompleted()} method if data
|
| @@ -365,6 +379,12 @@ public abstract class BidirectionalStream {
|
| public abstract void write(ByteBuffer buffer, boolean endOfStream);
|
|
|
| /**
|
| + * Flushes pending writes. This method should only be invoked when auto
|
| + * flush is disable through {@link Builder#setDisableAutoFlush}.
|
| + */
|
| + public abstract void flush();
|
| +
|
| + /**
|
| * Pings remote end-point. {@code callback} methods will be invoked on {@code executor}.
|
| *
|
| * @param callback the callback that will be invoked when ping succeeds or fails
|
|
|