Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.net; | |
| 6 | |
| 7 /** | |
| 8 * HTTP request (GET, PUT or POST). | |
| 9 * Note: All methods must be called on the Executor passed in during creation. | |
| 10 */ | |
| 11 | |
| 12 // | |
|
mmenke
2014/09/03 21:19:20
Remove empty comment and blank line.
mef
2014/09/03 21:55:39
Done.
| |
| 13 public abstract interface AsyncUrlRequest { | |
| 14 /** | |
| 15 * More setters go here. They may only be called before start (Maybe | |
| 16 * also allow during redirects). Could optionally instead use arguments | |
| 17 * to URLRequestFactory when creating the request. | |
| 18 */ | |
| 19 | |
| 20 /** | |
| 21 * Sets the HTTP method verb to use for this request. Currently can only be | |
| 22 * "POST" or "PUT". | |
|
mmenke
2014/09/03 21:19:20
I don't think there's any need for these restricti
mef
2014/09/03 21:55:38
Done.
| |
| 23 * | |
| 24 * <p>The default when this method is not called is "GET" if the request has | |
| 25 * no body or "POST" if it does. | |
| 26 * | |
| 27 * @param method Either "POST" or "PUT". | |
| 28 */ | |
| 29 public void setHttpMethod(String method); | |
| 30 | |
| 31 /** | |
| 32 * Adds a request header. Must be done before request has started. | |
| 33 * | |
| 34 * @param header Header name | |
| 35 * @param value Header value | |
| 36 */ | |
| 37 public void addHeader(String header, String value); | |
| 38 | |
| 39 /** | |
| 40 * Starts the request, all callbacks go to listener. | |
| 41 * @param listener | |
| 42 */ | |
| 43 public void start(AsyncUrlRequestListener listener); | |
| 44 | |
| 45 /** | |
| 46 * Can be called at any time. | |
| 47 */ | |
| 48 public void cancel(); | |
| 49 | |
| 50 /** | |
| 51 * | |
| 52 * @return {boolean} true if the request has been cancelled by the embedder. | |
|
mmenke
2014/09/03 21:19:20
nit: Looks like I was wrong about using the {}
mmenke
2014/09/03 21:19:20
If it returns true for errors, it should be rename
mef
2014/09/03 21:55:38
Done.
mef
2014/09/03 21:55:39
Acknowledged.
| |
| 53 * TBD(mmenke): False in all other cases (Including errors). | |
| 54 */ | |
| 55 public boolean isCanceled(); | |
| 56 | |
| 57 /** | |
| 58 * Can be called at any time, but the request may continue behind the | |
| 59 * scenes, depending on when it's called. None of the listener's methods | |
| 60 * will be called while paused, until and unless the request is resumed. | |
| 61 * (Note: This allows us to have more than one ByteBuffer in flight, | |
| 62 * if we want, as well as allow pausing at any point). | |
| 63 * | |
| 64 * TBD: May need different pause behavior. | |
| 65 */ | |
| 66 public void pause(); | |
| 67 | |
| 68 /** | |
| 69 * Returns True if paused. False if not paused or is cancelled. | |
| 70 * @return | |
| 71 */ | |
| 72 public boolean isPaused(); | |
| 73 | |
| 74 /** | |
| 75 * When resuming, any pending callback to the listener will be called | |
| 76 * asynchronously. | |
| 77 */ | |
| 78 public void resume(); | |
| 79 | |
| 80 /** | |
| 81 * Note: There are deliberately no accessors for the results of the request | |
| 82 * here. Having none removes any ambiguity over when they are populated, | |
| 83 * particularly in the redirect case. | |
| 84 */ | |
| 85 } | |
| 86 | |
| OLD | NEW |