OLD | NEW |
---|---|
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 } | 81 } |
82 | 82 |
83 /** | 83 /** |
84 * Sets the HTTP method for the request. Returns builder to facilitate c haining. | 84 * Sets the HTTP method for the request. Returns builder to facilitate c haining. |
85 * | 85 * |
86 * @param method the method to use for request. Default is 'POST' | 86 * @param method the method to use for request. Default is 'POST' |
87 * @return the builder to facilitate chaining | 87 * @return the builder to facilitate chaining |
88 */ | 88 */ |
89 public Builder setHttpMethod(String method) { | 89 public Builder setHttpMethod(String method) { |
90 if (method == null) { | 90 if (method == null) { |
91 throw new NullPointerException("Invalid method name."); | 91 throw new NullPointerException("Method is required."); |
92 } | 92 } |
93 mHttpMethod = method; | 93 mHttpMethod = method; |
94 return this; | 94 return this; |
95 } | 95 } |
96 | 96 |
97 /** | 97 /** |
98 * Adds a request header. Returns builder to facilitate chaining. | 98 * Adds a request header. Returns builder to facilitate chaining. |
99 * | 99 * |
100 * @param header the header name | 100 * @param header the header name |
101 * @param value the header value | 101 * @param value the header value |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 /** | 147 /** |
148 * Sets priority of the stream which should be one of the | 148 * Sets priority of the stream which should be one of the |
149 * {@link #STREAM_PRIORITY_IDLE STREAM_PRIORITY_*} values. | 149 * {@link #STREAM_PRIORITY_IDLE STREAM_PRIORITY_*} values. |
150 * The stream is given {@link #STREAM_PRIORITY_MEDIUM} priority if {@lin k | 150 * The stream is given {@link #STREAM_PRIORITY_MEDIUM} priority if {@lin k |
151 * #setPriority} is not called. | 151 * #setPriority} is not called. |
152 * | 152 * |
153 * @param priority priority of the stream which should be one of the | 153 * @param priority priority of the stream which should be one of the |
154 * {@link #STREAM_PRIORITY_IDLE STREAM_PRIORITY_*} values. | 154 * {@link #STREAM_PRIORITY_IDLE STREAM_PRIORITY_*} values. |
155 * @return the builder to facilitate chaining. | 155 * @return the builder to facilitate chaining. |
156 */ | 156 */ |
157 public Builder setPriority(@StreamPriority int priority) { | 157 public Builder setPriority(@StreamPriority int priority) { |
kapishnikov
2016/01/22 16:58:14
Not related to this CL but I noticed that @StreamP
mef
2016/01/22 17:36:06
Yeah, we need to re-work the whole priority API, s
| |
158 mPriority = priority; | 158 mPriority = priority; |
159 return this; | 159 return this; |
160 } | 160 } |
161 | 161 |
162 /** | 162 /** |
163 * Creates a {@link BidirectionalStream} using configuration from this | 163 * Creates a {@link BidirectionalStream} using configuration from this |
164 * {@link Builder}. The returned {@code BidirectionalStream} can then be started | 164 * {@link Builder}. The returned {@code BidirectionalStream} can then be started |
165 * by calling {@link BidirectionalStream#start}. | 165 * by calling {@link BidirectionalStream#start}. |
166 * | 166 * |
167 * @return constructed {@link BidirectionalStream} using configuration f rom | 167 * @return constructed {@link BidirectionalStream} using configuration f rom |
168 * this {@link Builder} | 168 * this {@link Builder} |
169 */ | 169 */ |
170 public BidirectionalStream build() { | 170 public BidirectionalStream build() { |
171 return mCronetEngine.createBidirectionalStream( | 171 return mCronetEngine.createBidirectionalStream( |
172 mUrl, mCallback, mExecutor, mHttpMethod, mRequestHeaders, mP riority); | 172 mUrl, mCallback, mExecutor, mHttpMethod, mRequestHeaders, mP riority); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 /** | 176 /** |
177 * Callback class used to receive callbacks from a {@link BidirectionalStrea m}. | 177 * Callback class used to receive callbacks from a {@link BidirectionalStrea m}. |
178 */ | 178 */ |
179 public abstract static class Callback { | 179 public abstract static class Callback { |
kapishnikov
2016/01/22 16:58:14
I wonder why the Callback class is a class and not
mef
2016/01/22 17:36:06
Per Android API guidelines.
| |
180 /** | 180 /** |
181 * Invoked when request headers are sent. Indicates that stream has init iated the request. | 181 * Invoked when request headers are sent. Indicates that stream has init iated the request. |
182 * Consumer may call {@link BidirectionalStream#write write()} to start writing data. | 182 * Consumer may call {@link BidirectionalStream#write write()} to start writing data. |
183 * | 183 * |
184 * @param stream the stream on which request headers were sent | 184 * @param stream the stream on which request headers were sent |
185 */ | 185 */ |
186 public abstract void onRequestHeadersSent(BidirectionalStream stream); | 186 public abstract void onRequestHeadersSent(BidirectionalStream stream); |
187 | 187 |
188 /** | 188 /** |
189 * Invoked when initial response headers are received. Headers are avail able from | 189 * Invoked when initial response headers are received. Headers are avail able from |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 /** | 399 /** |
400 * Returns {@code true} if the stream was successfully started and is now | 400 * Returns {@code true} if the stream was successfully started and is now |
401 * done (succeeded, canceled, or failed). | 401 * done (succeeded, canceled, or failed). |
402 * | 402 * |
403 * @return {@code true} if the stream was successfully started and is now | 403 * @return {@code true} if the stream was successfully started and is now |
404 * done (completed, canceled, or failed), otherwise returns {@code f alse} | 404 * done (completed, canceled, or failed), otherwise returns {@code f alse} |
405 * to indicate stream is not yet started or is in progress. | 405 * to indicate stream is not yet started or is in progress. |
406 */ | 406 */ |
407 public abstract boolean isDone(); | 407 public abstract boolean isDone(); |
408 } | 408 } |
OLD | NEW |