| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 import android.util.Log; | 8 import android.util.Log; |
| 9 import android.util.Pair; | 9 import android.util.Pair; |
| 10 | 10 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 /** | 133 /** |
| 134 * Disables cache for the request. If context is not set up to use cache
, | 134 * Disables cache for the request. If context is not set up to use cache
, |
| 135 * this call has no effect. | 135 * this call has no effect. |
| 136 * @return the builder to facilitate chaining. | 136 * @return the builder to facilitate chaining. |
| 137 */ | 137 */ |
| 138 public Builder disableCache() { | 138 public Builder disableCache() { |
| 139 mDisableCache = true; | 139 mDisableCache = true; |
| 140 return this; | 140 return this; |
| 141 } | 141 } |
| 142 | 142 |
| 143 /** @deprecated not really deprecated but hidden. */ | 143 /** @hide */ |
| 144 @IntDef({ | 144 @IntDef({ |
| 145 REQUEST_PRIORITY_IDLE, REQUEST_PRIORITY_LOWEST, REQUEST_PRIORITY
_LOW, | 145 REQUEST_PRIORITY_IDLE, REQUEST_PRIORITY_LOWEST, REQUEST_PRIORITY
_LOW, |
| 146 REQUEST_PRIORITY_MEDIUM, REQUEST_PRIORITY_HIGHEST, | 146 REQUEST_PRIORITY_MEDIUM, REQUEST_PRIORITY_HIGHEST, |
| 147 }) | 147 }) |
| 148 @Retention(RetentionPolicy.SOURCE) | 148 @Retention(RetentionPolicy.SOURCE) |
| 149 @SuppressWarnings("DepAnn") | |
| 150 public @interface RequestPriority {} | 149 public @interface RequestPriority {} |
| 151 | 150 |
| 152 /** | 151 /** |
| 153 * Lowest request priority. Passed to {@link #setPriority}. | 152 * Lowest request priority. Passed to {@link #setPriority}. |
| 154 */ | 153 */ |
| 155 public static final int REQUEST_PRIORITY_IDLE = 0; | 154 public static final int REQUEST_PRIORITY_IDLE = 0; |
| 156 /** | 155 /** |
| 157 * Very low request priority. Passed to {@link #setPriority}. | 156 * Very low request priority. Passed to {@link #setPriority}. |
| 158 */ | 157 */ |
| 159 public static final int REQUEST_PRIORITY_LOWEST = 1; | 158 public static final int REQUEST_PRIORITY_LOWEST = 1; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 214 |
| 216 /** | 215 /** |
| 217 * Associates the annotation object with this request. May add more than
one. | 216 * Associates the annotation object with this request. May add more than
one. |
| 218 * Passed through to a {@link CronetEngine.RequestFinishedListener}, | 217 * Passed through to a {@link CronetEngine.RequestFinishedListener}, |
| 219 * see {@link CronetEngine.UrlRequestInfo#getAnnotations}. | 218 * see {@link CronetEngine.UrlRequestInfo#getAnnotations}. |
| 220 * | 219 * |
| 221 * @param annotation an object to pass on to the | 220 * @param annotation an object to pass on to the |
| 222 * {@link CronetEngine.RequestFinishedListener} with a {@link CronetEngi
ne.UrlRequestInfo}. | 221 * {@link CronetEngine.RequestFinishedListener} with a {@link CronetEngi
ne.UrlRequestInfo}. |
| 223 * @return the builder to facilitate chaining. | 222 * @return the builder to facilitate chaining. |
| 224 * | 223 * |
| 225 * @deprecated not really deprecated but hidden for now as it's a protot
ype. | 224 * @hide as it's a prototype. |
| 226 */ | 225 */ |
| 227 @Deprecated | |
| 228 public Builder addRequestAnnotation(Object annotation) { | 226 public Builder addRequestAnnotation(Object annotation) { |
| 229 if (annotation == null) { | 227 if (annotation == null) { |
| 230 throw new NullPointerException("Invalid metrics annotation."); | 228 throw new NullPointerException("Invalid metrics annotation."); |
| 231 } | 229 } |
| 232 if (mRequestAnnotations.isEmpty()) { | 230 if (mRequestAnnotations.isEmpty()) { |
| 233 mRequestAnnotations = new ArrayList<Object>(); | 231 mRequestAnnotations = new ArrayList<Object>(); |
| 234 } | 232 } |
| 235 mRequestAnnotations.add(annotation); | 233 mRequestAnnotations.add(annotation); |
| 236 return this; | 234 return this; |
| 237 } | 235 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 * @param info Response information. May be {@code null} if no response
was | 362 * @param info Response information. May be {@code null} if no response
was |
| 365 * received. | 363 * received. |
| 366 */ | 364 */ |
| 367 public void onCanceled(UrlRequest request, UrlResponseInfo info) {} | 365 public void onCanceled(UrlRequest request, UrlResponseInfo info) {} |
| 368 } | 366 } |
| 369 | 367 |
| 370 /** | 368 /** |
| 371 * Request status values returned by {@link #getStatus}. | 369 * Request status values returned by {@link #getStatus}. |
| 372 */ | 370 */ |
| 373 public static class Status { | 371 public static class Status { |
| 374 /** @deprecated not really deprecated but hidden. */ | 372 /** @hide */ |
| 375 @IntDef({ | 373 @IntDef({ |
| 376 INVALID, IDLE, WAITING_FOR_STALLED_SOCKET_POOL, WAITING_FOR_AVAI
LABLE_SOCKET, | 374 INVALID, IDLE, WAITING_FOR_STALLED_SOCKET_POOL, WAITING_FOR_AVAI
LABLE_SOCKET, |
| 377 WAITING_FOR_DELEGATE, WAITING_FOR_CACHE, DOWNLOADING_PROXY_SCRIP
T, | 375 WAITING_FOR_DELEGATE, WAITING_FOR_CACHE, DOWNLOADING_PROXY_SCRIP
T, |
| 378 RESOLVING_PROXY_FOR_URL, RESOLVING_HOST_IN_PROXY_SCRIPT, ESTABLI
SHING_PROXY_TUNNEL, | 376 RESOLVING_PROXY_FOR_URL, RESOLVING_HOST_IN_PROXY_SCRIPT, ESTABLI
SHING_PROXY_TUNNEL, |
| 379 RESOLVING_HOST, CONNECTING, SSL_HANDSHAKE, SENDING_REQUEST, WAIT
ING_FOR_RESPONSE, | 377 RESOLVING_HOST, CONNECTING, SSL_HANDSHAKE, SENDING_REQUEST, WAIT
ING_FOR_RESPONSE, |
| 380 READING_RESPONSE, | 378 READING_RESPONSE, |
| 381 }) | 379 }) |
| 382 @Retention(RetentionPolicy.SOURCE) | 380 @Retention(RetentionPolicy.SOURCE) |
| 383 @SuppressWarnings("DepAnn") | |
| 384 public @interface StatusValues {} | 381 public @interface StatusValues {} |
| 385 | 382 |
| 386 /** | 383 /** |
| 387 * This state indicates that the request is completed, canceled, or is n
ot | 384 * This state indicates that the request is completed, canceled, or is n
ot |
| 388 * started. | 385 * started. |
| 389 */ | 386 */ |
| 390 public static final int INVALID = -1; | 387 public static final int INVALID = -1; |
| 391 /** | 388 /** |
| 392 * This state corresponds to a resource load that has either not yet beg
un | 389 * This state corresponds to a resource load that has either not yet beg
un |
| 393 * or is idle waiting for the consumer to do something to move things al
ong | 390 * or is idle waiting for the consumer to do something to move things al
ong |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 563 |
| 567 /** | 564 /** |
| 568 * Sets the HTTP method verb to use for this request. Must be done before | 565 * Sets the HTTP method verb to use for this request. Must be done before |
| 569 * request has started. | 566 * request has started. |
| 570 * | 567 * |
| 571 * <p>The default when this method is not called is "GET" if the request has | 568 * <p>The default when this method is not called is "GET" if the request has |
| 572 * no body or "POST" if it does. | 569 * no body or "POST" if it does. |
| 573 * | 570 * |
| 574 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". | 571 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". |
| 575 * @deprecated Use {@link Builder#setHttpMethod}. | 572 * @deprecated Use {@link Builder#setHttpMethod}. |
| 573 * @hide |
| 576 */ | 574 */ |
| 577 @Deprecated public void setHttpMethod(String method); | 575 @Deprecated public void setHttpMethod(String method); |
| 578 | 576 |
| 579 /** | 577 /** |
| 580 * Adds a request header. Must be done before request has started. | 578 * Adds a request header. Must be done before request has started. |
| 581 * | 579 * |
| 582 * @param header header name. | 580 * @param header header name. |
| 583 * @param value header value. | 581 * @param value header value. |
| 584 * @deprecated Use {@link Builder#setPriority}. | 582 * @deprecated Use {@link Builder#setPriority}. |
| 583 * @hide |
| 585 */ | 584 */ |
| 586 @Deprecated public void addHeader(String header, String value); | 585 @Deprecated public void addHeader(String header, String value); |
| 587 | 586 |
| 588 /** | 587 /** |
| 589 * Sets upload data provider. Must be done before request has started. May o
nly be | 588 * Sets upload data provider. Must be done before request has started. May o
nly be |
| 590 * invoked once per request. Switches method to "POST" if not explicitly | 589 * invoked once per request. Switches method to "POST" if not explicitly |
| 591 * set. Starting the request will throw an exception if a Content-Type | 590 * set. Starting the request will throw an exception if a Content-Type |
| 592 * header is not set. | 591 * header is not set. |
| 593 * | 592 * |
| 594 * @param uploadDataProvider responsible for providing the upload data. | 593 * @param uploadDataProvider responsible for providing the upload data. |
| 595 * @param executor All {@code uploadDataProvider} methods will be invoked | 594 * @param executor All {@code uploadDataProvider} methods will be invoked |
| 596 * using this {@code Executor}. May optionally be the same | 595 * using this {@code Executor}. May optionally be the same |
| 597 * {@code Executor} the request itself is using. | 596 * {@code Executor} the request itself is using. |
| 598 * @deprecated Use {@link Builder#setUploadDataProvider}. | 597 * @deprecated Use {@link Builder#setUploadDataProvider}. |
| 598 * @hide |
| 599 */ | 599 */ |
| 600 @Deprecated | 600 @Deprecated |
| 601 public void setUploadDataProvider(UploadDataProvider uploadDataProvider, Exe
cutor executor); | 601 public void setUploadDataProvider(UploadDataProvider uploadDataProvider, Exe
cutor executor); |
| 602 | 602 |
| 603 /** | 603 /** |
| 604 * Starts the request, all callbacks go to {@link Callback}. May only be cal
led | 604 * Starts the request, all callbacks go to {@link Callback}. May only be cal
led |
| 605 * once. May not be called if {@link #cancel} has been called. | 605 * once. May not be called if {@link #cancel} has been called. |
| 606 */ | 606 */ |
| 607 public void start(); | 607 public void start(); |
| 608 | 608 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 * finished (completed, canceled, or failed). | 652 * finished (completed, canceled, or failed). |
| 653 * @return {@code true} if the request was successfully started and is now | 653 * @return {@code true} if the request was successfully started and is now |
| 654 * finished (completed, canceled, or failed). | 654 * finished (completed, canceled, or failed). |
| 655 */ | 655 */ |
| 656 public boolean isDone(); | 656 public boolean isDone(); |
| 657 | 657 |
| 658 /** | 658 /** |
| 659 * Disables cache for the request. If context is not set up to use cache, | 659 * Disables cache for the request. If context is not set up to use cache, |
| 660 * this call has no effect. | 660 * this call has no effect. |
| 661 * @deprecated Use {@link Builder#disableCache}. | 661 * @deprecated Use {@link Builder#disableCache}. |
| 662 * @hide |
| 662 */ | 663 */ |
| 663 // TODO(pauljensen): When all callers shifted to Builder.disableCache(), | 664 // TODO(pauljensen): When all callers shifted to Builder.disableCache(), |
| 664 // remove this method and instead add constructor argument and make | 665 // remove this method and instead add constructor argument and make |
| 665 // CronetUrlRequest.mDisableCache final. | 666 // CronetUrlRequest.mDisableCache final. |
| 666 @Deprecated public void disableCache(); | 667 @Deprecated public void disableCache(); |
| 667 | 668 |
| 668 /** | 669 /** |
| 669 * Queries the status of the request. | 670 * Queries the status of the request. |
| 670 * @param listener a {@link StatusListener} that will be invoked with | 671 * @param listener a {@link StatusListener} that will be invoked with |
| 671 * the request's current status. {@code listener} will be invoked | 672 * the request's current status. {@code listener} will be invoked |
| 672 * back on the {@link Executor} passed in when the request was | 673 * back on the {@link Executor} passed in when the request was |
| 673 * created. | 674 * created. |
| 674 */ | 675 */ |
| 675 public void getStatus(final StatusListener listener); | 676 public void getStatus(final StatusListener listener); |
| 676 | 677 |
| 677 // Note: There are deliberately no accessors for the results of the request | 678 // Note: There are deliberately no accessors for the results of the request |
| 678 // here. Having none removes any ambiguity over when they are populated, | 679 // here. Having none removes any ambiguity over when they are populated, |
| 679 // particularly in the redirect case. | 680 // particularly in the redirect case. |
| 680 } | 681 } |
| 681 | 682 |
| OLD | NEW |