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

Unified Diff: components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandler.java

Issue 725683002: [Cronet] Initial implementation of HttpURLConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated test Created 6 years, 1 month 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: components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandler.java
diff --git a/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandler.java b/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..f1e3b592c48b35e00bdb4cb79c7e6f506c3a34cf
--- /dev/null
+++ b/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLStreamHandler.java
@@ -0,0 +1,46 @@
+// Copyright 2014 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.urlconnection;
+
+import org.chromium.net.UrlRequestContext;
+
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * An {@code URLStreamHandler} that handles http and https connections.
+ */
+public class CronetHttpURLStreamHandler extends URLStreamHandler {
+ private final UrlRequestContext mUrlRequestContext;
+
+ public CronetHttpURLStreamHandler(UrlRequestContext urlRequestContext) {
+ mUrlRequestContext = urlRequestContext;
+ }
+
+ /**
+ * Establishes a new connection to the resource specified by the URL url.
+ */
+ @Override
+ protected URLConnection openConnection(URL url) throws IOException {
+ String protocol = url.getProtocol();
+ if ("http".equals(protocol) || "https".equals(protocol)) {
+ return new CronetHttpURLConnection(url, mUrlRequestContext);
+ }
+ throw new UnsupportedOperationException(
+ "Unexpected protocol:" + protocol);
+ }
+
+ /**
+ * Establishes a new connection to the resource specified by the URL url
+ * using the given proxy.
+ */
+ @Override
+ protected URLConnection openConnection(URL url, Proxy proxy) {
+ throw new UnsupportedOperationException();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698