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. |
mmenke
2014/11/06 17:31:29
All of these should mention they may not be called
mef
2014/11/06 22:51:47
Done.
| |
20 * | 30 * |
21 * <p>The default when this method is not called is "GET" if the request has | 31 * <p>The default when this method is not called is "GET" if the request has |
22 * no body or "POST" if it does. | 32 * no body or "POST" if it does. |
23 * | 33 * |
24 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". | 34 * @param method "GET", "HEAD", "DELETE", "POST" or "PUT". |
25 */ | 35 */ |
26 public void setHttpMethod(String method); | 36 public void setHttpMethod(String method); |
27 | 37 |
28 /** | 38 /** |
29 * Adds a request header. Must be done before request has started. | 39 * Adds a request header. Must be done before request has started. |
30 * | 40 * |
31 * @param header Header name | 41 * @param header Header name |
32 * @param value Header value | 42 * @param value Header value |
33 */ | 43 */ |
34 public void addHeader(String header, String value); | 44 public void addHeader(String header, String value); |
35 | 45 |
36 /** | 46 /** |
37 * Starts the request, all callbacks go to listener. | 47 * Starts the request, all callbacks go to listener. |
mmenke
2014/11/06 17:31:29
May only be called once. May not be called if can
mef
2014/11/06 22:51:47
Done.
| |
38 * @param listener | |
39 */ | 48 */ |
40 public void start(UrlRequestListener listener); | 49 public void start(); |
41 | 50 |
42 /** | 51 /** |
43 * Can be called at any time. | 52 * Can be called at any time. |
mmenke
2014/11/06 17:31:29
+"If the Executor passed to UrlRequest on construc
mef
2014/11/06 22:51:47
Done.
| |
44 */ | 53 */ |
45 public void cancel(); | 54 public void cancel(); |
46 | 55 |
47 /** | 56 /** |
48 * | 57 * |
mmenke
2014/11/06 17:31:29
nit: Remove blank line.
mef
2014/11/06 22:51:47
Done.
| |
49 * @return True if the request has been cancelled by the embedder. | 58 * @return True if the request has been cancelled by the embedder. |
50 * TBD(mmenke): False in all other cases (Including errors). | 59 * TBD(mmenke): False in all other cases (Including errors). |
51 */ | 60 */ |
52 public boolean isCanceled(); | 61 public boolean isCanceled(); |
53 | 62 |
54 /** | 63 /** |
55 * Can be called at any time, but the request may continue behind the | 64 * 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 | 65 * 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. | 66 * 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, | 67 * (Note: This allows us to have more than one ByteBuffer in flight, |
(...skipping 15 matching lines...) Expand all Loading... | |
74 */ | 83 */ |
75 public void resume(); | 84 public void resume(); |
76 | 85 |
77 /** | 86 /** |
78 * Note: There are deliberately no accessors for the results of the request | 87 * Note: There are deliberately no accessors for the results of the request |
79 * here. Having none removes any ambiguity over when they are populated, | 88 * here. Having none removes any ambiguity over when they are populated, |
80 * particularly in the redirect case. | 89 * particularly in the redirect case. |
81 */ | 90 */ |
82 } | 91 } |
83 | 92 |
OLD | NEW |