| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 * @param info Response information. May be {@code null} if no response
was | 368 * @param info Response information. May be {@code null} if no response
was |
| 371 * received. | 369 * received. |
| 372 */ | 370 */ |
| 373 public void onCanceled(UrlRequest request, UrlResponseInfo info) {} | 371 public void onCanceled(UrlRequest request, UrlResponseInfo info) {} |
| 374 } | 372 } |
| 375 | 373 |
| 376 /** | 374 /** |
| 377 * Request status values returned by {@link #getStatus}. | 375 * Request status values returned by {@link #getStatus}. |
| 378 */ | 376 */ |
| 379 public static class Status { | 377 public static class Status { |
| 380 /** @deprecated not really deprecated but hidden. */ | 378 /** @hide */ |
| 381 @IntDef({ | 379 @IntDef({ |
| 382 INVALID, IDLE, WAITING_FOR_STALLED_SOCKET_POOL, WAITING_FOR_AVAI
LABLE_SOCKET, | 380 INVALID, IDLE, WAITING_FOR_STALLED_SOCKET_POOL, WAITING_FOR_AVAI
LABLE_SOCKET, |
| 383 WAITING_FOR_DELEGATE, WAITING_FOR_CACHE, DOWNLOADING_PROXY_SCRIP
T, | 381 WAITING_FOR_DELEGATE, WAITING_FOR_CACHE, DOWNLOADING_PROXY_SCRIP
T, |
| 384 RESOLVING_PROXY_FOR_URL, RESOLVING_HOST_IN_PROXY_SCRIPT, ESTABLI
SHING_PROXY_TUNNEL, | 382 RESOLVING_PROXY_FOR_URL, RESOLVING_HOST_IN_PROXY_SCRIPT, ESTABLI
SHING_PROXY_TUNNEL, |
| 385 RESOLVING_HOST, CONNECTING, SSL_HANDSHAKE, SENDING_REQUEST, WAIT
ING_FOR_RESPONSE, | 383 RESOLVING_HOST, CONNECTING, SSL_HANDSHAKE, SENDING_REQUEST, WAIT
ING_FOR_RESPONSE, |
| 386 READING_RESPONSE, | 384 READING_RESPONSE, |
| 387 }) | 385 }) |
| 388 @Retention(RetentionPolicy.SOURCE) | 386 @Retention(RetentionPolicy.SOURCE) |
| 389 @SuppressWarnings("DepAnn") | |
| 390 public @interface StatusValues {} | 387 public @interface StatusValues {} |
| 391 | 388 |
| 392 /** | 389 /** |
| 393 * This state indicates that the request is completed, canceled, or is n
ot | 390 * This state indicates that the request is completed, canceled, or is n
ot |
| 394 * started. | 391 * started. |
| 395 */ | 392 */ |
| 396 public static final int INVALID = -1; | 393 public static final int INVALID = -1; |
| 397 /** | 394 /** |
| 398 * This state corresponds to a resource load that has either not yet beg
un | 395 * This state corresponds to a resource load that has either not yet beg
un |
| 399 * or is idle waiting for the consumer to do something to move things al
ong | 396 * 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... |
| 572 | 569 |
| 573 /** | 570 /** |
| 574 * Sets the HTTP method verb to use for this request. Must be done before | 571 * Sets the HTTP method verb to use for this request. Must be done before |
| 575 * request has started. | 572 * request has started. |
| 576 * | 573 * |
| 577 * <p>The default when this method is not called is "GET" if the request has | 574 * <p>The default when this method is not called is "GET" if the request has |
| 578 * no body or "POST" if it does. | 575 * no body or "POST" if it does. |
| 579 * | 576 * |
| 580 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". | 577 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". |
| 581 * @deprecated Use {@link Builder#setHttpMethod}. | 578 * @deprecated Use {@link Builder#setHttpMethod}. |
| 579 * @hide |
| 582 */ | 580 */ |
| 583 @Deprecated public void setHttpMethod(String method); | 581 @Deprecated public void setHttpMethod(String method); |
| 584 | 582 |
| 585 /** | 583 /** |
| 586 * Adds a request header. Must be done before request has started. | 584 * Adds a request header. Must be done before request has started. |
| 587 * | 585 * |
| 588 * @param header header name. | 586 * @param header header name. |
| 589 * @param value header value. | 587 * @param value header value. |
| 590 * @deprecated Use {@link Builder#setPriority}. | 588 * @deprecated Use {@link Builder#setPriority}. |
| 589 * @hide |
| 591 */ | 590 */ |
| 592 @Deprecated public void addHeader(String header, String value); | 591 @Deprecated public void addHeader(String header, String value); |
| 593 | 592 |
| 594 /** | 593 /** |
| 595 * Sets upload data provider. Must be done before request has started. May o
nly be | 594 * Sets upload data provider. Must be done before request has started. May o
nly be |
| 596 * invoked once per request. Switches method to "POST" if not explicitly | 595 * invoked once per request. Switches method to "POST" if not explicitly |
| 597 * set. Starting the request will throw an exception if a Content-Type | 596 * set. Starting the request will throw an exception if a Content-Type |
| 598 * header is not set. | 597 * header is not set. |
| 599 * | 598 * |
| 600 * @param uploadDataProvider responsible for providing the upload data. | 599 * @param uploadDataProvider responsible for providing the upload data. |
| 601 * @param executor All {@code uploadDataProvider} methods will be invoked | 600 * @param executor All {@code uploadDataProvider} methods will be invoked |
| 602 * using this {@code Executor}. May optionally be the same | 601 * using this {@code Executor}. May optionally be the same |
| 603 * {@code Executor} the request itself is using. | 602 * {@code Executor} the request itself is using. |
| 604 * @deprecated Use {@link Builder#setUploadDataProvider}. | 603 * @deprecated Use {@link Builder#setUploadDataProvider}. |
| 604 * @hide |
| 605 */ | 605 */ |
| 606 @Deprecated | 606 @Deprecated |
| 607 public void setUploadDataProvider(UploadDataProvider uploadDataProvider, Exe
cutor executor); | 607 public void setUploadDataProvider(UploadDataProvider uploadDataProvider, Exe
cutor executor); |
| 608 | 608 |
| 609 /** | 609 /** |
| 610 * Starts the request, all callbacks go to {@link Callback}. May only be cal
led | 610 * Starts the request, all callbacks go to {@link Callback}. May only be cal
led |
| 611 * once. May not be called if {@link #cancel} has been called. | 611 * once. May not be called if {@link #cancel} has been called. |
| 612 */ | 612 */ |
| 613 public void start(); | 613 public void start(); |
| 614 | 614 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 * finished (completed, canceled, or failed). | 658 * finished (completed, canceled, or failed). |
| 659 * @return {@code true} if the request was successfully started and is now | 659 * @return {@code true} if the request was successfully started and is now |
| 660 * finished (completed, canceled, or failed). | 660 * finished (completed, canceled, or failed). |
| 661 */ | 661 */ |
| 662 public boolean isDone(); | 662 public boolean isDone(); |
| 663 | 663 |
| 664 /** | 664 /** |
| 665 * Disables cache for the request. If context is not set up to use cache, | 665 * Disables cache for the request. If context is not set up to use cache, |
| 666 * this call has no effect. | 666 * this call has no effect. |
| 667 * @deprecated Use {@link Builder#disableCache}. | 667 * @deprecated Use {@link Builder#disableCache}. |
| 668 * @hide |
| 668 */ | 669 */ |
| 669 // TODO(pauljensen): When all callers shifted to Builder.disableCache(), | 670 // TODO(pauljensen): When all callers shifted to Builder.disableCache(), |
| 670 // remove this method and instead add constructor argument and make | 671 // remove this method and instead add constructor argument and make |
| 671 // CronetUrlRequest.mDisableCache final. | 672 // CronetUrlRequest.mDisableCache final. |
| 672 @Deprecated public void disableCache(); | 673 @Deprecated public void disableCache(); |
| 673 | 674 |
| 674 /** | 675 /** |
| 675 * Queries the status of the request. | 676 * Queries the status of the request. |
| 676 * @param listener a {@link StatusListener} that will be invoked with | 677 * @param listener a {@link StatusListener} that will be invoked with |
| 677 * the request's current status. {@code listener} will be invoked | 678 * the request's current status. {@code listener} will be invoked |
| 678 * back on the {@link Executor} passed in when the request was | 679 * back on the {@link Executor} passed in when the request was |
| 679 * created. | 680 * created. |
| 680 */ | 681 */ |
| 681 public void getStatus(final StatusListener listener); | 682 public void getStatus(final StatusListener listener); |
| 682 | 683 |
| 683 // Note: There are deliberately no accessors for the results of the request | 684 // Note: There are deliberately no accessors for the results of the request |
| 684 // here. Having none removes any ambiguity over when they are populated, | 685 // here. Having none removes any ambiguity over when they are populated, |
| 685 // particularly in the redirect case. | 686 // particularly in the redirect case. |
| 686 } | 687 } |
| 687 | 688 |
| OLD | NEW |