| 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 16 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |