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.os.Build; | 8 import android.os.Build; |
| 9 import android.os.ConditionVariable; | 9 import android.os.ConditionVariable; |
| 10 import android.os.Handler; | 10 import android.os.Handler; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 */ | 34 */ |
| 35 private final Object mLock = new Object(); | 35 private final Object mLock = new Object(); |
| 36 private final ConditionVariable mInitCompleted = new ConditionVariable(false ); | 36 private final ConditionVariable mInitCompleted = new ConditionVariable(false ); |
| 37 private final AtomicInteger mActiveRequestCount = new AtomicInteger(0); | 37 private final AtomicInteger mActiveRequestCount = new AtomicInteger(0); |
| 38 | 38 |
| 39 private long mUrlRequestContextAdapter = 0; | 39 private long mUrlRequestContextAdapter = 0; |
| 40 private Thread mNetworkThread; | 40 private Thread mNetworkThread; |
| 41 | 41 |
| 42 public CronetUrlRequestContext(Context context, | 42 public CronetUrlRequestContext(Context context, |
| 43 UrlRequestContextConfig config) { | 43 UrlRequestContextConfig config) { |
| 44 CronetLibraryLoader.ensureInitialized(context, config); | 44 CronetLibraryLoader.ensureInitialized(context, config); |
|
mmenke
2015/03/06 15:58:28
Should this also use getApplicationContext? Also,
pauljensen
2015/03/06 16:21:15
I tried to explain this in the CL description. I
mmenke
2015/03/06 16:52:23
Hrm...For some reason I was thinking you were addi
| |
| 45 nativeSetMinLogLevel(getLoggingLevel()); | 45 nativeSetMinLogLevel(getLoggingLevel()); |
| 46 mUrlRequestContextAdapter = nativeCreateRequestContextAdapter( | 46 mUrlRequestContextAdapter = nativeCreateRequestContextAdapter( |
| 47 context, config.toString()); | 47 context.getApplicationContext(), config.toString()); |
| 48 if (mUrlRequestContextAdapter == 0) { | 48 if (mUrlRequestContextAdapter == 0) { |
| 49 throw new NullPointerException("Context Adapter creation failed."); | 49 throw new NullPointerException("Context Adapter creation failed."); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Init native Chromium URLRequestContext on main UI thread. | 52 // Init native Chromium URLRequestContext on main UI thread. |
| 53 Runnable task = new Runnable() { | 53 Runnable task = new Runnable() { |
| 54 @Override | 54 @Override |
| 55 public void run() { | 55 public void run() { |
| 56 synchronized (mLock) { | 56 synchronized (mLock) { |
| 57 // mUrlRequestContextAdapter is guaranteed to exist until | 57 // mUrlRequestContextAdapter is guaranteed to exist until |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 private void initNetworkThread() { | 188 private void initNetworkThread() { |
| 189 synchronized (mLock) { | 189 synchronized (mLock) { |
| 190 mNetworkThread = Thread.currentThread(); | 190 mNetworkThread = Thread.currentThread(); |
| 191 mInitCompleted.open(); | 191 mInitCompleted.open(); |
| 192 } | 192 } |
| 193 Thread.currentThread().setName("ChromiumNet"); | 193 Thread.currentThread().setName("ChromiumNet"); |
| 194 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); | 194 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // Native methods are implemented in cronet_url_request_context.cc. | 197 // Native methods are implemented in cronet_url_request_context.cc. |
| 198 private static native long nativeCreateRequestContextAdapter( | 198 private static native long nativeCreateRequestContextAdapter(Context appCont ext, String config); |
|
mef
2015/03/06 16:55:55
does this really need appContext? It doesn't seem
| |
| 199 Context context, String config); | |
| 200 | 199 |
| 201 private static native int nativeSetMinLogLevel(int loggingLevel); | 200 private static native int nativeSetMinLogLevel(int loggingLevel); |
| 202 | 201 |
| 203 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 202 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 204 private native void nativeDestroy(long nativePtr); | 203 private native void nativeDestroy(long nativePtr); |
| 205 | 204 |
| 206 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 205 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 207 private native void nativeStartNetLogToFile(long nativePtr, | 206 private native void nativeStartNetLogToFile(long nativePtr, |
| 208 String fileName); | 207 String fileName); |
| 209 | 208 |
| 210 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 209 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 211 private native void nativeStopNetLog(long nativePtr); | 210 private native void nativeStopNetLog(long nativePtr); |
| 212 | 211 |
| 213 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 212 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 214 private native void nativeInitRequestContextOnMainThread(long nativePtr); | 213 private native void nativeInitRequestContextOnMainThread(long nativePtr); |
| 215 } | 214 } |
| OLD | NEW |