Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 package org.chromium.net.impl; | |
| 5 | |
| 6 import android.support.annotation.IntDef; | |
| 7 | |
| 8 import static org.chromium.net.UrlRequest.Builder.REQUEST_PRIORITY_HIGHEST; | |
| 9 import static org.chromium.net.UrlRequest.Builder.REQUEST_PRIORITY_IDLE; | |
| 10 import static org.chromium.net.UrlRequest.Builder.REQUEST_PRIORITY_LOW; | |
| 11 import static org.chromium.net.UrlRequest.Builder.REQUEST_PRIORITY_LOWEST; | |
| 12 import static org.chromium.net.UrlRequest.Builder.REQUEST_PRIORITY_MEDIUM; | |
| 13 | |
| 14 import org.chromium.net.BidirectionalStream; | |
| 15 import org.chromium.net.ExperimentalBidirectionalStream; | |
| 16 import org.chromium.net.ExperimentalCronetEngine; | |
| 17 import org.chromium.net.ExperimentalUrlRequest; | |
| 18 import org.chromium.net.UrlRequest; | |
| 19 | |
| 20 import java.lang.annotation.Retention; | |
| 21 import java.lang.annotation.RetentionPolicy; | |
| 22 import java.net.URL; | |
| 23 import java.util.Collection; | |
| 24 import java.util.List; | |
| 25 import java.util.Map; | |
| 26 import java.util.concurrent.Executor; | |
| 27 | |
| 28 /** | |
| 29 * Base class of {@link CronetUrlRequestContext} and {@link JavaCronetEngine} th at contains | |
| 30 * shared logic. | |
| 31 */ | |
| 32 public abstract class CronetEngineBase extends ExperimentalCronetEngine { | |
| 33 /** | |
| 34 * Creates a {@link UrlRequest} object. All callbacks will | |
| 35 * be called on {@code executor}'s thread. {@code executor} must not run | |
| 36 * tasks on the current thread to prevent blocking networking operations | |
| 37 * and causing exceptions during shutdown. | |
| 38 * | |
| 39 * @param url {@link URL} for the request. | |
| 40 * @param callback callback object that gets invoked on different events. | |
| 41 * @param executor {@link Executor} on which all callbacks will be invoked. | |
| 42 * @param priority priority of the request which should be one of the | |
| 43 * {@link UrlRequest.Builder#REQUEST_PRIORITY_IDLE REQUEST_PRIORITY_ *} | |
| 44 * values. | |
| 45 * @param requestAnnotations Objects to pass on to | |
| 46 * {@link org.chromium.net.RequestFinishedInfo.Listener}. | |
| 47 * @param disableCache disables cache for the request. | |
| 48 * If context is not set up to use cache this param has no effect. | |
| 49 * @param disableConnectionMigration disables connection migration for this | |
| 50 * request if it is enabled for the session. | |
| 51 * @param allowDirectExecutor whether executors used by this request are per mitted | |
| 52 * to execute submitted tasks inline. | |
| 53 * @return new request. | |
| 54 */ | |
| 55 protected abstract UrlRequestBase createRequest(String url, UrlRequest.Callb ack callback, | |
| 56 Executor executor, int priority, Collection<Object> requestAnnotatio ns, | |
|
pauljensen
2016/10/03 15:22:37
@RequestPriority?
kapishnikov
2016/10/03 23:49:28
I am actually getting a lint error if I do so:
--
kapishnikov
2016/10/05 17:16:31
Done but had to add @SuppressLint("WrongConstant")
| |
| 57 boolean disableCache, boolean disableConnectionMigration, boolean al lowDirectExecutor); | |
| 58 | |
| 59 /** | |
| 60 * Creates a {@link BidirectionalStream} object. {@code callback} methods wi ll | |
| 61 * be invoked on {@code executor}. {@code executor} must not run | |
| 62 * tasks on the current thread to prevent blocking networking operations | |
| 63 * and causing exceptions during shutdown. | |
| 64 * | |
| 65 * @param url the URL for the stream | |
| 66 * @param callback the object whose methods get invoked upon different event s | |
| 67 * @param executor the {@link Executor} on which all callbacks will be calle d | |
| 68 * @param httpMethod the HTTP method to use for the stream | |
| 69 * @param requestHeaders the list of request headers | |
| 70 * @param priority priority of the stream which should be one of the | |
| 71 * {@link BidirectionalStream.Builder#STREAM_PRIORITY_IDLE STREAM_PR IORITY_*} | |
| 72 * values. | |
| 73 * @param delayRequestHeadersUntilFirstFlush whether to delay sending reques t | |
| 74 * headers until flush() is called, and try to combine them | |
| 75 * with the next data frame. | |
| 76 * @param requestAnnotations Objects to pass on to | |
| 77 * {@link org.chromium.net.RequestFinishedInfo.Listener}. | |
| 78 * @return a new stream. | |
| 79 */ | |
| 80 public abstract ExperimentalBidirectionalStream createBidirectionalStream(St ring url, | |
|
pauljensen
2016/10/03 15:22:37
how come this is public but createRequest() is pro
kapishnikov
2016/10/03 23:49:28
Good catch. Changed to 'protected'.
| |
| 81 BidirectionalStream.Callback callback, Executor executor, String htt pMethod, | |
| 82 List<Map.Entry<String, String>> requestHeaders, | |
| 83 @BidirectionalStreamBuilderImpl.StreamPriority int priority, | |
| 84 boolean delayRequestHeadersUntilFirstFlush, Collection<Object> reque stAnnotations); | |
| 85 | |
| 86 /** | |
| 87 * @return {@code true} if the engine is enabled. | |
| 88 */ | |
| 89 public abstract boolean isEnabled(); | |
|
pauljensen
2016/10/03 15:22:37
is this used anymore? can we get rid of it and th
kapishnikov
2016/10/03 23:49:28
Another good catch. It is not used anymore.
| |
| 90 | |
| 91 @Override | |
| 92 public ExperimentalUrlRequest.Builder newUrlRequestBuilder( | |
| 93 String url, UrlRequest.Callback callback, Executor executor) { | |
| 94 return new UrlRequestBuilderImpl(url, callback, executor, this); | |
| 95 } | |
| 96 | |
| 97 @IntDef({ | |
| 98 REQUEST_PRIORITY_IDLE, REQUEST_PRIORITY_LOWEST, REQUEST_PRIORITY_LOW , | |
| 99 REQUEST_PRIORITY_MEDIUM, REQUEST_PRIORITY_HIGHEST, | |
| 100 }) | |
| 101 @Retention(RetentionPolicy.SOURCE) | |
| 102 public @interface RequestPriority {} | |
| 103 } | |
| OLD | NEW |