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

Unified Diff: components/cronet/README.md

Issue 1363723002: [Cronet] Create Builders, rename UrlRequestContext to CronetEngine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address mef's comments Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/README.md
diff --git a/components/cronet/README.md b/components/cronet/README.md
index eb7d81a399677366a626da387584ee0396e0783d..8c1764fb335b0cd4cbd80f1d036940213091299e 100644
--- a/components/cronet/README.md
+++ b/components/cronet/README.md
@@ -68,14 +68,13 @@ events during the lifetime of a request. For example:
Make a request like this:
- UrlRequestContextConfig myConfig = new UrlRequestContextConfig();
- CronetUrlRequestContext myRequestContext =
- new CronetUrlRequestContext(getContext(), myConfig);
+ CronetEngine.Builder engineBuilder = new CronetEngine.Builder();
+ CronetEngine engine = engineBuilder.build(getContext());
xunjieli 2015/09/28 14:57:05 I usually see build method with 0 argument. Should
mef 2015/09/28 16:31:38 My concern with having setter is that it is not ap
Executor executor = Executors.newSingleThreadExecutor();
MyListener listener = new MyListener();
- UrlRequest request = myRequestContext.createRequest(
+ UrlRequest.Builder requestBuilder = new UrlRequest.Builder(
"https://www.example.com", listener, executor);
xunjieli 2015/09/28 14:57:05 Why doesn't the UrlRequest.Builder have a build me
mef 2015/09/28 16:31:38 I see your point, but what would somebody do with
mef 2015/09/28 17:13:37 I take it back. Looking at http://cr.openjdk.java.
- request.start();
+ UrlRequest request = engine.executeRequest(requestBuilder);
In the above example, `MyListener` extends `UrlRequestListener`. The request
is started asynchronously. When the response is ready (fully or partially), and
@@ -97,9 +96,8 @@ which signals the completion of the request.
### Uploading Data
MyUploadDataProvider myUploadDataProvider = new MyUploadDataProvider();
- request.setHttpMethod("POST");
- request.setUploadDataProvider(myUploadDataProvider, executor);
- request.start();
+ requestBuilder.setHttpMethod("POST");
+ requestBuilder.setUploadDataProvider(myUploadDataProvider, executor);
In the above example, `MyUploadDataProvider` extends `UploadDataProvider`.
When Cronet is ready to send the request body,
@@ -112,32 +110,32 @@ request body into `byteBuffer`. Once the client is done writing into
invoked again. For more details, please see the API reference.
### <a id=configuring-cronet></a> Configuring Cronet
-Various configuration options are available via the `UrlRequestContextConfig`
+Various configuration options are available via the `CronetEngine.Builder`
object.
Enabling HTTP/2, QUIC, or SDCH:
- For Example:
- myConfig.enableSPDY(true).enableQUIC(true).enableSDCH(true);
+ engineBuilder.enableSPDY(true).enableQUIC(true).enableSDCH(true);
Controlling the cache:
- Use a 100KiB in-memory cache:
- myConfig.enableHttpCache(
- UrlRequestContextConfig.HttpCache.IN_MEMORY, 100 * 1024);
+ engineBuilder.enableHttpCache(
+ CronetEngine.Builder.HttpCache.IN_MEMORY, 100 * 1024);
- or use a 1MiB disk cache:
- myConfig.setStoragePath(storagePathString);
- myConfig.enableHttpCache(UrlRequestContextConfig.HttpCache.DISK,
+ engineBuilder.setStoragePath(storagePathString);
+ engineBuilder.enableHttpCache(CronetEngine.Builder.HttpCache.DISK,
1024 * 1024);
### Debugging
To get more information about how Cronet is processing network
requests, you can start and stop **NetLog** logging by calling
-`UrlRequestContext.startNetLogToFile` and `UrlRequestContext.stopNetLog`.
+`CronetEngine.startNetLogToFile` and `CronetEngine.stopNetLog`.
Bear in mind that logs may contain sensitive data. You may analyze the
generated log by navigating to [chrome://net-internals#import] using a
Chrome browser.
@@ -149,7 +147,7 @@ To use Cronet's implementation instead of the system's default implementation,
simply do the following:
CronetURLStreamHandlerFactory streamHandlerFactory =
- new CronetURLStreamHandlerFactory(getContext(), myConfig);
+ new CronetURLStreamHandlerFactory(getContext(), engineBuilder);
URL.setURLStreamHandlerFactory(streamHandlerFactory);
Cronet's
@@ -158,7 +156,7 @@ implementation, including not utilizing the default system HTTP cache (Please
see {@link org.chromium.net.urlconnection.CronetURLStreamHandlerFactory} for
more information).
You can configure Cronet and control caching through the
-`UrlRequestContextConfig` instance, `myConfig`
+`CronetEngine.Builder` instance, `engineBuilder`
(See [Configuring Cronet](#configuring-cronet) section), before you pass it
into the `CronetURLStreamHandlerFactory` constructor.

Powered by Google App Engine
This is Rietveld 408576698