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

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

Issue 624443003: Setup ProxyConfigServiceAndroid in Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix an indentation Created 6 years, 2 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;
9 import android.os.Looper;
8 import android.os.Process; 10 import android.os.Process;
9 import android.util.Log; 11 import android.util.Log;
10 12
11 import org.chromium.base.CalledByNative; 13 import org.chromium.base.CalledByNative;
12 import org.chromium.base.JNINamespace; 14 import org.chromium.base.JNINamespace;
13 15
14 /** 16 /**
15 * Provides context for the native HTTP operations. 17 * Provides context for the native HTTP operations.
16 */ 18 */
17 @JNINamespace("cronet") 19 @JNINamespace("cronet")
18 public class ChromiumUrlRequestContext { 20 public class ChromiumUrlRequestContext {
19 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG. 21 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG.
20 private static final int LOG_DEBUG = -1; // LOG(FATAL...INFO), VLOG(1) 22 private static final int LOG_DEBUG = -1; // LOG(FATAL...INFO), VLOG(1)
21 private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2) 23 private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2)
22 static final String LOG_TAG = "ChromiumNetwork"; 24 static final String LOG_TAG = "ChromiumNetwork";
23 25
24 /** 26 /**
25 * Native adapter object, owned by ChromiumUrlRequestContext. 27 * Native adapter object, owned by ChromiumUrlRequestContext.
26 */ 28 */
27 private long mChromiumUrlRequestContextAdapter; 29 private long mChromiumUrlRequestContextAdapter;
28 30
29 /** 31 /**
30 * Constructor. 32 * Constructor.
31 *
32 */ 33 */
33 protected ChromiumUrlRequestContext(Context context, String userAgent, 34 protected ChromiumUrlRequestContext(Context context, String userAgent,
34 String config) { 35 String config) {
35 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter( 36 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter(
36 context, userAgent, getLoggingLevel(), config); 37 context, userAgent, getLoggingLevel(), config);
37 if (mChromiumUrlRequestContextAdapter == 0) { 38 if (mChromiumUrlRequestContextAdapter == 0) {
38 throw new NullPointerException("Context Adapter creation failed"); 39 throw new NullPointerException("Context Adapter creation failed");
39 } 40 }
41 // Post a task to UI thread to init native Chromium URLRequestContext.
42 Runnable task = new Runnable() {
43 public void run() {
44 nativeInitRequestContextOnUIThread(
mmenke 2014/10/15 17:44:17 nit: +2 indent.
xunjieli 2014/10/15 19:48:08 Done.
45 mChromiumUrlRequestContextAdapter);
46 }
47 };
48 new Handler(Looper.getMainLooper()).post(task);
mmenke 2014/10/15 17:44:17 In the future, may want to just run synchronously
xunjieli 2014/10/15 19:48:08 Acknowledged. I have added your suggestion in the
40 } 49 }
41 50
42 /** 51 /**
43 * Returns the version of this network stack formatted as N.N.N.N/X where 52 * Returns the version of this network stack formatted as N.N.N.N/X where
44 * N.N.N.N is the version of Chromium and X is the revision number. 53 * N.N.N.N is the version of Chromium and X is the revision number.
45 */ 54 */
46 public static String getVersion() { 55 public static String getVersion() {
47 return Version.getVersion(); 56 return Version.getVersion();
48 } 57 }
49 58
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 long chromiumUrlRequestContextAdapter); 131 long chromiumUrlRequestContextAdapter);
123 132
124 private native void nativeInitializeStatistics(); 133 private native void nativeInitializeStatistics();
125 134
126 private native String nativeGetStatisticsJSON(String filter); 135 private native String nativeGetStatisticsJSON(String filter);
127 136
128 private native void nativeStartNetLogToFile( 137 private native void nativeStartNetLogToFile(
129 long chromiumUrlRequestContextAdapter, String fileName); 138 long chromiumUrlRequestContextAdapter, String fileName);
130 139
131 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); 140 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter);
141 private native void nativeInitRequestContextOnUIThread(
142 long chromiumUrlRequestContextAdapter);
132 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698