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

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

Issue 981013002: [Cronet] Make sure to only pass the application Context to InitApplicationContext to avoid DCHECK fa (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add ChromiumUrlRequestContext test too Created 5 years, 9 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
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 26 matching lines...) Expand all
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);
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
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);
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698