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; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 * Stops NetLog logging and flushes file to disk. If a logging session is | 71 * Stops NetLog logging and flushes file to disk. If a logging session is |
72 * not in progress this call is ignored. | 72 * not in progress this call is ignored. |
73 */ | 73 */ |
74 public abstract void stopNetLog(); | 74 public abstract void stopNetLog(); |
75 | 75 |
76 private static HttpUrlRequestFactory createChromiumFactory( | 76 private static HttpUrlRequestFactory createChromiumFactory( |
77 Context context, HttpUrlRequestFactoryConfig config) { | 77 Context context, HttpUrlRequestFactoryConfig config) { |
78 HttpUrlRequestFactory factory = null; | 78 HttpUrlRequestFactory factory = null; |
79 try { | 79 try { |
80 Class<? extends HttpUrlRequestFactory> factoryClass = | 80 Class<? extends HttpUrlRequestFactory> factoryClass = |
81 HttpUrlRequestFactory.class.getClassLoader(). | 81 HttpUrlRequestFactory.class.getClassLoader() |
82 loadClass(CHROMIUM_URL_REQUEST_FACTORY). | 82 .loadClass(CHROMIUM_URL_REQUEST_FACTORY) |
83 asSubclass(HttpUrlRequestFactory.class); | 83 .asSubclass(HttpUrlRequestFactory.class); |
84 Constructor<? extends HttpUrlRequestFactory> constructor = | 84 Constructor<? extends HttpUrlRequestFactory> constructor = |
85 factoryClass.getConstructor( | 85 factoryClass.getConstructor( |
86 Context.class, HttpUrlRequestFactoryConfig.class); | 86 Context.class, HttpUrlRequestFactoryConfig.class); |
87 HttpUrlRequestFactory chromiumFactory = | 87 HttpUrlRequestFactory chromiumFactory = |
88 constructor.newInstance(context, config); | 88 constructor.newInstance(context, config); |
89 if (chromiumFactory.isEnabled()) { | 89 if (chromiumFactory.isEnabled()) { |
90 factory = chromiumFactory; | 90 factory = chromiumFactory; |
91 } | 91 } |
92 } catch (ClassNotFoundException e) { | 92 } catch (ClassNotFoundException e) { |
93 // Leave as null | 93 // Leave as null |
94 } catch (Exception e) { | 94 } catch (Exception e) { |
95 throw new IllegalStateException( | 95 throw new IllegalStateException( |
96 "Cannot instantiate: " + | 96 "Cannot instantiate: " + CHROMIUM_URL_REQUEST_FACTORY, |
97 CHROMIUM_URL_REQUEST_FACTORY, | |
98 e); | 97 e); |
99 } | 98 } |
100 return factory; | 99 return factory; |
101 } | 100 } |
102 } | 101 } |
OLD | NEW |