• 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 
5 package android.net.http;
6 
7 /**
8  * {@link BidirectionalStream} that exposes experimental features. To obtain an
9  * instance of this class, cast a {@code BidirectionalStream} to this type. Every
10  * instance of {@code BidirectionalStream} can be cast to an instance of this class,
11  * as they are backed by the same implementation and hence perform identically.
12  * Instances of this class are not meant for general use, but instead only
13  * to access experimental features. Experimental features may be deprecated in the
14  * future. Use at your own risk.
15  *
16  * {@hide prototype}
17  */
18 public abstract class ExperimentalBidirectionalStream extends BidirectionalStream {
19     /**
20      * {@link BidirectionalStream.Builder} that exposes experimental features. To obtain an
21      * instance of this class, cast a {@code BidirectionalStream.Builder} to this type. Every
22      * instance of {@code BidirectionalStream.Builder} can be cast to an instance of this class,
23      * as they are backed by the same implementation and hence perform identically.
24      * Instances of this class are not meant for general use, but instead only
25      * to access experimental features. Experimental features may be deprecated in the
26      * future. Use at your own risk.
27      */
28     public abstract static class Builder extends BidirectionalStream.Builder {
29         /**
30          * Associates the annotation object with this request. May add more than one.
31          * Passed through to a {@link RequestFinishedInfo.Listener},
32          * see {@link RequestFinishedInfo#getAnnotations}.
33          *
34          * @param annotation an object to pass on to the {@link RequestFinishedInfo.Listener} with a
35          * {@link RequestFinishedInfo}.
36          * @return the builder to facilitate chaining.
37          */
addRequestAnnotation(Object annotation)38         public Builder addRequestAnnotation(Object annotation) {
39             return this;
40         }
41 
42         /**
43          * Binds the request to the specified network handle. The HTTP stack will send this request
44          * only using the network associated to this handle. If this network disconnects the request
45          * will  fail, the exact error will depend on the stage of request processing when
46          * the network disconnects. Network handles can be obtained
47          * through {@code Network#getNetworkHandle}.
48          *
49          * @param networkHandle the network handle to bind the request to. Specify
50          *        {@link ExperimentalHttpEngine#UNBIND_NETWORK_HANDLE} to unbind.
51          * @return the builder to facilitate chaining.
52          */
bindToNetwork(long networkHandle)53         public Builder bindToNetwork(long networkHandle) {
54             return this;
55         }
56 
57         // To support method chaining, override superclass methods to return an
58         // instance of this class instead of the parent.
59 
60         @Override
setHttpMethod(String method)61         public abstract Builder setHttpMethod(String method);
62 
63         @Override
addHeader(String header, String value)64         public abstract Builder addHeader(String header, String value);
65 
66         @Override
setPriority(int priority)67         public abstract Builder setPriority(int priority);
68 
69         @Override
setDelayRequestHeadersUntilFirstFlushEnabled( boolean delayRequestHeadersUntilFirstFlush)70         public abstract Builder setDelayRequestHeadersUntilFirstFlushEnabled(
71                 boolean delayRequestHeadersUntilFirstFlush);
72 
73         @Override
build()74         public abstract ExperimentalBidirectionalStream build();
75     }
76 }
77