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

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

Issue 2660963002: Cronet: a framework to provide alternative Cronet implementations (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.net;
6
7 import android.content.Context;
8
9 import java.lang.reflect.Constructor;
10
11 /**
12 * Replaceable class providing ability to load Cronet implementation.
13 */
14 final class ImplLoader {
15 // The class name of the Cronet Engine Builder implementation.
16 private static final String CRONET_ENGINE_BUILDER_IMPL =
17 "org.chromium.net.impl.CronetEngineBuilderImpl";
18
19 /**
20 * Load implementation of {@link ICronetEngineBuilder}.
21 * @param context Android {@link Context} to use for loading.
22 * @return {@link ICronetEngineBuilder} implementation.
23 */
24 static ICronetEngineBuilder load(Context context) {
25 try {
26 Class<? extends ICronetEngineBuilder> delegateImplClass =
27 Class.forName(CRONET_ENGINE_BUILDER_IMPL)
28 .asSubclass(ICronetEngineBuilder.class);
29 Constructor<? extends ICronetEngineBuilder> ctor =
30 delegateImplClass.getConstructor(Context.class);
31 return ctor.newInstance(context);
32 } catch (Exception e) {
33 throw new RuntimeException(
34 "Unable to construct the implementation of the Cronet Engine Builder: "
35 + CRONET_ENGINE_BUILDER_IMPL,
36 e);
37 }
38 }
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698