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.os.Handler; | 8 import android.os.Handler; |
9 import android.os.Looper; | 9 import android.os.Looper; |
10 import android.os.Process; | 10 import android.os.Process; |
11 import android.util.Log; | 11 import android.util.Log; |
12 | 12 |
13 import org.chromium.base.CalledByNative; | 13 import org.chromium.base.CalledByNative; |
14 import org.chromium.base.JNINamespace; | 14 import org.chromium.base.JNINamespace; |
15 import org.chromium.base.VisibleForTesting; | |
15 | 16 |
16 /** | 17 /** |
17 * Provides context for the native HTTP operations. | 18 * Provides context for the native HTTP operations. |
18 */ | 19 */ |
19 @JNINamespace("cronet") | 20 @JNINamespace("cronet") |
20 public class ChromiumUrlRequestContext { | 21 public class ChromiumUrlRequestContext { |
21 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG. | 22 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG. |
22 private static final int LOG_DEBUG = -1; // LOG(FATAL...INFO), VLOG(1) | 23 private static final int LOG_DEBUG = -1; // LOG(FATAL...INFO), VLOG(1) |
23 private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2) | 24 private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2) |
24 static final String LOG_TAG = "ChromiumNetwork"; | 25 static final String LOG_TAG = "ChromiumNetwork"; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 } | 89 } |
89 | 90 |
90 /** | 91 /** |
91 * Stops NetLog logging and flushes file to disk. If a logging session is | 92 * Stops NetLog logging and flushes file to disk. If a logging session is |
92 * not in progress, this call is ignored. | 93 * not in progress, this call is ignored. |
93 */ | 94 */ |
94 public void stopNetLog() { | 95 public void stopNetLog() { |
95 nativeStopNetLog(mChromiumUrlRequestContextAdapter); | 96 nativeStopNetLog(mChromiumUrlRequestContextAdapter); |
96 } | 97 } |
97 | 98 |
99 /** | |
100 * Returns the native URLRequestContextAdapter pointer. | |
101 * Currently this method is only used in testing. | |
102 */ | |
103 @VisibleForTesting | |
104 long getUrlRequestContextAdapter() { | |
mef
2015/04/16 16:04:19
maybe call it getUrlRequestContextAdapterForTestin
xunjieli
2015/04/16 19:36:57
Done.
| |
105 return mChromiumUrlRequestContextAdapter; | |
106 } | |
107 | |
98 @CalledByNative | 108 @CalledByNative |
99 private void initNetworkThread() { | 109 private void initNetworkThread() { |
100 Thread.currentThread().setName("ChromiumNet"); | 110 Thread.currentThread().setName("ChromiumNet"); |
101 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); | 111 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); |
102 } | 112 } |
103 | 113 |
104 @Override | 114 @Override |
105 protected void finalize() throws Throwable { | 115 protected void finalize() throws Throwable { |
106 nativeReleaseRequestContextAdapter(mChromiumUrlRequestContextAdapter); | 116 nativeReleaseRequestContextAdapter(mChromiumUrlRequestContextAdapter); |
107 super.finalize(); | 117 super.finalize(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 private native String nativeGetStatisticsJSON(String filter); | 150 private native String nativeGetStatisticsJSON(String filter); |
141 | 151 |
142 private native void nativeStartNetLogToFile( | 152 private native void nativeStartNetLogToFile( |
143 long chromiumUrlRequestContextAdapter, String fileName); | 153 long chromiumUrlRequestContextAdapter, String fileName); |
144 | 154 |
145 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); | 155 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); |
146 | 156 |
147 private native void nativeInitRequestContextOnMainThread( | 157 private native void nativeInitRequestContextOnMainThread( |
148 long chromiumUrlRequestContextAdapter); | 158 long chromiumUrlRequestContextAdapter); |
149 } | 159 } |
OLD | NEW |