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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/ChromiumUrlRequestContext.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.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;
(...skipping 16 matching lines...) Expand all
27 * Native adapter object, owned by ChromiumUrlRequestContext. 27 * Native adapter object, owned by ChromiumUrlRequestContext.
28 */ 28 */
29 private long mChromiumUrlRequestContextAdapter; 29 private long mChromiumUrlRequestContextAdapter;
30 30
31 /** 31 /**
32 * Constructor. 32 * Constructor.
33 */ 33 */
34 protected ChromiumUrlRequestContext(final Context context, String userAgent, 34 protected ChromiumUrlRequestContext(final Context context, String userAgent,
35 String config) { 35 String config) {
36 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter( 36 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter(
37 context, userAgent, getLoggingLevel(), config); 37 context.getApplicationContext(), userAgent, getLoggingLevel(), c onfig);
38 if (mChromiumUrlRequestContextAdapter == 0) { 38 if (mChromiumUrlRequestContextAdapter == 0) {
39 throw new NullPointerException("Context Adapter creation failed"); 39 throw new NullPointerException("Context Adapter creation failed");
40 } 40 }
41 // Post a task to UI thread to init native Chromium URLRequestContext. 41 // Post a task to UI thread to init native Chromium URLRequestContext.
42 // TODO(xunjieli): This constructor is not supposed to be invoked on 42 // TODO(xunjieli): This constructor is not supposed to be invoked on
43 // the main thread. Consider making the following code into a blocking 43 // the main thread. Consider making the following code into a blocking
44 // API to handle the case where we are already on main thread. 44 // API to handle the case where we are already on main thread.
45 Runnable task = new Runnable() { 45 Runnable task = new Runnable() {
46 public void run() { 46 public void run() {
47 NetworkChangeNotifier.init(context); 47 NetworkChangeNotifier.init(context);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } else if (Log.isLoggable(LOG_TAG, Log.DEBUG)) { 127 } else if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
128 loggingLevel = LOG_DEBUG; 128 loggingLevel = LOG_DEBUG;
129 } else { 129 } else {
130 loggingLevel = LOG_NONE; 130 loggingLevel = LOG_NONE;
131 } 131 }
132 return loggingLevel; 132 return loggingLevel;
133 } 133 }
134 134
135 // Returns an instance ChromiumUrlRequestContextAdapter to be stored in 135 // Returns an instance ChromiumUrlRequestContextAdapter to be stored in
136 // mChromiumUrlRequestContextAdapter. 136 // mChromiumUrlRequestContextAdapter.
137 private native long nativeCreateRequestContextAdapter(Context context, 137 private native long nativeCreateRequestContextAdapter(
138 String userAgent, int loggingLevel, String config); 138 Context appContext, String userAgent, int loggingLevel, String confi g);
139 139
140 private native void nativeReleaseRequestContextAdapter( 140 private native void nativeReleaseRequestContextAdapter(
141 long chromiumUrlRequestContextAdapter); 141 long chromiumUrlRequestContextAdapter);
142 142
143 private native void nativeInitializeStatistics(); 143 private native void nativeInitializeStatistics();
144 144
145 private native String nativeGetStatisticsJSON(String filter); 145 private native String nativeGetStatisticsJSON(String filter);
146 146
147 private native void nativeStartNetLogToFile( 147 private native void nativeStartNetLogToFile(
148 long chromiumUrlRequestContextAdapter, String fileName); 148 long chromiumUrlRequestContextAdapter, String fileName);
149 149
150 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); 150 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter);
151 151
152 private native void nativeInitRequestContextOnMainThread( 152 private native void nativeInitRequestContextOnMainThread(
153 long chromiumUrlRequestContextAdapter); 153 long chromiumUrlRequestContextAdapter);
154 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698