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

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

Issue 1159343003: Expose Cronet Url requests with priorities. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added period Created 5 years, 6 months 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
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import android.content.Context; 7 import android.content.Context;
8 import android.util.Log; 8 import android.util.Log;
9 9
10 import java.lang.reflect.Constructor; 10 import java.lang.reflect.Constructor;
11 import java.util.concurrent.Executor; 11 import java.util.concurrent.Executor;
12 12
13 /** 13 /**
14 * A context for {@link UrlRequest}'s, which uses the best HTTP stack 14 * A context for {@link UrlRequest}'s, which uses the best HTTP stack
15 * available on the current platform. 15 * available on the current platform.
16 */ 16 */
17 public abstract class UrlRequestContext { 17 public abstract class UrlRequestContext {
18 private static final String TAG = "UrlRequestFactory"; 18 private static final String TAG = "UrlRequestFactory";
19 private static final String CRONET_URL_REQUEST_CONTEXT = 19 private static final String CRONET_URL_REQUEST_CONTEXT =
20 "org.chromium.net.CronetUrlRequestContext"; 20 "org.chromium.net.CronetUrlRequestContext";
21 21
22 /** 22 /**
23 * Creates an UrlRequest object. All UrlRequest functions must 23 * Creates a {@link UrlRequest} object. All callbacks will
24 * be called on the Executor's thread, and all callbacks will be called 24 * be called on the Executor's thread. Executor must not run tasks on the
25 * on the Executor's thread as well. Executor must not run tasks on the
26 * current thread to prevent network jank and exception during shutdown. 25 * current thread to prevent network jank and exception during shutdown.
27 * 26 *
28 * createRequest itself may be called on any thread.
29 * @param url URL for the request. 27 * @param url URL for the request.
30 * @param listener Callback interface that gets called on different events. 28 * @param listener Callback interface that gets called on different events.
31 * @param executor Executor on which all callbacks will be called. 29 * @param executor Executor on which all callbacks will be called.
32 * @return new request. 30 * @return new request.
33 */ 31 */
34 public abstract UrlRequest createRequest(String url, 32 public abstract UrlRequest createRequest(String url,
35 UrlRequestListener listener, Executor executor); 33 UrlRequestListener listener, Executor executor);
36 34
37 /** 35 /**
36 * Creates a {@link UrlRequest} object. All callbacks will
37 * be called on the Executor's thread. Executor must not run tasks on the
38 * current thread to prevent network jank and exception during shutdown.
39 *
40 * @param url URL for the request.
41 * @param listener Callback interface that gets called on different events.
42 * @param executor Executor on which all callbacks will be called.
43 * @param priority Priority of the request which should be one of the
44 REQUEST_PRIORITY_* values in {@link UrlRequest}.
45 * @return new request.
46 */
47 public abstract UrlRequest createRequest(String url,
48 UrlRequestListener listener, Executor executor, int priority);
49
50 /**
38 * @return true if the context is enabled. 51 * @return true if the context is enabled.
39 */ 52 */
40 public abstract boolean isEnabled(); 53 public abstract boolean isEnabled();
41 54
42 /** 55 /**
43 * @return a human-readable version string of the context. 56 * @return a human-readable version string of the context.
44 */ 57 */
45 public abstract String getVersionString(); 58 public abstract String getVersionString();
46 59
47 /** 60 /**
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } catch (ClassNotFoundException e) { 133 } catch (ClassNotFoundException e) {
121 // Leave as null. 134 // Leave as null.
122 } catch (Exception e) { 135 } catch (Exception e) {
123 throw new IllegalStateException( 136 throw new IllegalStateException(
124 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT, 137 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT,
125 e); 138 e);
126 } 139 }
127 return urlRequestContext; 140 return urlRequestContext;
128 } 141 }
129 } 142 }
OLDNEW
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698