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

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

Issue 876123002: [Cronet] Make CronetHttpURLStreamHandler.openConnection public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unsupported protocol Created 5 years, 10 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.urlconnection; 5 package org.chromium.net.urlconnection;
6 6
7 import org.chromium.net.UrlRequestContext; 7 import org.chromium.net.UrlRequestContext;
8 8
9 import java.io.IOException; 9 import java.io.IOException;
10 import java.net.Proxy; 10 import java.net.Proxy;
11 import java.net.URL; 11 import java.net.URL;
12 import java.net.URLConnection; 12 import java.net.URLConnection;
13 import java.net.URLStreamHandler; 13 import java.net.URLStreamHandler;
14 14
15 /** 15 /**
16 * An {@code URLStreamHandler} that handles http and https connections. 16 * An {@code URLStreamHandler} that handles http and https connections.
17 */ 17 */
18 public class CronetHttpURLStreamHandler extends URLStreamHandler { 18 public class CronetHttpURLStreamHandler extends URLStreamHandler {
19 private final UrlRequestContext mUrlRequestContext; 19 private final UrlRequestContext mUrlRequestContext;
20 20
21 public CronetHttpURLStreamHandler(UrlRequestContext urlRequestContext) { 21 public CronetHttpURLStreamHandler(UrlRequestContext urlRequestContext) {
22 mUrlRequestContext = urlRequestContext; 22 mUrlRequestContext = urlRequestContext;
23 } 23 }
24 24
25 /** 25 /**
26 * Establishes a new connection to the resource specified by the URL url. 26 * Establishes a new connection to the resource specified by the URL url.
27 */ 27 */
28 @Override 28 @Override
29 protected URLConnection openConnection(URL url) throws IOException { 29 public URLConnection openConnection(URL url) throws IOException {
30 String protocol = url.getProtocol(); 30 String protocol = url.getProtocol();
31 if ("http".equals(protocol) || "https".equals(protocol)) { 31 if ("http".equals(protocol) || "https".equals(protocol)) {
32 return new CronetHttpURLConnection(url, mUrlRequestContext); 32 return new CronetHttpURLConnection(url, mUrlRequestContext);
33 } 33 }
34 throw new UnsupportedOperationException( 34 throw new UnsupportedOperationException(
35 "Unexpected protocol:" + protocol); 35 "Unexpected protocol:" + protocol);
36 } 36 }
37 37
38 /** 38 /**
39 * Establishes a new connection to the resource specified by the URL url 39 * Establishes a new connection to the resource specified by the URL url
40 * using the given proxy. 40 * using the given proxy.
41 */ 41 */
42 @Override 42 @Override
43 protected URLConnection openConnection(URL url, Proxy proxy) { 43 public URLConnection openConnection(URL url, Proxy proxy) {
44 throw new UnsupportedOperationException(); 44 throw new UnsupportedOperationException();
45 } 45 }
46 } 46 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/urlconnection/CronetHttpURLStreamHandlerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698