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
3 // found in the LICENSE file.
5 package org.chromium.net;
7 import android.content.Context;
8 import android.os.ConditionVariable;
9 import android.os.Process;
11 import org.chromium.base.AccessedByNative;
12 import org.chromium.base.CalledByNative;
15 * Provides context for the native HTTP operations.
17 public class UrlRequestContext {
18 protected static final int LOG_NONE = 0;
20 protected static final int LOG_DEBUG = 1;
22 protected static final int LOG_VERBOSE = 2;
25 * This field is accessed exclusively from the native layer.
28 private long mRequestContext;
30 private final ConditionVariable mStarted = new ConditionVariable();
35 * @param loggingLevel see {@link #LOG_NONE}, {@link #LOG_DEBUG} and
36 * {@link #LOG_VERBOSE}.
38 protected UrlRequestContext(Context context, String userAgent,
40 nativeInitialize(context, userAgent, loggingLevel);
45 * Returns the version of this network stack formatted as N.N.N.N/X where
46 * N.N.N.N is the version of Chromium and X is the version of the JNI layer.
48 public static native String getVersion();
51 private void initNetworkThread() {
52 Thread.currentThread().setName("ChromiumNet");
53 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
58 protected void finalize() throws Throwable {
63 private native void nativeInitialize(Context context, String userAgent,
66 private native void nativeFinalize();