OLD | NEW |
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.CronetEngine; | 7 import org.chromium.net.CronetEngine; |
| 8 import org.chromium.net.impl.CronetEngineBase; |
8 | 9 |
9 import java.net.URLStreamHandler; | 10 import java.net.URLStreamHandler; |
10 import java.net.URLStreamHandlerFactory; | 11 import java.net.URLStreamHandlerFactory; |
11 | 12 |
12 /** | 13 /** |
13 * An implementation of {@link URLStreamHandlerFactory} to handle HTTP and HTTPS | 14 * An implementation of {@link URLStreamHandlerFactory} to handle HTTP and HTTPS |
14 * traffic. An instance of this class can be installed via | 15 * traffic. An instance of this class can be installed via |
15 * {@link java.net.URL#setURLStreamHandlerFactory} thus using Cronet by default
for all requests | 16 * {@link java.net.URL#setURLStreamHandlerFactory} thus using Cronet by default
for all requests |
16 * created via {@link java.net.URL#openConnection}. | 17 * created via {@link java.net.URL#openConnection}. |
17 * <p> | 18 * <p> |
(...skipping 15 matching lines...) Expand all Loading... |
33 * javax.net.ssl.HttpsURLConnection#setDefaultHostnameVerifier(javax.net.ssl
.HostnameVerifier) | 34 * javax.net.ssl.HttpsURLConnection#setDefaultHostnameVerifier(javax.net.ssl
.HostnameVerifier) |
34 * HttpsURLConnection.setDefaultHostnameVerifier(javax.net.ssl.HostnameVerif
ier)}</li> | 35 * HttpsURLConnection.setDefaultHostnameVerifier(javax.net.ssl.HostnameVerif
ier)}</li> |
35 * <li>the HTTPS socket factory installed via {@link | 36 * <li>the HTTPS socket factory installed via {@link |
36 * javax.net.ssl.HttpsURLConnection#setDefaultSSLSocketFactory(javax.net.ssl
.SSLSocketFactory) | 37 * javax.net.ssl.HttpsURLConnection#setDefaultSSLSocketFactory(javax.net.ssl
.SSLSocketFactory) |
37 * HttpsURLConnection.setDefaultSSLSocketFactory(javax.net.ssl.SSLSocketFact
ory)}</li> | 38 * HttpsURLConnection.setDefaultSSLSocketFactory(javax.net.ssl.SSLSocketFact
ory)}</li> |
38 * </ul> | 39 * </ul> |
39 * | 40 * |
40 * {@hide} | 41 * {@hide} |
41 */ | 42 */ |
42 public class CronetURLStreamHandlerFactory implements URLStreamHandlerFactory { | 43 public class CronetURLStreamHandlerFactory implements URLStreamHandlerFactory { |
43 private final CronetEngine mCronetEngine; | 44 private final CronetEngineBase mCronetEngine; |
44 | 45 |
45 /** | 46 /** |
46 * Creates a {@link CronetURLStreamHandlerFactory} to handle HTTP and HTTPS | 47 * Creates a {@link CronetURLStreamHandlerFactory} to handle HTTP and HTTPS |
47 * traffic. | 48 * traffic. |
48 * @param cronetEngine the {@link CronetEngine} to be used. | 49 * @param cronetEngine the {@link CronetEngine} to be used. |
49 * @throws NullPointerException if config is null. | 50 * @throws NullPointerException if config is null. |
50 */ | 51 */ |
51 public CronetURLStreamHandlerFactory(CronetEngine cronetEngine) { | 52 public CronetURLStreamHandlerFactory(CronetEngineBase cronetEngine) { |
52 if (cronetEngine == null) { | 53 if (cronetEngine == null) { |
53 throw new NullPointerException("CronetEngine is null."); | 54 throw new NullPointerException("CronetEngine is null."); |
54 } | 55 } |
55 mCronetEngine = cronetEngine; | 56 mCronetEngine = cronetEngine; |
56 } | 57 } |
57 | 58 |
58 /** | 59 /** |
59 * Returns a {@link CronetHttpURLStreamHandler} for HTTP and HTTPS, and | 60 * Returns a {@link CronetHttpURLStreamHandler} for HTTP and HTTPS, and |
60 * {@code null} for other protocols. | 61 * {@code null} for other protocols. |
61 */ | 62 */ |
62 @Override | 63 @Override |
63 public URLStreamHandler createURLStreamHandler(String protocol) { | 64 public URLStreamHandler createURLStreamHandler(String protocol) { |
64 if ("http".equals(protocol) || "https".equals(protocol)) { | 65 if ("http".equals(protocol) || "https".equals(protocol)) { |
65 return new CronetHttpURLStreamHandler(mCronetEngine); | 66 return new CronetHttpURLStreamHandler(mCronetEngine); |
66 } | 67 } |
67 return null; | 68 return null; |
68 } | 69 } |
69 } | 70 } |
OLD | NEW |