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

Unified Diff: net/cronet/android/java/src/org/chromium/net/UrlRequestContext.java

Issue 145213003: Initial upload of cronet for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed copyright year on sample code back to 2012 Created 6 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 side-by-side diff with in-line comments
Download patch
Index: net/cronet/android/java/src/org/chromium/net/UrlRequestContext.java
diff --git a/net/cronet/android/java/src/org/chromium/net/UrlRequestContext.java b/net/cronet/android/java/src/org/chromium/net/UrlRequestContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..74dbebf4c443551a8105efa58f2679e608a4b6fe
--- /dev/null
+++ b/net/cronet/android/java/src/org/chromium/net/UrlRequestContext.java
@@ -0,0 +1,66 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.net;
+
+import android.content.Context;
+import android.os.ConditionVariable;
+import android.os.Process;
+
+import org.chromium.base.AccessedByNative;
+import org.chromium.base.CalledByNative;
+
+/**
+ * Provides context for the native HTTP operations.
+ */
+public class UrlRequestContext {
+ protected static final int LOG_NONE = 0;
+ protected static final int LOG_DEBUG = 1;
+ protected static final int LOG_VERBOSE = 2;
+
+ /**
+ * This field is accessed exclusively from the native layer.
+ */
+ @AccessedByNative
+ private long mRequestContext;
+
+ private final ConditionVariable mStarted = new ConditionVariable();
+
+ /**
+ * Constructor.
+ *
+ * @param loggingLevel see {@link #LOG_NONE}, {@link #LOG_DEBUG} and
+ * {@link #LOG_VERBOSE}.
+ */
+ protected UrlRequestContext(Context context,
+ String userAgent,
+ int loggingLevel) {
+ nativeInitialize(context, userAgent, loggingLevel);
+ mStarted.block(2000);
+ }
+
+ /**
+ * Returns the version of this network stack formatted as N.N.N.N/X where
+ * N.N.N.N is the version of Chromium and X is the version of the JNI layer.
+ */
+ public static native String getVersion();
+
+ @CalledByNative
+ private void initNetworkThread() {
+ Thread.currentThread().setName("ChromiumNet");
+ Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
+ mStarted.open();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ nativeFinalize();
+ super.finalize();
+ }
+
+ private native void nativeInitialize(Context context,
+ String userAgent,
+ int loggingLevel);
+ private native void nativeFinalize();
+}
« no previous file with comments | « net/cronet/android/java/src/org/chromium/net/UrlRequest.java ('k') | net/cronet/android/org_chromium_net_UrlRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698