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

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

Issue 1383023003: [Cronet] Expose HttpURLConnection API from CronetEngine, not classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@builder2
Patch Set: Created 5 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.os.Build; 7 import android.os.Build;
8 import android.os.ConditionVariable; 8 import android.os.ConditionVariable;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.Looper; 10 import android.os.Looper;
11 import android.os.Process; 11 import android.os.Process;
12 import android.util.Log; 12 import android.util.Log;
13 13
14 import org.chromium.base.VisibleForTesting; 14 import org.chromium.base.VisibleForTesting;
15 import org.chromium.base.annotations.CalledByNative; 15 import org.chromium.base.annotations.CalledByNative;
16 import org.chromium.base.annotations.JNINamespace; 16 import org.chromium.base.annotations.JNINamespace;
17 import org.chromium.base.annotations.NativeClassQualifiedName; 17 import org.chromium.base.annotations.NativeClassQualifiedName;
18 import org.chromium.base.annotations.UsedByReflection; 18 import org.chromium.base.annotations.UsedByReflection;
19 import org.chromium.net.urlconnection.CronetHttpURLConnection;
20 import org.chromium.net.urlconnection.CronetURLStreamHandlerFactory;
19 21
22 import java.net.Proxy;
23 import java.net.URL;
24 import java.net.URLConnection;
25 import java.net.URLStreamHandlerFactory;
20 import java.util.concurrent.Executor; 26 import java.util.concurrent.Executor;
21 import java.util.concurrent.atomic.AtomicInteger; 27 import java.util.concurrent.atomic.AtomicInteger;
22 28
23 /** 29 /**
24 * CronetEngine using Chromium HTTP stack implementation. 30 * CronetEngine using Chromium HTTP stack implementation.
25 */ 31 */
26 @JNINamespace("cronet") 32 @JNINamespace("cronet")
27 @UsedByReflection("CronetEngine.java") 33 @UsedByReflection("CronetEngine.java")
28 class CronetUrlRequestContext extends CronetEngine { 34 class CronetUrlRequestContext extends CronetEngine {
29 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG. 35 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 145 }
140 146
141 @Override 147 @Override
142 public void stopNetLog() { 148 public void stopNetLog() {
143 synchronized (mLock) { 149 synchronized (mLock) {
144 checkHaveAdapter(); 150 checkHaveAdapter();
145 nativeStopNetLog(mUrlRequestContextAdapter); 151 nativeStopNetLog(mUrlRequestContextAdapter);
146 } 152 }
147 } 153 }
148 154
155 @Override
156 public URLConnection openConnection(URL url) {
157 return openConnection(url, Proxy.NO_PROXY);
158 }
159
160 @Override
161 public URLConnection openConnection(URL url, Proxy proxy) {
162 if (proxy.type() != Proxy.Type.DIRECT) {
163 throw new UnsupportedOperationException();
164 }
165 String protocol = url.getProtocol();
166 if ("http".equals(protocol) || "https".equals(protocol)) {
167 return new CronetHttpURLConnection(url, this);
168 }
169 throw new UnsupportedOperationException("Unexpected protocol:" + protoco l);
170 }
171
172 @Override
173 public URLStreamHandlerFactory createURLStreamHandlerFactory() {
174 return new CronetURLStreamHandlerFactory(this);
175 }
176
149 /** 177 /**
150 * Mark request as started to prevent shutdown when there are active 178 * Mark request as started to prevent shutdown when there are active
151 * requests. 179 * requests.
152 */ 180 */
153 void onRequestStarted(UrlRequest urlRequest) { 181 void onRequestStarted(UrlRequest urlRequest) {
154 mActiveRequestCount.incrementAndGet(); 182 mActiveRequestCount.incrementAndGet();
155 } 183 }
156 184
157 /** 185 /**
158 * Mark request as completed to allow shutdown when there are no active 186 * Mark request as completed to allow shutdown when there are no active
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 246 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
219 private native void nativeStartNetLogToFile(long nativePtr, 247 private native void nativeStartNetLogToFile(long nativePtr,
220 String fileName, boolean logAll); 248 String fileName, boolean logAll);
221 249
222 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 250 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
223 private native void nativeStopNetLog(long nativePtr); 251 private native void nativeStopNetLog(long nativePtr);
224 252
225 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 253 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
226 private native void nativeInitRequestContextOnMainThread(long nativePtr); 254 private native void nativeInitRequestContextOnMainThread(long nativePtr);
227 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698