Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/impl/CronetEngineBase.java

Issue 2339223002: Cronet API Refactoring (Closed)
Patch Set: Rebase & Conflict Resolution Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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, @RequestPriority int priority, Collection<Object> requestAnnotations,
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 protected abstract ExperimentalBidirectionalStream createBidirectionalStream (String url,
81 BidirectionalStream.Callback callback, Executor executor, String htt pMethod,
82 List<Map.Entry<String, String>> requestHeaders, @StreamPriority int priority,
83 boolean delayRequestHeadersUntilFirstFlush, Collection<Object> reque stAnnotations);
84
85 @Override
86 public ExperimentalUrlRequest.Builder newUrlRequestBuilder(
87 String url, UrlRequest.Callback callback, Executor executor) {
88 return new UrlRequestBuilderImpl(url, callback, executor, this);
89 }
90
91 @IntDef({
92 REQUEST_PRIORITY_IDLE, REQUEST_PRIORITY_LOWEST, REQUEST_PRIORITY_LOW ,
93 REQUEST_PRIORITY_MEDIUM, REQUEST_PRIORITY_HIGHEST,
94 })
95 @Retention(RetentionPolicy.SOURCE)
96 public @interface RequestPriority {}
97
98 @IntDef({
99 BidirectionalStream.Builder.STREAM_PRIORITY_IDLE,
100 BidirectionalStream.Builder.STREAM_PRIORITY_LOWEST,
101 BidirectionalStream.Builder.STREAM_PRIORITY_LOW,
102 BidirectionalStream.Builder.STREAM_PRIORITY_MEDIUM,
103 BidirectionalStream.Builder.STREAM_PRIORITY_HIGHEST,
104 })
105 @Retention(RetentionPolicy.SOURCE)
106 public @interface StreamPriority {}
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698