• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 org.chromium.net;
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         /** Request is idempotent. Passed to {@link #setIdempotency}. */
52         public static final int IDEMPOTENT = 1;
53 
54         /** Request is not idempotent. Passed to {@link #setIdempotency}. */
55         public static final int NOT_IDEMPOTENT = 2;
56 
57         /**
58          * Sets idempotency of the request which should be one of the {@link #DEFAULT_IDEMPOTENCY
59          * IDEMPOTENT NOT_IDEMPOTENT} values. The default idempotency indicates that 0-RTT is only
60          * enabled for safe HTTP methods (GET, HEAD, OPTIONS, and TRACE).
61          *
62          * @param idempotency idempotency of the request which should be one of the {@link
63          * #DEFAULT_IDEMPOTENCY IDEMPOTENT NOT_IDEMPOTENT} values.
64          * @return the builder to facilitate chaining.
65          */
setIdempotency(int idempotency)66         public Builder setIdempotency(int idempotency) {
67             return this;
68         }
69 
70         // To support method chaining, override superclass methods to return an
71         // instance of this class instead of the parent.
72 
73         @Override
setHttpMethod(String method)74         public abstract Builder setHttpMethod(String method);
75 
76         @Override
addHeader(String header, String value)77         public abstract Builder addHeader(String header, String value);
78 
79         @Override
disableCache()80         public abstract Builder disableCache();
81 
82         @Override
setPriority(int priority)83         public abstract Builder setPriority(int priority);
84 
85         @Override
setUploadDataProvider( UploadDataProvider uploadDataProvider, Executor executor)86         public abstract Builder setUploadDataProvider(
87                 UploadDataProvider uploadDataProvider, Executor executor);
88 
89         @Override
allowDirectExecutor()90         public abstract Builder allowDirectExecutor();
91 
92         @Override
build()93         public abstract ExperimentalUrlRequest build();
94 
95         @Override
addRequestAnnotation(Object annotation)96         public Builder addRequestAnnotation(Object annotation) {
97             return this;
98         }
99 
100         @Override
setTrafficStatsTag(int tag)101         public Builder setTrafficStatsTag(int tag) {
102             return this;
103         }
104 
105         @Override
setTrafficStatsUid(int uid)106         public Builder setTrafficStatsUid(int uid) {
107             return this;
108         }
109 
110         @Override
setRequestFinishedListener(RequestFinishedInfo.Listener listener)111         public Builder setRequestFinishedListener(RequestFinishedInfo.Listener listener) {
112             return this;
113         }
114     }
115 }
116