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

Side by Side Diff: components/cronet/README.md

Issue 1383023003: [Cronet] Expose HttpURLConnection API from CronetEngine, not classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@builder2
Patch Set: address nits 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
« no previous file with comments | « no previous file | components/cronet/android/java/package-list » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Quick Start Guide to Using Cronet 1 # Quick Start Guide to Using Cronet
2 Cronet is the networking stack of Chromium put into a library for use on 2 Cronet is the networking stack of Chromium put into a library for use on
3 mobile. This is the same networking stack that is used in the Chrome browser 3 mobile. This is the same networking stack that is used in the Chrome browser
4 by over a billion people. It offers an easy-to-use, high performance, 4 by over a billion people. It offers an easy-to-use, high performance,
5 standards-compliant, and secure way to perform HTTP requests. Cronet has support 5 standards-compliant, and secure way to perform HTTP requests. Cronet has support
6 for both Android and iOS. On Android, Cronet offers its own Java asynchronous 6 for both Android and iOS. On Android, Cronet offers its own Java asynchronous
7 API as well as support for the [java.net.HttpURLConnection] API. 7 API as well as support for the [java.net.HttpURLConnection] API.
8 This document gives a brief introduction to using these two Java APIs. 8 This document gives a brief introduction to using these two Java APIs.
9 9
10 ### Basics 10 ### Basics
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 To get more information about how Cronet is processing network 137 To get more information about how Cronet is processing network
138 requests, you can start and stop **NetLog** logging by calling 138 requests, you can start and stop **NetLog** logging by calling
139 `CronetEngine.startNetLogToFile` and `CronetEngine.stopNetLog`. 139 `CronetEngine.startNetLogToFile` and `CronetEngine.stopNetLog`.
140 Bear in mind that logs may contain sensitive data. You may analyze the 140 Bear in mind that logs may contain sensitive data. You may analyze the
141 generated log by navigating to [chrome://net-internals#import] using a 141 generated log by navigating to [chrome://net-internals#import] using a
142 Chrome browser. 142 Chrome browser.
143 143
144 # Using the java.net.HttpURLConnection API 144 # Using the java.net.HttpURLConnection API
145 Cronet offers an implementation of the [java.net.HttpURLConnection] API to make 145 Cronet offers an implementation of the [java.net.HttpURLConnection] API to make
146 it easier for apps which rely on this API to use Cronet. 146 it easier for apps which rely on this API to use Cronet.
147 To use Cronet's implementation instead of the system's default implementation, 147 To open individual connections using Cronet's implementation, do the following:
148 simply do the following:
149 148
150 CronetURLStreamHandlerFactory streamHandlerFactory = 149 HttpURLConnection connection =
151 new CronetURLStreamHandlerFactory(engine); 150 (HttpURLConnection)engine.openConnection(url);
152 URL.setURLStreamHandlerFactory(streamHandlerFactory); 151
152 To use Cronet's implementation instead of the system's default implementation
153 for all connections established using `URL.openConnection()` do the following:
154
155 URL.setURLStreamHandlerFactory(engine.createURLStreamHandlerFactory());
153 156
154 Cronet's 157 Cronet's
155 HttpURLConnection implementation has some limitations as compared to the system 158 HttpURLConnection implementation has some limitations as compared to the system
156 implementation, including not utilizing the default system HTTP cache (Please 159 implementation, including not utilizing the default system HTTP cache (Please
157 see {@link org.chromium.net.urlconnection.CronetURLStreamHandlerFactory} for 160 see {@link org.chromium.net.CronetEngine#createURLStreamHandlerFactory} for
158 more information). 161 more information).
159 You can configure Cronet and control caching through the 162 You can configure Cronet and control caching through the
160 `CronetEngine.Builder` instance, `engineBuilder` 163 `CronetEngine.Builder` instance, `engineBuilder`
161 (See [Configuring Cronet](#configuring-cronet) section), before you pass it 164 (See [Configuring Cronet](#configuring-cronet) section), before you build the
162 into the `CronetURLStreamHandlerFactory` constructor. 165 `CronetEngine` and then call `CronetEngine.createURLStreamHandlerFactory()`.
163 166
164 [ByteBuffer]: https://developer.android.com/reference/java/nio/ByteBuffer.html 167 [ByteBuffer]: https://developer.android.com/reference/java/nio/ByteBuffer.html
165 [chrome://net-internals#import]: chrome://net-internals#import 168 [chrome://net-internals#import]: chrome://net-internals#import
166 [java.net.HttpURLConnection]: https://developer.android.com/reference/java/net/H ttpURLConnection.html 169 [java.net.HttpURLConnection]: https://developer.android.com/reference/java/net/H ttpURLConnection.html
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/java/package-list » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698