1 // Copyright 2016 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 package android.net.http; 5 6 import java.util.concurrent.Executor; 7 8 /** 9 * {@link UrlRequest} that exposes experimental features. To obtain an instance of this class, cast 10 * a {@code UrlRequest} to this type. Every instance of {@code UrlRequest} can be cast to an 11 * instance of this class, as they are backed by the same implementation and hence perform 12 * identically. Instances of this class are not meant for general use, but instead only to access 13 * experimental features. Experimental features may be deprecated in the future. Use at your own 14 * risk. 15 * 16 * {@hide for consistency with other experimental classes} 17 * 18 * @deprecated scheduled for deletion, don't use in new code. 19 */ 20 @Deprecated 21 public abstract class ExperimentalUrlRequest extends UrlRequest { 22 /** 23 * {@link UrlRequest#Builder} that exposes experimental features. To obtain an instance of this 24 * class, cast a {@code UrlRequest.Builder} to this type. Every instance of {@code 25 * UrlRequest.Builder} can be cast to an instance of this class, as they are backed by the same 26 * implementation and hence perform identically. Instances of this class are not meant for 27 * general use, but instead only to access experimental features. Experimental features may be 28 * deprecated in the future. Use at your own risk. 29 * 30 * {@hide for consistency with other experimental classes} 31 * 32 * @deprecated scheduled for deletion, don't use in new code. 33 */ 34 @Deprecated 35 public abstract static class Builder extends UrlRequest.Builder { 36 /** 37 * Disables connection migration for the request if enabled for the session. 38 * 39 * @return the builder to facilitate chaining. 40 */ disableConnectionMigration()41 public Builder disableConnectionMigration() { 42 return this; 43 } 44 45 /** 46 * Default request idempotency, only enable 0-RTT for safe HTTP methods. Passed to {@link 47 * #setIdempotency}. 48 */ 49 public static final int DEFAULT_IDEMPOTENCY = 0; 50 51 /** 52 * Request is idempotent. Passed to {@link #setIdempotency}. 53 */ 54 public static final int IDEMPOTENT = 1; 55 56 /** 57 * Request is not idempotent. Passed to {@link #setIdempotency}. 58 */ 59 public static final int NOT_IDEMPOTENT = 2; 60 61 /** 62 * Sets idempotency of the request which should be one of the {@link #DEFAULT_IDEMPOTENCY 63 * IDEMPOTENT NOT_IDEMPOTENT} values. The default idempotency indicates that 0-RTT is only 64 * enabled for safe HTTP methods (GET, HEAD, OPTIONS, and TRACE). 65 * 66 * @param idempotency idempotency of the request which should be one of the {@link 67 * #DEFAULT_IDEMPOTENCY IDEMPOTENT NOT_IDEMPOTENT} values. 68 * @return the builder to facilitate chaining. 69 */ setIdempotency(int idempotency)70 public Builder setIdempotency(int idempotency) { 71 return this; 72 } 73 74 // To support method chaining, override superclass methods to return an 75 // instance of this class instead of the parent. 76 77 @Override setHttpMethod(String method)78 public abstract Builder setHttpMethod(String method); 79 80 @Override addHeader(String header, String value)81 public abstract Builder addHeader(String header, String value); 82 83 @Override setCacheDisabled(boolean disableCache)84 public abstract Builder setCacheDisabled(boolean disableCache); 85 86 @Override setPriority(int priority)87 public abstract Builder setPriority(int priority); 88 89 @Override setUploadDataProvider( UploadDataProvider uploadDataProvider, Executor executor)90 public abstract Builder setUploadDataProvider( 91 UploadDataProvider uploadDataProvider, Executor executor); 92 93 @Override setDirectExecutorAllowed(boolean allowDirectExecutor)94 public abstract Builder setDirectExecutorAllowed(boolean allowDirectExecutor); 95 96 @Override build()97 public abstract ExperimentalUrlRequest build(); 98 99 @Override addRequestAnnotation(Object annotation)100 public Builder addRequestAnnotation(Object annotation) { 101 return this; 102 } 103 104 @Override setTrafficStatsTag(int tag)105 public Builder setTrafficStatsTag(int tag) { 106 return this; 107 } 108 109 @Override setTrafficStatsUid(int uid)110 public Builder setTrafficStatsUid(int uid) { 111 return this; 112 } 113 114 @Override setRequestFinishedListener(RequestFinishedInfo.Listener listener)115 public Builder setRequestFinishedListener(RequestFinishedInfo.Listener listener) { 116 return this; 117 } 118 } 119 } 120