Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 int requestPriority, Map<String, String> headers, | 52 int requestPriority, Map<String, String> headers, |
| 53 HttpUrlRequestListener listener); | 53 HttpUrlRequestListener listener); |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Creates a new request intended for streaming. | 56 * Creates a new request intended for streaming. |
| 57 */ | 57 */ |
| 58 public abstract HttpUrlRequest createRequest(String url, | 58 public abstract HttpUrlRequest createRequest(String url, |
| 59 int requestPriority, Map<String, String> headers, | 59 int requestPriority, Map<String, String> headers, |
| 60 WritableByteChannel channel, HttpUrlRequestListener listener); | 60 WritableByteChannel channel, HttpUrlRequestListener listener); |
| 61 | 61 |
| 62 /** | |
| 63 * Starts NetLog logging to a file named |fileName| in the | |
| 64 * application temporary directory. |fileName| must not be empty. Log level | |
| 65 * is LOG_ALL_BUT_BYTES. If the file exists it is truncated before starting. | |
|
mmenke
2014/09/29 18:53:19
If we're going to document the log level, we shoul
mef
2014/09/29 21:21:24
I'm fine with not documenting the log level, altho
mmenke
2014/09/29 21:24:30
Great, let's do that for now, then.
I wonder if i
mef
2014/09/29 22:25:09
Done.
| |
| 66 * If actively logging the call is ignored. | |
| 67 */ | |
| 68 public abstract void startNetLogToFile(String fileName); | |
| 69 | |
| 70 /** | |
| 71 * Stops NetLog logging and flushes file to disk. If a logging session is | |
| 72 * not in progress this call is ignored. | |
| 73 */ | |
| 74 public abstract void stopNetLog(); | |
| 75 | |
| 62 private static HttpUrlRequestFactory createChromiumFactory( | 76 private static HttpUrlRequestFactory createChromiumFactory( |
| 63 Context context, HttpUrlRequestFactoryConfig config) { | 77 Context context, HttpUrlRequestFactoryConfig config) { |
| 64 HttpUrlRequestFactory factory = null; | 78 HttpUrlRequestFactory factory = null; |
| 65 try { | 79 try { |
| 66 Class<? extends HttpUrlRequestFactory> factoryClass = | 80 Class<? extends HttpUrlRequestFactory> factoryClass = |
| 67 HttpUrlRequestFactory.class.getClassLoader(). | 81 HttpUrlRequestFactory.class.getClassLoader(). |
| 68 loadClass(CHROMIUM_URL_REQUEST_FACTORY). | 82 loadClass(CHROMIUM_URL_REQUEST_FACTORY). |
| 69 asSubclass(HttpUrlRequestFactory.class); | 83 asSubclass(HttpUrlRequestFactory.class); |
| 70 Constructor<? extends HttpUrlRequestFactory> constructor = | 84 Constructor<? extends HttpUrlRequestFactory> constructor = |
| 71 factoryClass.getConstructor( | 85 factoryClass.getConstructor( |
| 72 Context.class, HttpUrlRequestFactoryConfig.class); | 86 Context.class, HttpUrlRequestFactoryConfig.class); |
| 73 HttpUrlRequestFactory chromiumFactory = | 87 HttpUrlRequestFactory chromiumFactory = |
| 74 constructor.newInstance(context, config); | 88 constructor.newInstance(context, config); |
| 75 if (chromiumFactory.isEnabled()) { | 89 if (chromiumFactory.isEnabled()) { |
| 76 factory = chromiumFactory; | 90 factory = chromiumFactory; |
| 77 } | 91 } |
| 78 } catch (ClassNotFoundException e) { | 92 } catch (ClassNotFoundException e) { |
| 79 // Leave as null | 93 // Leave as null |
| 80 } catch (Exception e) { | 94 } catch (Exception e) { |
| 81 throw new IllegalStateException( | 95 throw new IllegalStateException( |
| 82 "Cannot instantiate: " + | 96 "Cannot instantiate: " + |
| 83 CHROMIUM_URL_REQUEST_FACTORY, | 97 CHROMIUM_URL_REQUEST_FACTORY, |
| 84 e); | 98 e); |
| 85 } | 99 } |
| 86 return factory; | 100 return factory; |
| 87 } | 101 } |
| 88 } | 102 } |
| OLD | NEW |