| 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 /** | 7 /** |
| 8 * HTTP request (GET, PUT or POST). | 8 * HTTP request (GET, PUT or POST). |
| 9 * Note: All methods must be called on the Executor passed in during creation. | 9 * Note: All methods must be called on the Executor passed in during creation. |
| 10 */ | 10 */ |
| 11 public interface UrlRequest { | 11 public interface UrlRequest { |
| 12 public static final int REQUEST_PRIORITY_IDLE = 0; |
| 13 |
| 14 public static final int REQUEST_PRIORITY_LOWEST = 1; |
| 15 |
| 16 public static final int REQUEST_PRIORITY_LOW = 2; |
| 17 |
| 18 public static final int REQUEST_PRIORITY_MEDIUM = 3; |
| 19 |
| 20 public static final int REQUEST_PRIORITY_HIGHEST = 4; |
| 21 |
| 12 /** | 22 /** |
| 13 * More setters go here. They may only be called before start (Maybe | 23 * More setters go here. They may only be called before start (Maybe |
| 14 * also allow during redirects). Could optionally instead use arguments | 24 * also allow during redirects). Could optionally instead use arguments |
| 15 * to URLRequestFactory when creating the request. | 25 * to URLRequestFactory when creating the request. |
| 16 */ | 26 */ |
| 17 | 27 |
| 18 /** | 28 /** |
| 19 * Sets the HTTP method verb to use for this request. | 29 * Sets the HTTP method verb to use for this request. Must be done before |
| 30 * request has started. |
| 20 * | 31 * |
| 21 * <p>The default when this method is not called is "GET" if the request has | 32 * <p>The default when this method is not called is "GET" if the request has |
| 22 * no body or "POST" if it does. | 33 * no body or "POST" if it does. |
| 23 * | 34 * |
| 24 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". | 35 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". |
| 25 */ | 36 */ |
| 26 public void setHttpMethod(String method); | 37 public void setHttpMethod(String method); |
| 27 | 38 |
| 28 /** | 39 /** |
| 29 * Adds a request header. Must be done before request has started. | 40 * Adds a request header. Must be done before request has started. |
| 30 * | 41 * |
| 31 * @param header Header name | 42 * @param header Header name |
| 32 * @param value Header value | 43 * @param value Header value |
| 33 */ | 44 */ |
| 34 public void addHeader(String header, String value); | 45 public void addHeader(String header, String value); |
| 35 | 46 |
| 36 /** | 47 /** |
| 37 * Starts the request, all callbacks go to listener. | 48 * Starts the request, all callbacks go to listener. May only be called |
| 38 * @param listener | 49 * once. May not be called if cancel has been called on the request. |
| 39 */ | 50 */ |
| 40 public void start(UrlRequestListener listener); | 51 public void start(); |
| 41 | 52 |
| 42 /** | 53 /** |
| 43 * Can be called at any time. | 54 * Cancels the request. |
| 55 * |
| 56 * Can be called at any time. If the Executor passed to UrlRequest on |
| 57 * construction runs tasks on a single thread, and cancel is called on that |
| 58 * thread, no listener methods will be invoked after cancel is called. |
| 59 * Otherwise, at most one listener method may be made after cancel has |
| 60 * completed. |
| 44 */ | 61 */ |
| 45 public void cancel(); | 62 public void cancel(); |
| 46 | 63 |
| 47 /** | 64 /** |
| 48 * | |
| 49 * @return True if the request has been cancelled by the embedder. | 65 * @return True if the request has been cancelled by the embedder. |
| 50 * TBD(mmenke): False in all other cases (Including errors). | 66 * False in all other cases (Including errors). |
| 51 */ | 67 */ |
| 52 public boolean isCanceled(); | 68 public boolean isCanceled(); |
| 53 | 69 |
| 54 /** | 70 /** |
| 55 * Can be called at any time, but the request may continue behind the | 71 * Can be called at any time, but the request may continue behind the |
| 56 * scenes, depending on when it's called. None of the listener's methods | 72 * scenes, depending on when it's called. None of the listener's methods |
| 57 * will be called while paused, until and unless the request is resumed. | 73 * will be called while paused, until and unless the request is resumed. |
| 58 * (Note: This allows us to have more than one ByteBuffer in flight, | 74 * (Note: This allows us to have more than one ByteBuffer in flight, |
| 59 * if we want, as well as allow pausing at any point). | 75 * if we want, as well as allow pausing at any point). |
| 60 * | 76 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 */ | 90 */ |
| 75 public void resume(); | 91 public void resume(); |
| 76 | 92 |
| 77 /** | 93 /** |
| 78 * Note: There are deliberately no accessors for the results of the request | 94 * Note: There are deliberately no accessors for the results of the request |
| 79 * here. Having none removes any ambiguity over when they are populated, | 95 * here. Having none removes any ambiguity over when they are populated, |
| 80 * particularly in the redirect case. | 96 * particularly in the redirect case. |
| 81 */ | 97 */ |
| 82 } | 98 } |
| 83 | 99 |
| OLD | NEW |