Index: components/cronet/android/api/src/org/chromium/net/CronetEngine.java |
diff --git a/components/cronet/android/api/src/org/chromium/net/CronetEngine.java b/components/cronet/android/api/src/org/chromium/net/CronetEngine.java |
index 6336533491fe1c048429edb41211dcd51e33b7d6..e77ce4131dad545c04bceff9d25e0a8fce9da2cd 100644 |
--- a/components/cronet/android/api/src/org/chromium/net/CronetEngine.java |
+++ b/components/cronet/android/api/src/org/chromium/net/CronetEngine.java |
@@ -41,6 +41,21 @@ public abstract class CronetEngine { |
* then {@link #build} is called to create the {@code CronetEngine}. |
*/ |
public static class Builder { |
+ /** |
+ * A callback for loading the cronet native library. Apps needing to implement 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
|
+ * library loading logic can implement this interface and pass an instance to |
+ * {@link CronetEngine.Builder.setLibraryLoader()}. For example, this might be required |
+ * to work around {@code UnsatisfiedLinkError}s caused by flaky installation on certain |
+ * older devices. |
+ */ |
+ 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.
|
+ /** |
+ * Load the native library. |
xunjieli
2016/01/22 22:53:15
nit: s/Load/Loads
mgersh
2016/01/25 17:31:11
Done.
|
+ * @param libName name of the library to load |
+ */ |
+ public void loadLibrary(String libName); |
+ } |
+ |
// A hint that a host supports QUIC. |
static class QuicHint { |
// The host. |
@@ -86,6 +101,7 @@ public abstract class CronetEngine { |
private String mUserAgent; |
private String mStoragePath; |
private boolean mLegacyModeEnabled; |
+ private CustomLibraryLoader mLibraryLoader; |
private String mLibraryName; |
private boolean mQuicEnabled; |
private boolean mHttp2Enabled; |
@@ -187,8 +203,21 @@ public abstract class CronetEngine { |
return this; |
} |
- String libraryName() { |
- return mLibraryName; |
+ /** |
+ * 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.
|
+ * @return the builder to facilitate chaining. |
+ */ |
+ public Builder setLibraryLoader(CustomLibraryLoader loader) { |
+ mLibraryLoader = loader; |
+ return this; |
+ } |
+ |
+ void loadLibrary() { |
+ if (mLibraryLoader == null) { |
+ System.loadLibrary(mLibraryName); |
+ } else { |
+ mLibraryLoader.loadLibrary(mLibraryName); |
+ } |
} |
/** |