OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.support.annotation.IntDef; | 8 import android.support.annotation.IntDef; |
9 import android.support.annotation.Nullable; | 9 import android.support.annotation.Nullable; |
10 import android.util.Log; | 10 import android.util.Log; |
(...skipping 23 matching lines...) Expand all Loading... | |
34 * An engine to process {@link UrlRequest}s, which uses the best HTTP stack | 34 * An engine to process {@link UrlRequest}s, which uses the best HTTP stack |
35 * available on the current platform. | 35 * available on the current platform. |
36 */ | 36 */ |
37 public abstract class CronetEngine { | 37 public abstract class CronetEngine { |
38 /** | 38 /** |
39 * A builder for {@link CronetEngine}s, which allows runtime configuration o f | 39 * A builder for {@link CronetEngine}s, which allows runtime configuration o f |
40 * {@code CronetEngine}. Configuration options are set on the builder and | 40 * {@code CronetEngine}. Configuration options are set on the builder and |
41 * then {@link #build} is called to create the {@code CronetEngine}. | 41 * then {@link #build} is called to create the {@code CronetEngine}. |
42 */ | 42 */ |
43 public static class Builder { | 43 public static class Builder { |
44 /** | |
45 * A callback for loading the cronet native library. Apps needing to imp lement custom | |
xunjieli
2016/01/22 22:53:15
nit: s/A callback/An interface.
According to go/a
mgersh
2016/01/25 17:31:11
Thanks, that's a useful link. It convinced me to c
| |
46 * library loading logic can implement this interface and pass an instan ce to | |
47 * {@link CronetEngine.Builder.setLibraryLoader()}. For example, this mi ght be required | |
48 * to work around {@code UnsatisfiedLinkError}s caused by flaky installa tion on certain | |
49 * older devices. | |
50 */ | |
51 public static interface CustomLibraryLoader { | |
xunjieli
2016/01/22 22:53:15
Gonna retract my earlier comment. I think LibraryL
mgersh
2016/01/25 17:31:11
Done.
| |
52 /** | |
53 * Load the native library. | |
xunjieli
2016/01/22 22:53:15
nit: s/Load/Loads
mgersh
2016/01/25 17:31:11
Done.
| |
54 * @param libName name of the library to load | |
55 */ | |
56 public void loadLibrary(String libName); | |
57 } | |
58 | |
44 // A hint that a host supports QUIC. | 59 // A hint that a host supports QUIC. |
45 static class QuicHint { | 60 static class QuicHint { |
46 // The host. | 61 // The host. |
47 final String mHost; | 62 final String mHost; |
48 // Port of the server that supports QUIC. | 63 // Port of the server that supports QUIC. |
49 final int mPort; | 64 final int mPort; |
50 // Alternate protocol port. | 65 // Alternate protocol port. |
51 final int mAlternatePort; | 66 final int mAlternatePort; |
52 | 67 |
53 QuicHint(String host, int port, int alternatePort) { | 68 QuicHint(String host, int port, int alternatePort) { |
(...skipping 25 matching lines...) Expand all Loading... | |
79 private static final Pattern INVALID_PKP_HOST_NAME = Pattern.compile("^[ 0-9\\.]*$"); | 94 private static final Pattern INVALID_PKP_HOST_NAME = Pattern.compile("^[ 0-9\\.]*$"); |
80 | 95 |
81 // Private fields are simply storage of configuration for the resulting CronetEngine. | 96 // Private fields are simply storage of configuration for the resulting CronetEngine. |
82 // See setters below for verbose descriptions. | 97 // See setters below for verbose descriptions. |
83 private final Context mContext; | 98 private final Context mContext; |
84 private final List<QuicHint> mQuicHints = new LinkedList<QuicHint>(); | 99 private final List<QuicHint> mQuicHints = new LinkedList<QuicHint>(); |
85 private final List<Pkp> mPkps = new LinkedList<Pkp>(); | 100 private final List<Pkp> mPkps = new LinkedList<Pkp>(); |
86 private String mUserAgent; | 101 private String mUserAgent; |
87 private String mStoragePath; | 102 private String mStoragePath; |
88 private boolean mLegacyModeEnabled; | 103 private boolean mLegacyModeEnabled; |
104 private CustomLibraryLoader mLibraryLoader; | |
89 private String mLibraryName; | 105 private String mLibraryName; |
90 private boolean mQuicEnabled; | 106 private boolean mQuicEnabled; |
91 private boolean mHttp2Enabled; | 107 private boolean mHttp2Enabled; |
92 private boolean mSdchEnabled; | 108 private boolean mSdchEnabled; |
93 private String mDataReductionProxyKey; | 109 private String mDataReductionProxyKey; |
94 private String mDataReductionProxyPrimaryProxy; | 110 private String mDataReductionProxyPrimaryProxy; |
95 private String mDataReductionProxyFallbackProxy; | 111 private String mDataReductionProxyFallbackProxy; |
96 private String mDataReductionProxySecureProxyCheckUrl; | 112 private String mDataReductionProxySecureProxyCheckUrl; |
97 private boolean mDisableCache; | 113 private boolean mDisableCache; |
98 private int mHttpCacheMode; | 114 private int mHttpCacheMode; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 | 196 |
181 /** | 197 /** |
182 * Overrides the name of the native library backing Cronet. | 198 * Overrides the name of the native library backing Cronet. |
183 * @return the builder to facilitate chaining. | 199 * @return the builder to facilitate chaining. |
184 */ | 200 */ |
185 Builder setLibraryName(String libName) { | 201 Builder setLibraryName(String libName) { |
186 mLibraryName = libName; | 202 mLibraryName = libName; |
187 return this; | 203 return this; |
188 } | 204 } |
189 | 205 |
190 String libraryName() { | 206 /** |
191 return mLibraryName; | 207 * Overrides the callback to load the native library. |
xunjieli
2016/01/22 22:53:15
Maybe update the comment? something like: Sets a l
mgersh
2016/01/25 17:31:11
Done.
| |
208 * @return the builder to facilitate chaining. | |
209 */ | |
210 public Builder setLibraryLoader(CustomLibraryLoader loader) { | |
211 mLibraryLoader = loader; | |
212 return this; | |
213 } | |
214 | |
215 void loadLibrary() { | |
216 if (mLibraryLoader == null) { | |
217 System.loadLibrary(mLibraryName); | |
218 } else { | |
219 mLibraryLoader.loadLibrary(mLibraryName); | |
220 } | |
192 } | 221 } |
193 | 222 |
194 /** | 223 /** |
195 * Sets whether <a href="https://www.chromium.org/quic">QUIC</a> protoco l | 224 * Sets whether <a href="https://www.chromium.org/quic">QUIC</a> protoco l |
196 * is enabled. Defaults to disabled. | 225 * is enabled. Defaults to disabled. |
197 * @return the builder to facilitate chaining. | 226 * @return the builder to facilitate chaining. |
198 */ | 227 */ |
199 public Builder enableQUIC(boolean value) { | 228 public Builder enableQUIC(boolean value) { |
200 mQuicEnabled = value; | 229 mQuicEnabled = value; |
201 return this; | 230 return this; |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1026 * Interface to listen for finished requests that were created via this Cron etEngine instance. | 1055 * Interface to listen for finished requests that were created via this Cron etEngine instance. |
1027 * | 1056 * |
1028 * @deprecated not really deprecated but hidden for now as it's a prototype. | 1057 * @deprecated not really deprecated but hidden for now as it's a prototype. |
1029 */ | 1058 */ |
1030 @Deprecated | 1059 @Deprecated |
1031 public interface RequestFinishedListener { // TODO(klm): Add a convenience a bstract class. | 1060 public interface RequestFinishedListener { // TODO(klm): Add a convenience a bstract class. |
1032 /** Invoked with request info. */ | 1061 /** Invoked with request info. */ |
1033 void onRequestFinished(UrlRequestInfo requestInfo); | 1062 void onRequestFinished(UrlRequestInfo requestInfo); |
1034 } | 1063 } |
1035 } | 1064 } |
OLD | NEW |