| 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 /** @hide */ | 143 /** @deprecated not really deprecated but hidden. */ |
| 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") |
| 149 public @interface RequestPriority {} | 150 public @interface RequestPriority {} |
| 150 | 151 |
| 151 /** | 152 /** |
| 152 * Lowest request priority. Passed to {@link #setPriority}. | 153 * Lowest request priority. Passed to {@link #setPriority}. |
| 153 */ | 154 */ |
| 154 public static final int REQUEST_PRIORITY_IDLE = 0; | 155 public static final int REQUEST_PRIORITY_IDLE = 0; |
| 155 /** | 156 /** |
| 156 * Very low request priority. Passed to {@link #setPriority}. | 157 * Very low request priority. Passed to {@link #setPriority}. |
| 157 */ | 158 */ |
| 158 public static final int REQUEST_PRIORITY_LOWEST = 1; | 159 public static final int REQUEST_PRIORITY_LOWEST = 1; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 215 |
| 215 /** | 216 /** |
| 216 * Associates the annotation object with this request. May add more than
one. | 217 * Associates the annotation object with this request. May add more than
one. |
| 217 * Passed through to a {@link CronetEngine.RequestFinishedListener}, | 218 * Passed through to a {@link CronetEngine.RequestFinishedListener}, |
| 218 * see {@link CronetEngine.UrlRequestInfo#getAnnotations}. | 219 * see {@link CronetEngine.UrlRequestInfo#getAnnotations}. |
| 219 * | 220 * |
| 220 * @param annotation an object to pass on to the | 221 * @param annotation an object to pass on to the |
| 221 * {@link CronetEngine.RequestFinishedListener} with a {@link CronetEngi
ne.UrlRequestInfo}. | 222 * {@link CronetEngine.RequestFinishedListener} with a {@link CronetEngi
ne.UrlRequestInfo}. |
| 222 * @return the builder to facilitate chaining. | 223 * @return the builder to facilitate chaining. |
| 223 * | 224 * |
| 224 * @hide as it's a prototype. | 225 * @deprecated not really deprecated but hidden for now as it's a protot
ype. |
| 225 */ | 226 */ |
| 227 @Deprecated |
| 226 public Builder addRequestAnnotation(Object annotation) { | 228 public Builder addRequestAnnotation(Object annotation) { |
| 227 if (annotation == null) { | 229 if (annotation == null) { |
| 228 throw new NullPointerException("Invalid metrics annotation."); | 230 throw new NullPointerException("Invalid metrics annotation."); |
| 229 } | 231 } |
| 230 if (mRequestAnnotations.isEmpty()) { | 232 if (mRequestAnnotations.isEmpty()) { |
| 231 mRequestAnnotations = new ArrayList<Object>(); | 233 mRequestAnnotations = new ArrayList<Object>(); |
| 232 } | 234 } |
| 233 mRequestAnnotations.add(annotation); | 235 mRequestAnnotations.add(annotation); |
| 234 return this; | 236 return this; |
| 235 } | 237 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 * @param info Response information. May be {@code null} if no response
was | 370 * @param info Response information. May be {@code null} if no response
was |
| 369 * received. | 371 * received. |
| 370 */ | 372 */ |
| 371 public void onCanceled(UrlRequest request, UrlResponseInfo info) {} | 373 public void onCanceled(UrlRequest request, UrlResponseInfo info) {} |
| 372 } | 374 } |
| 373 | 375 |
| 374 /** | 376 /** |
| 375 * Request status values returned by {@link #getStatus}. | 377 * Request status values returned by {@link #getStatus}. |
| 376 */ | 378 */ |
| 377 public static class Status { | 379 public static class Status { |
| 378 /** @hide */ | 380 /** @deprecated not really deprecated but hidden. */ |
| 379 @IntDef({ | 381 @IntDef({ |
| 380 INVALID, IDLE, WAITING_FOR_STALLED_SOCKET_POOL, WAITING_FOR_AVAI
LABLE_SOCKET, | 382 INVALID, IDLE, WAITING_FOR_STALLED_SOCKET_POOL, WAITING_FOR_AVAI
LABLE_SOCKET, |
| 381 WAITING_FOR_DELEGATE, WAITING_FOR_CACHE, DOWNLOADING_PROXY_SCRIP
T, | 383 WAITING_FOR_DELEGATE, WAITING_FOR_CACHE, DOWNLOADING_PROXY_SCRIP
T, |
| 382 RESOLVING_PROXY_FOR_URL, RESOLVING_HOST_IN_PROXY_SCRIPT, ESTABLI
SHING_PROXY_TUNNEL, | 384 RESOLVING_PROXY_FOR_URL, RESOLVING_HOST_IN_PROXY_SCRIPT, ESTABLI
SHING_PROXY_TUNNEL, |
| 383 RESOLVING_HOST, CONNECTING, SSL_HANDSHAKE, SENDING_REQUEST, WAIT
ING_FOR_RESPONSE, | 385 RESOLVING_HOST, CONNECTING, SSL_HANDSHAKE, SENDING_REQUEST, WAIT
ING_FOR_RESPONSE, |
| 384 READING_RESPONSE, | 386 READING_RESPONSE, |
| 385 }) | 387 }) |
| 386 @Retention(RetentionPolicy.SOURCE) | 388 @Retention(RetentionPolicy.SOURCE) |
| 389 @SuppressWarnings("DepAnn") |
| 387 public @interface StatusValues {} | 390 public @interface StatusValues {} |
| 388 | 391 |
| 389 /** | 392 /** |
| 390 * This state indicates that the request is completed, canceled, or is n
ot | 393 * This state indicates that the request is completed, canceled, or is n
ot |
| 391 * started. | 394 * started. |
| 392 */ | 395 */ |
| 393 public static final int INVALID = -1; | 396 public static final int INVALID = -1; |
| 394 /** | 397 /** |
| 395 * This state corresponds to a resource load that has either not yet beg
un | 398 * This state corresponds to a resource load that has either not yet beg
un |
| 396 * or is idle waiting for the consumer to do something to move things al
ong | 399 * 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... |
| 569 | 572 |
| 570 /** | 573 /** |
| 571 * Sets the HTTP method verb to use for this request. Must be done before | 574 * Sets the HTTP method verb to use for this request. Must be done before |
| 572 * request has started. | 575 * request has started. |
| 573 * | 576 * |
| 574 * <p>The default when this method is not called is "GET" if the request has | 577 * <p>The default when this method is not called is "GET" if the request has |
| 575 * no body or "POST" if it does. | 578 * no body or "POST" if it does. |
| 576 * | 579 * |
| 577 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". | 580 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". |
| 578 * @deprecated Use {@link Builder#setHttpMethod}. | 581 * @deprecated Use {@link Builder#setHttpMethod}. |
| 579 * @hide | |
| 580 */ | 582 */ |
| 581 @Deprecated public void setHttpMethod(String method); | 583 @Deprecated public void setHttpMethod(String method); |
| 582 | 584 |
| 583 /** | 585 /** |
| 584 * Adds a request header. Must be done before request has started. | 586 * Adds a request header. Must be done before request has started. |
| 585 * | 587 * |
| 586 * @param header header name. | 588 * @param header header name. |
| 587 * @param value header value. | 589 * @param value header value. |
| 588 * @deprecated Use {@link Builder#setPriority}. | 590 * @deprecated Use {@link Builder#setPriority}. |
| 589 * @hide | |
| 590 */ | 591 */ |
| 591 @Deprecated public void addHeader(String header, String value); | 592 @Deprecated public void addHeader(String header, String value); |
| 592 | 593 |
| 593 /** | 594 /** |
| 594 * Sets upload data provider. Must be done before request has started. May o
nly be | 595 * Sets upload data provider. Must be done before request has started. May o
nly be |
| 595 * invoked once per request. Switches method to "POST" if not explicitly | 596 * invoked once per request. Switches method to "POST" if not explicitly |
| 596 * set. Starting the request will throw an exception if a Content-Type | 597 * set. Starting the request will throw an exception if a Content-Type |
| 597 * header is not set. | 598 * header is not set. |
| 598 * | 599 * |
| 599 * @param uploadDataProvider responsible for providing the upload data. | 600 * @param uploadDataProvider responsible for providing the upload data. |
| 600 * @param executor All {@code uploadDataProvider} methods will be invoked | 601 * @param executor All {@code uploadDataProvider} methods will be invoked |
| 601 * using this {@code Executor}. May optionally be the same | 602 * using this {@code Executor}. May optionally be the same |
| 602 * {@code Executor} the request itself is using. | 603 * {@code Executor} the request itself is using. |
| 603 * @deprecated Use {@link Builder#setUploadDataProvider}. | 604 * @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 | |
| 669 */ | 668 */ |
| 670 // TODO(pauljensen): When all callers shifted to Builder.disableCache(), | 669 // TODO(pauljensen): When all callers shifted to Builder.disableCache(), |
| 671 // remove this method and instead add constructor argument and make | 670 // remove this method and instead add constructor argument and make |
| 672 // CronetUrlRequest.mDisableCache final. | 671 // CronetUrlRequest.mDisableCache final. |
| 673 @Deprecated public void disableCache(); | 672 @Deprecated public void disableCache(); |
| 674 | 673 |
| 675 /** | 674 /** |
| 676 * Queries the status of the request. | 675 * Queries the status of the request. |
| 677 * @param listener a {@link StatusListener} that will be invoked with | 676 * @param listener a {@link StatusListener} that will be invoked with |
| 678 * the request's current status. {@code listener} will be invoked | 677 * the request's current status. {@code listener} will be invoked |
| 679 * back on the {@link Executor} passed in when the request was | 678 * back on the {@link Executor} passed in when the request was |
| 680 * created. | 679 * created. |
| 681 */ | 680 */ |
| 682 public void getStatus(final StatusListener listener); | 681 public void getStatus(final StatusListener listener); |
| 683 | 682 |
| 684 // Note: There are deliberately no accessors for the results of the request | 683 // Note: There are deliberately no accessors for the results of the request |
| 685 // here. Having none removes any ambiguity over when they are populated, | 684 // here. Having none removes any ambiguity over when they are populated, |
| 686 // particularly in the redirect case. | 685 // particularly in the redirect case. |
| 687 } | 686 } |
| 688 | 687 |
| OLD | NEW |