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..9f2f7b7ab3180c015e213808f13e7ad6068efdae 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,19 @@ public abstract class CronetEngine { |
* then {@link #build} is called to create the {@code CronetEngine}. |
*/ |
public static class Builder { |
+ /** |
+ * A callback for loading the "cronet" library. |
xunjieli
2016/01/21 19:50:53
Suggest making this into an abstract class, and mL
mgersh
2016/01/22 17:41:16
I made it into an interface instead, since it look
|
+ */ |
+ public static class LibraryLoader { |
+ /** |
+ * Load the native library. |
+ */ |
+ public void loadLibrary(Context context, String name) { |
xunjieli
2016/01/21 19:50:53
I don't think we need the context as an argument.
mgersh
2016/01/22 17:41:16
Done.
|
+ // The context isn't used here, but other implementations might need it |
+ System.loadLibrary(name); |
+ } |
+ } |
+ |
// A hint that a host supports QUIC. |
static class QuicHint { |
// The host. |
@@ -86,6 +99,7 @@ public abstract class CronetEngine { |
private String mUserAgent; |
private String mStoragePath; |
private boolean mLegacyModeEnabled; |
+ private LibraryLoader mLibraryLoader; |
private String mLibraryName; |
private boolean mQuicEnabled; |
private boolean mHttp2Enabled; |
@@ -107,6 +121,7 @@ public abstract class CronetEngine { |
public Builder(Context context) { |
mContext = context; |
setLibraryName("cronet"); |
+ setLibraryLoader(new LibraryLoader()); |
enableLegacyMode(false); |
enableQUIC(false); |
enableHTTP2(true); |
@@ -187,8 +202,17 @@ public abstract class CronetEngine { |
return this; |
} |
- String libraryName() { |
- return mLibraryName; |
+ /** |
+ * Overrides the callback to load the native library. |
+ * @return the builder to facilitate chaining. |
+ */ |
+ public Builder setLibraryLoader(LibraryLoader loader) { |
+ mLibraryLoader = loader; |
+ return this; |
+ } |
+ |
+ void loadLibrary(Context context) { |
+ mLibraryLoader.loadLibrary(context, mLibraryName); |
xunjieli
2016/01/21 19:50:53
Suggest do the following:
If mLibraryLoader is nul
mgersh
2016/01/22 17:41:16
Done.
|
} |
/** |