| 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; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 * Native adapter object, owned by ChromiumUrlRequestContext. | 29 * Native adapter object, owned by ChromiumUrlRequestContext. |
| 30 */ | 30 */ |
| 31 private long mChromiumUrlRequestContextAdapter; | 31 private long mChromiumUrlRequestContextAdapter; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Constructor. | 34 * Constructor. |
| 35 */ | 35 */ |
| 36 protected ChromiumUrlRequestContext( | 36 protected ChromiumUrlRequestContext( |
| 37 final Context context, String userAgent, CronetEngine.Builder config
) { | 37 final Context context, String userAgent, CronetEngine.Builder config
) { |
| 38 CronetLibraryLoader.ensureInitialized(context, config); | 38 CronetLibraryLoader.ensureInitialized(context, config); |
| 39 mChromiumUrlRequestContextAdapter = | 39 mChromiumUrlRequestContextAdapter = nativeCreateRequestContextAdapter( |
| 40 nativeCreateRequestContextAdapter(userAgent, getLoggingLevel(), | 40 userAgent, getLoggingLevel(), config.toJSONString()); |
| 41 CronetUrlRequestContext.createNativeUrlRequestContextCon
fig(config)); | |
| 42 if (mChromiumUrlRequestContextAdapter == 0) { | 41 if (mChromiumUrlRequestContextAdapter == 0) { |
| 43 throw new NullPointerException("Context Adapter creation failed"); | 42 throw new NullPointerException("Context Adapter creation failed"); |
| 44 } | 43 } |
| 45 // Post a task to UI thread to init native Chromium URLRequestContext. | 44 // Post a task to UI thread to init native Chromium URLRequestContext. |
| 46 // TODO(xunjieli): This constructor is not supposed to be invoked on | 45 // TODO(xunjieli): This constructor is not supposed to be invoked on |
| 47 // the main thread. Consider making the following code into a blocking | 46 // the main thread. Consider making the following code into a blocking |
| 48 // API to handle the case where we are already on main thread. | 47 // API to handle the case where we are already on main thread. |
| 49 Runnable task = new Runnable() { | 48 Runnable task = new Runnable() { |
| 50 public void run() { | 49 public void run() { |
| 51 nativeInitRequestContextOnMainThread( | 50 nativeInitRequestContextOnMainThread( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 loggingLevel = LOG_DEBUG; | 133 loggingLevel = LOG_DEBUG; |
| 135 } else { | 134 } else { |
| 136 loggingLevel = LOG_NONE; | 135 loggingLevel = LOG_NONE; |
| 137 } | 136 } |
| 138 return loggingLevel; | 137 return loggingLevel; |
| 139 } | 138 } |
| 140 | 139 |
| 141 // Returns an instance ChromiumUrlRequestContextAdapter to be stored in | 140 // Returns an instance ChromiumUrlRequestContextAdapter to be stored in |
| 142 // mChromiumUrlRequestContextAdapter. | 141 // mChromiumUrlRequestContextAdapter. |
| 143 private native long nativeCreateRequestContextAdapter( | 142 private native long nativeCreateRequestContextAdapter( |
| 144 String userAgent, int loggingLevel, long config); | 143 String userAgent, int loggingLevel, String config); |
| 145 | 144 |
| 146 private native void nativeReleaseRequestContextAdapter( | 145 private native void nativeReleaseRequestContextAdapter( |
| 147 long chromiumUrlRequestContextAdapter); | 146 long chromiumUrlRequestContextAdapter); |
| 148 | 147 |
| 149 private native void nativeInitializeStatistics(); | 148 private native void nativeInitializeStatistics(); |
| 150 | 149 |
| 151 private native String nativeGetStatisticsJSON(String filter); | 150 private native String nativeGetStatisticsJSON(String filter); |
| 152 | 151 |
| 153 private native void nativeStartNetLogToFile( | 152 private native void nativeStartNetLogToFile( |
| 154 long chromiumUrlRequestContextAdapter, String fileName, | 153 long chromiumUrlRequestContextAdapter, String fileName, |
| 155 boolean logAll); | 154 boolean logAll); |
| 156 | 155 |
| 157 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); | 156 private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter); |
| 158 | 157 |
| 159 private native void nativeInitRequestContextOnMainThread( | 158 private native void nativeInitRequestContextOnMainThread( |
| 160 long chromiumUrlRequestContextAdapter); | 159 long chromiumUrlRequestContextAdapter); |
| 161 } | 160 } |
| OLD | NEW |