Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: components/cronet/android/api/src/org/chromium/net/BidirectionalStream.java

Issue 1992953004: [Cronet] Make delaying sending request headers explicit in bidirectional stream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.support.annotation.IntDef; 7 import android.support.annotation.IntDef;
8 8
9 import java.lang.annotation.Retention; 9 import java.lang.annotation.Retention;
10 import java.lang.annotation.RetentionPolicy; 10 import java.lang.annotation.RetentionPolicy;
(...skipping 30 matching lines...) Expand all
41 // List of request headers, stored as header field name and value pairs. 41 // List of request headers, stored as header field name and value pairs.
42 private final ArrayList<Map.Entry<String, String>> mRequestHeaders = 42 private final ArrayList<Map.Entry<String, String>> mRequestHeaders =
43 new ArrayList<Map.Entry<String, String>>(); 43 new ArrayList<Map.Entry<String, String>>();
44 44
45 // HTTP method for the request. Default to POST. 45 // HTTP method for the request. Default to POST.
46 private String mHttpMethod = "POST"; 46 private String mHttpMethod = "POST";
47 // Priority of the stream. Default is medium. 47 // Priority of the stream. Default is medium.
48 @StreamPriority private int mPriority = STREAM_PRIORITY_MEDIUM; 48 @StreamPriority private int mPriority = STREAM_PRIORITY_MEDIUM;
49 49
50 private boolean mDisableAutoFlush; 50 private boolean mDisableAutoFlush;
51 private boolean mDelayHeadersUntilNextWrite;
51 52
52 /** 53 /**
53 * Creates a builder for {@link BidirectionalStream} objects. All callba cks for 54 * Creates a builder for {@link BidirectionalStream} objects. All callba cks for
54 * generated {@code BidirectionalStream} objects will be invoked on 55 * generated {@code BidirectionalStream} objects will be invoked on
55 * {@code executor}. {@code executor} must not run tasks on the 56 * {@code executor}. {@code executor} must not run tasks on the
56 * current thread, otherwise the networking operations may block and exc eptions 57 * current thread, otherwise the networking operations may block and exc eptions
57 * may be thrown at shutdown time. 58 * may be thrown at shutdown time.
58 * 59 *
59 * @param url the URL for the generated stream 60 * @param url the URL for the generated stream
60 * @param callback the {@link Callback} object that gets invoked upon di fferent events 61 * @param callback the {@link Callback} object that gets invoked upon di fferent events
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 * 168 *
168 * @param disableAutoFlush if true, auto flush will be disabled. 169 * @param disableAutoFlush if true, auto flush will be disabled.
169 * @return the builder to facilitate chaining. 170 * @return the builder to facilitate chaining.
170 */ 171 */
171 public Builder disableAutoFlush(boolean disableAutoFlush) { 172 public Builder disableAutoFlush(boolean disableAutoFlush) {
172 mDisableAutoFlush = disableAutoFlush; 173 mDisableAutoFlush = disableAutoFlush;
173 return this; 174 return this;
174 } 175 }
175 176
176 /** 177 /**
178 * Delays sending request headers until the next {@link write()} is invo ked.
179 * This flag is currently only respected when QUIC is negotiated.
180 * When true, QUIC will send request header frame along with data frame( s)
181 * as a single packet when possible.
182 *
183 * @param delayHeadersUntilNextWrite if true, sending request headers wi ll
184 * be delayed until the next write() is invoked.
185 * @return the builder to facilitate chaining.
186 */
187 public Builder delayHeadersUntilNextWrite(boolean delayHeadersUntilNextW rite) {
mef 2016/05/23 14:57:26 Does it have an effect if disableAutoFlush is fals
188 mDelayHeadersUntilNextWrite = delayHeadersUntilNextWrite;
189 return this;
190 }
191
192 /**
177 * Creates a {@link BidirectionalStream} using configuration from this 193 * Creates a {@link BidirectionalStream} using configuration from this
178 * {@link Builder}. The returned {@code BidirectionalStream} can then be started 194 * {@link Builder}. The returned {@code BidirectionalStream} can then be started
179 * by calling {@link BidirectionalStream#start}. 195 * by calling {@link BidirectionalStream#start}.
180 * 196 *
181 * @return constructed {@link BidirectionalStream} using configuration f rom 197 * @return constructed {@link BidirectionalStream} using configuration f rom
182 * this {@link Builder} 198 * this {@link Builder}
183 */ 199 */
184 public BidirectionalStream build() { 200 public BidirectionalStream build() {
185 return mCronetEngine.createBidirectionalStream(mUrl, mCallback, mExe cutor, mHttpMethod, 201 return mCronetEngine.createBidirectionalStream(mUrl, mCallback, mExe cutor, mHttpMethod,
186 mRequestHeaders, mPriority, mDisableAutoFlush); 202 mRequestHeaders, mPriority, mDisableAutoFlush, mDelayHeaders UntilNextWrite);
187 } 203 }
188 } 204 }
189 205
190 /** 206 /**
191 * Callback class used to receive callbacks from a {@link BidirectionalStrea m}. 207 * Callback class used to receive callbacks from a {@link BidirectionalStrea m}.
192 */ 208 */
193 public abstract static class Callback { 209 public abstract static class Callback {
194 /** 210 /**
195 * Invoked when the stream is ready for reading and writing. 211 * Invoked when the stream is ready for reading and writing.
196 * Consumer may call {@link BidirectionalStream#read read()} to start re ading data. 212 * Consumer may call {@link BidirectionalStream#read read()} to start re ading data.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 /** 434 /**
419 * Returns {@code true} if the stream was successfully started and is now 435 * Returns {@code true} if the stream was successfully started and is now
420 * done (succeeded, canceled, or failed). 436 * done (succeeded, canceled, or failed).
421 * 437 *
422 * @return {@code true} if the stream was successfully started and is now 438 * @return {@code true} if the stream was successfully started and is now
423 * done (completed, canceled, or failed), otherwise returns {@code f alse} 439 * done (completed, canceled, or failed), otherwise returns {@code f alse}
424 * to indicate stream is not yet started or is in progress. 440 * to indicate stream is not yet started or is in progress.
425 */ 441 */
426 public abstract boolean isDone(); 442 public abstract boolean isDone();
427 } 443 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698