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 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 org.chromium.net.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 org.chromium.net.UrlRequest} object. All callbacks will | |
xunjieli
2015/06/05 15:29:50
nit: I think if we are refering to the class in th
mkirsche
2015/06/05 15:43:55
Done.
| |
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 UrlRequest.java | |
xunjieli
2015/06/05 15:29:50
nit: Use "{@link UrlRequest}"
mkirsche
2015/06/05 15:43:55
Done.
| |
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 Loading... | |
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 } |
OLD | NEW |