Commit b8a6d56f authored by xunjieli's avatar xunjieli Committed by Commit bot

Enable sdch in Cronet

This CL combined rdsmith@'s CL(747453004) and mef@'s
CL(1073193002), and added tests to make sure sdch works for
both the old and the new API.

BUG=414885

Review URL: https://codereview.chromium.org/1085903002

Cr-Commit-Position: refs/heads/master@{#327517}
parent e9ac6f32
......@@ -400,6 +400,17 @@ static jstring GetNegotiatedProtocol(JNIEnv* env,
return ConvertUTF8ToJavaString(env, negotiated_protocol.c_str()).Release();
}
static jboolean GetWasCached(JNIEnv* env,
jobject jcaller,
jlong jurl_request_adapter) {
URLRequestAdapter* request_adapter =
reinterpret_cast<URLRequestAdapter*>(jurl_request_adapter);
DCHECK(request_adapter);
bool was_cached = request_adapter->GetWasCached();
return was_cached ? JNI_TRUE : JNI_FALSE;
}
static void DisableRedirects(JNIEnv* env, jobject jcaller,
jlong jrequest_adapter) {
URLRequestAdapter* request_adapter =
......
......@@ -20,6 +20,7 @@
#include "net/http/http_auth_handler_factory.h"
#include "net/log/write_to_file_net_log_observer.h"
#include "net/proxy/proxy_service.h"
#include "net/sdch/sdch_owner.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
......@@ -161,6 +162,12 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
if (config->load_disable_cache)
default_load_flags_ |= net::LOAD_DISABLE_CACHE;
if (config->enable_sdch) {
DCHECK(context_->sdch_manager());
sdch_owner_.reset(
new net::SdchOwner(context_->sdch_manager(), context_.get()));
}
// Currently (circa M39) enabling QUIC requires setting probability threshold.
if (config->enable_quic) {
context_->http_server_properties()
......
......@@ -25,6 +25,7 @@ namespace net {
class WriteToFileNetLogObserver;
class URLRequestContext;
class ProxyConfigService;
class SdchOwner;
} // namespace net
namespace cronet {
......@@ -91,6 +92,7 @@ class CronetURLRequestContextAdapter {
scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_;
scoped_ptr<net::URLRequestContext> context_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::SdchOwner> sdch_owner_;
// Context config is only valid untng context is initialized.
scoped_ptr<URLRequestContextConfig> context_config_;
......
......@@ -421,6 +421,15 @@ public class ChromiumUrlRequest implements HttpUrlRequest {
}
}
@Override
public boolean wasCached() {
synchronized (mLock) {
validateNativeAdapterNotDestroyed();
validateHeadersAvailable();
return nativeGetWasCached(mUrlRequestAdapter);
}
}
@Override
public String getContentType() {
return mContentType;
......@@ -748,6 +757,8 @@ public class ChromiumUrlRequest implements HttpUrlRequest {
private native String nativeGetNegotiatedProtocol(long urlRequestAdapter);
private native boolean nativeGetWasCached(long urlRequestAdapter);
// Explicit class to work around JNI-generator generics confusion.
private static class ResponseHeadersMap extends
HashMap<String, List<String>> {
......
......@@ -12,6 +12,7 @@ import android.util.Log;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.VisibleForTesting;
/**
* Provides context for the native HTTP operations.
......@@ -95,6 +96,15 @@ public class ChromiumUrlRequestContext {
nativeStopNetLog(mChromiumUrlRequestContextAdapter);
}
/**
* Returns the native URLRequestContextAdapter pointer.
* Currently this method is only used in testing.
*/
@VisibleForTesting
long getUrlRequestContextAdapterForTesting() {
return mChromiumUrlRequestContextAdapter;
}
@CalledByNative
private void initNetworkThread() {
Thread.currentThread().setName("ChromiumNet");
......
......@@ -15,6 +15,7 @@ import android.util.Log;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.NativeClassQualifiedName;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.UsedByReflection;
import java.util.concurrent.Executor;
......@@ -152,6 +153,7 @@ public class CronetUrlRequestContext extends UrlRequestContext {
mActiveRequestCount.decrementAndGet();
}
@VisibleForTesting
long getUrlRequestContextAdapter() {
synchronized (mLock) {
checkHaveAdapter();
......
......@@ -433,6 +433,11 @@ class HttpUrlConnectionUrlRequest implements HttpUrlRequest {
return "";
}
@Override
public boolean wasCached() {
return false;
}
@Override
public int getHttpStatusCode() {
int httpStatusCode = mHttpStatusCode;
......
......@@ -113,6 +113,11 @@ public interface HttpUrlRequest {
*/
String getNegotiatedProtocol();
/**
* Returns whether the response is serviced from the cache.
*/
boolean wasCached();
/**
* Returns the entire response as a ByteBuffer.
*/
......
......@@ -15,14 +15,14 @@ import java.io.File;
* UrlRequestContext.
*/
public class UrlRequestContextConfig {
/**
* Default config enables SPDY, QUIC, in memory http cache.
* Default config enables SPDY, disables QUIC, SDCH and http cache.
*/
public UrlRequestContextConfig() {
enableLegacyMode(false);
enableQUIC(false);
enableSPDY(true);
enableSDCH(false);
enableHttpCache(HttpCache.DISABLED, 0);
}
......@@ -101,6 +101,13 @@ public class UrlRequestContextConfig {
return putBoolean(UrlRequestContextConfigList.ENABLE_SPDY, value);
}
/**
* Boolean, enable SDCH compression if true.
*/
public UrlRequestContextConfig enableSDCH(boolean value) {
return putBoolean(UrlRequestContextConfigList.ENABLE_SDCH, value);
}
/**
* Enumeration, disable or enable cache in memory or on disk.
*/
......
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Encoding: sdch
Domain: fake.sdch.domain
Path: /sdch/test
The quick brown fox jumps over the lazy dog.\n
HTTP/1.1 200 OK
Cache-Control: public, max-age=31536000
Content-Type: application/x-sdch-dictionary
// Copyright 2015 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;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.test.util.Feature;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Tests Sdch support.
*/
public class SdchTest extends CronetTestBase {
private CronetTestActivity mActivity;
private void setUp(boolean enableSdch) {
UrlRequestContextConfig config = new UrlRequestContextConfig();
config.enableSDCH(enableSdch);
config.setLibraryName("cronet_tests");
config.enableHttpCache(UrlRequestContextConfig.HttpCache.IN_MEMORY, 100 * 1024);
String[] commandLineArgs = {CronetTestActivity.CONFIG_KEY, config.toString()};
mActivity = launchCronetTestAppWithUrlAndCommandLineArgs(null, commandLineArgs);
mActivity.startNetLog();
// Registers custom DNS mapping for legacy ChromiumUrlRequestFactory.
ChromiumUrlRequestFactory factory = (ChromiumUrlRequestFactory) mActivity.mRequestFactory;
long legacyAdapter = factory.getRequestContext().getUrlRequestContextAdapterForTesting();
assertTrue(legacyAdapter != 0);
NativeTestServer.registerHostResolverProc(legacyAdapter, true);
// Registers custom DNS mapping for CronetUrlRequestContext.
CronetUrlRequestContext requestContext =
(CronetUrlRequestContext) mActivity.mUrlRequestContext;
long adapter = requestContext.getUrlRequestContextAdapter();
assertTrue(adapter != 0);
NativeTestServer.registerHostResolverProc(adapter, false);
// Starts NativeTestServer.
assertTrue(NativeTestServer.startNativeTestServer(getInstrumentation().getTargetContext()));
}
@Override
protected void tearDown() throws Exception {
NativeTestServer.shutdownNativeTestServer();
mActivity.stopNetLog();
super.tearDown();
}
@SmallTest
@Feature({"Cronet"})
public void testSdchEnabled_LegacyAPI() throws Exception {
setUp(true);
// Make a request to /sdch/index which advertises the dictionary.
TestHttpUrlRequestListener listener1 = startAndWaitForComplete_LegacyAPI(
NativeTestServer.getSdchURL() + "/sdch/index?q=LeQxM80O");
assertEquals(200, listener1.mHttpStatusCode);
assertEquals("This is an index page.\n", listener1.mResponseAsString);
assertEquals(Arrays.asList("/sdch/dict/LeQxM80O"),
listener1.mResponseHeaders.get("Get-Dictionary"));
waitForDictionaryAdded("LeQxM80O", true);
// Make a request to fetch encoded response at /sdch/test.
TestHttpUrlRequestListener listener2 =
startAndWaitForComplete_LegacyAPI(NativeTestServer.getSdchURL() + "/sdch/test");
assertEquals(200, listener2.mHttpStatusCode);
assertEquals("The quick brown fox jumps over the lazy dog.\n", listener2.mResponseAsString);
}
@SmallTest
@Feature({"Cronet"})
public void testSdchDisabled_LegacyAPI() throws Exception {
setUp(false);
// Make a request to /sdch/index.
// Since Sdch is not enabled, no dictionary should be advertised.
TestHttpUrlRequestListener listener = startAndWaitForComplete_LegacyAPI(
NativeTestServer.getSdchURL() + "/sdch/index?q=LeQxM80O");
assertEquals(200, listener.mHttpStatusCode);
assertEquals("This is an index page.\n", listener.mResponseAsString);
assertEquals(null, listener.mResponseHeaders.get("Get-Dictionary"));
}
@SmallTest
@Feature({"Cronet"})
public void testDictionaryNotFound_LegacyAPI() throws Exception {
setUp(true);
// Make a request to /sdch/index which advertises a bad dictionary that
// does not exist.
TestHttpUrlRequestListener listener1 = startAndWaitForComplete_LegacyAPI(
NativeTestServer.getSdchURL() + "/sdch/index?q=NotFound");
assertEquals(200, listener1.mHttpStatusCode);
assertEquals("This is an index page.\n", listener1.mResponseAsString);
assertEquals(Arrays.asList("/sdch/dict/NotFound"),
listener1.mResponseHeaders.get("Get-Dictionary"));
waitForDictionaryAdded("NotFound", true);
// Make a request to fetch /sdch/test, and make sure Sdch encoding is not used.
TestHttpUrlRequestListener listener2 =
startAndWaitForComplete_LegacyAPI(NativeTestServer.getSdchURL() + "/sdch/test");
assertEquals(200, listener2.mHttpStatusCode);
assertEquals("Sdch is not used.\n", listener2.mResponseAsString);
}
@SmallTest
@Feature({"Cronet"})
public void testSdchEnabled() throws Exception {
setUp(true);
// Make a request to /sdch which advertises the dictionary.
TestUrlRequestListener listener1 =
startAndWaitForComplete(NativeTestServer.getSdchURL() + "/sdch/index?q=LeQxM80O");
assertEquals(200, listener1.mResponseInfo.getHttpStatusCode());
assertEquals("This is an index page.\n", listener1.mResponseAsString);
assertEquals(Arrays.asList("/sdch/dict/LeQxM80O"),
listener1.mResponseInfo.getAllHeaders().get("Get-Dictionary"));
waitForDictionaryAdded("LeQxM80O", false);
// Make a request to fetch encoded response at /sdch/test.
TestUrlRequestListener listener2 =
startAndWaitForComplete(NativeTestServer.getSdchURL() + "/sdch/test");
assertEquals(200, listener1.mResponseInfo.getHttpStatusCode());
assertEquals("The quick brown fox jumps over the lazy dog.\n", listener2.mResponseAsString);
}
@SmallTest
@Feature({"Cronet"})
public void testSdchDisabled() throws Exception {
setUp(false);
// Make a request to /sdch.
// Since Sdch is not enabled, no dictionary should be advertised.
TestUrlRequestListener listener =
startAndWaitForComplete(NativeTestServer.getSdchURL() + "/sdch/index?q=LeQxM80O");
assertEquals(200, listener.mResponseInfo.getHttpStatusCode());
assertEquals("This is an index page.\n", listener.mResponseAsString);
assertEquals(null, listener.mResponseInfo.getAllHeaders().get("Get-Dictionary"));
}
@SmallTest
@Feature({"Cronet"})
public void testDictionaryNotFound() throws Exception {
setUp(true);
// Make a request to /sdch/index which advertises a bad dictionary that
// does not exist.
TestUrlRequestListener listener1 =
startAndWaitForComplete(NativeTestServer.getSdchURL() + "/sdch/index?q=NotFound");
assertEquals(200, listener1.mResponseInfo.getHttpStatusCode());
assertEquals("This is an index page.\n", listener1.mResponseAsString);
assertEquals(Arrays.asList("/sdch/dict/NotFound"),
listener1.mResponseInfo.getAllHeaders().get("Get-Dictionary"));
waitForDictionaryAdded("NotFound", false);
// Make a request to fetch /sdch/test, and make sure Sdch encoding is not used.
TestUrlRequestListener listener2 =
startAndWaitForComplete(NativeTestServer.getSdchURL() + "/sdch/test");
assertEquals(200, listener2.mResponseInfo.getHttpStatusCode());
assertEquals("Sdch is not used.\n", listener2.mResponseAsString);
}
/**
* Helper method to wait for dictionary to be fetched and added to the list of available
* dictionaries.
*/
private void waitForDictionaryAdded(String dict, boolean isLegacyAPI) throws Exception {
// Since Http cache is enabled, making a request to the dictionary explicitly will
// be served from the cache.
String url = NativeTestServer.getSdchURL() + "/sdch/dict/" + dict;
if (isLegacyAPI) {
TestHttpUrlRequestListener listener = startAndWaitForComplete_LegacyAPI(url);
if (dict.equals("NotFound")) {
assertEquals(404, listener.mHttpStatusCode);
} else {
assertEquals(200, listener.mHttpStatusCode);
assertTrue(listener.mWasCached);
}
} else {
TestUrlRequestListener listener = startAndWaitForComplete(url);
if (dict.equals("NotFound")) {
assertEquals(404, listener.mResponseInfo.getHttpStatusCode());
} else {
assertEquals(200, listener.mResponseInfo.getHttpStatusCode());
assertTrue(listener.mResponseInfo.wasCached());
}
}
// Now wait for dictionary to be added to the manager, which occurs
// asynchronously.
// TODO(xunjieli): Rather than setting an arbitrary delay, consider
// implementing a SdchObserver to watch for dictionary add events once
// add event is implemented in SdchObserver.
Thread.sleep(1000);
}
private TestHttpUrlRequestListener startAndWaitForComplete_LegacyAPI(String url)
throws Exception {
Map<String, String> headers = new HashMap<String, String>();
TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
HttpUrlRequest request = mActivity.mRequestFactory.createRequest(
url, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener);
request.start();
listener.blockForComplete();
return listener;
}
private TestUrlRequestListener startAndWaitForComplete(String url) throws Exception {
TestUrlRequestListener listener = new TestUrlRequestListener();
UrlRequest request =
mActivity.mUrlRequestContext.createRequest(url, listener, listener.getExecutor());
request.start();
listener.blockForDone();
return listener;
}
}
......@@ -26,6 +26,7 @@ public class TestHttpUrlRequestListener implements HttpUrlRequestListener {
public String mResponseAsString;
public Exception mException;
public Map<String, List<String>> mResponseHeaders;
public boolean mWasCached = false;
private final ConditionVariable mStarted = new ConditionVariable();
private final ConditionVariable mComplete = new ConditionVariable();
......@@ -42,6 +43,7 @@ public class TestHttpUrlRequestListener implements HttpUrlRequestListener {
mHttpStatusText = request.getHttpStatusText();
mNegotiatedProtocol = request.getNegotiatedProtocol();
mResponseHeaders = request.getAllHeaders();
mWasCached = request.wasCached();
mStarted.open();
}
......
......@@ -188,12 +188,14 @@ public class CronetTestActivity extends Activity {
}
public void startNetLog() {
mRequestFactory.startNetLogToFile(
Environment.getExternalStorageDirectory().getPath()
+ "/cronet_sample_netlog.json");
mRequestFactory.startNetLogToFile(Environment.getExternalStorageDirectory().getPath()
+ "/cronet_sample_netlog_old_api.json");
mUrlRequestContext.startNetLogToFile(Environment.getExternalStorageDirectory().getPath()
+ "/cronet_sample_netlog_new_api.json");
}
public void stopNetLog() {
mRequestFactory.stopNetLog();
mUrlRequestContext.stopNetLog();
}
}
......@@ -5,7 +5,9 @@
package org.chromium.net;
import android.content.Context;
import android.os.ConditionVariable;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
/**
......@@ -14,6 +16,8 @@ import org.chromium.base.JNINamespace;
*/
@JNINamespace("cronet")
public final class NativeTestServer {
private static final ConditionVariable sHostResolverBlock = new ConditionVariable();
public static boolean startNativeTestServer(Context context) {
return nativeStartNativeTestServer(
TestFilesInstaller.getInstalledPath(context));
......@@ -23,6 +27,19 @@ public final class NativeTestServer {
nativeShutdownNativeTestServer();
}
/**
* Registers customized DNS mapping for {@link NativeTestServer}.
* @param contextAdapter native context adapter object that this
* mapping should apply to.
* @param isLegacyAPI {@code true} if this context adapter is a part of the
* old API.
*/
public static void registerHostResolverProc(long contextAdapter, boolean isLegacyAPI) {
sHostResolverBlock.close();
nativeRegisterHostResolverProc(contextAdapter, isLegacyAPI);
sHostResolverBlock.block();
}
public static String getEchoBodyURL() {
return nativeGetEchoBodyURL();
}
......@@ -47,12 +64,24 @@ public final class NativeTestServer {
return nativeGetFileURL(filePath);
}
public static String getSdchURL() {
return nativeGetSdchURL();
}
@CalledByNative
private static void onHostResolverProcRegistered() {
sHostResolverBlock.open();
}
private static native boolean nativeStartNativeTestServer(String filePath);
private static native void nativeShutdownNativeTestServer();
private static native void nativeRegisterHostResolverProc(
long contextAdapter, boolean isLegacyAPI);
private static native String nativeGetEchoBodyURL();
private static native String nativeGetEchoHeaderURL(String header);
private static native String nativeGetEchoAllHeadersURL();
private static native String nativeGetEchoMethodURL();
private static native String nativeGetRedirectToEchoBody();
private static native String nativeGetFileURL(String filePath);
private static native String nativeGetSdchURL();
}
......@@ -114,6 +114,12 @@ std::string URLRequestAdapter::GetNegotiatedProtocol() const {
return url_request_->response_info().npn_negotiated_protocol;
}
bool URLRequestAdapter::GetWasCached() const {
if (url_request_ == NULL)
return false;
return url_request_->response_info().was_cached;
}
void URLRequestAdapter::Start() {
context_->PostTaskToNetworkThread(
FROM_HERE,
......
......@@ -118,6 +118,9 @@ class URLRequestAdapter : public net::URLRequest::Delegate {
// Get NPN or ALPN Negotiated Protocol (if any) from HttpResponseInfo.
std::string GetNegotiatedProtocol() const;
// Returns whether the response is serviced from cache.
bool GetWasCached() const;
// net::URLRequest::Delegate implementation:
void OnResponseStarted(net::URLRequest* request) override;
void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
......
......@@ -23,6 +23,7 @@
#include "net/http/http_server_properties.h"
#include "net/log/write_to_file_net_log_observer.h"
#include "net/proxy/proxy_service.h"
#include "net/sdch/sdch_owner.h"
#include "net/ssl/ssl_config_service_defaults.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context_builder.h"
......@@ -151,6 +152,12 @@ void URLRequestContextAdapter::InitRequestContextOnNetworkThread() {
context_.reset(context_builder.Build());
if (config_->enable_sdch) {
DCHECK(context_->sdch_manager());
sdch_owner_.reset(
new net::SdchOwner(context_->sdch_manager(), context_.get()));
}
// Currently (circa M39) enabling QUIC requires setting probability threshold.
if (config_->enable_quic) {
context_->http_server_properties()
......
......@@ -20,11 +20,9 @@
#include "net/url_request/url_request_context_getter.h"
namespace net {
class WriteToFileNetLogObserver;
class ProxyConfigService;
class SdchOwner;
} // namespace net
namespace cronet {
......@@ -109,6 +107,7 @@ class URLRequestContextAdapter : public net::URLRequestContextGetter {
scoped_ptr<NetLogObserver> net_log_observer_;
scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::SdchOwner> sdch_owner_;
scoped_ptr<URLRequestContextConfig> config_;
// A queue of tasks that need to be run after context has been initialized.
......
......@@ -78,6 +78,7 @@ void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic);
context_builder->set_quic_connection_options(
net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options));
context_builder->set_sdch_enabled(enable_sdch);
// TODO(mef): Use |config| to set cookies.
}
......@@ -92,6 +93,8 @@ void URLRequestContextConfig::RegisterJSONConverter(
&URLRequestContextConfig::enable_quic);
converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_SPDY,
&URLRequestContextConfig::enable_spdy);
converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_SDCH,
&URLRequestContextConfig::enable_sdch);
converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_HTTP_CACHE,
&URLRequestContextConfig::http_cache);
converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_LOAD_DISABLE_CACHE,
......
......@@ -58,6 +58,8 @@ struct URLRequestContextConfig {
bool enable_quic;
// Enable SPDY.
bool enable_spdy;
// Enable SDCH.
bool enable_sdch;
// Type of http cache: "HTTP_CACHE_DISABLED", "HTTP_CACHE_DISK" or
// "HTTP_CACHE_IN_MEMORY".
std::string http_cache;
......
......@@ -14,6 +14,7 @@ DEFINE_CONTEXT_CONFIG(ENABLE_LEGACY_MODE)
DEFINE_CONTEXT_CONFIG(NATIVE_LIBRARY_NAME)
DEFINE_CONTEXT_CONFIG(ENABLE_QUIC)
DEFINE_CONTEXT_CONFIG(ENABLE_SPDY)
DEFINE_CONTEXT_CONFIG(ENABLE_SDCH)
DEFINE_CONTEXT_CONFIG(HTTP_CACHE)
DEFINE_CONTEXT_CONFIG(HTTP_CACHE_MAX_SIZE)
......
......@@ -16,6 +16,7 @@
#include "net/base/cache_type.h"
#include "net/base/net_errors.h"
#include "net/base/network_delegate_impl.h"
#include "net/base/sdch_manager.h"
#include "net/cert/cert_verifier.h"
#include "net/cookies/cookie_monster.h"
#include "net/dns/host_resolver.h"
......@@ -205,7 +206,8 @@ URLRequestContextBuilder::URLRequestContextBuilder()
ftp_enabled_(false),
#endif
http_cache_enabled_(true),
throttling_enabled_(false) {
throttling_enabled_(false),
sdch_enabled_(false) {
}
URLRequestContextBuilder::~URLRequestContextBuilder() {}
......@@ -308,6 +310,11 @@ URLRequestContext* URLRequestContextBuilder::Build() {
new DefaultChannelIDStore(NULL), context->GetFileTaskRunner())));
}
if (sdch_enabled_) {
storage->set_sdch_manager(
scoped_ptr<net::SdchManager>(new SdchManager()).Pass());
}
storage->set_transport_security_state(new TransportSecurityState());
if (!transport_security_persister_path_.empty()) {
context->set_transport_security_persister(
......
......@@ -141,7 +141,6 @@ class NET_EXPORT URLRequestContextBuilder {
network_delegate_.reset(delegate);
}
// Adds additional auth handler factories to be used in addition to what is
// provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme|
// and |factory| are provided. The builder takes ownership of the factory and
......@@ -196,6 +195,13 @@ class NET_EXPORT URLRequestContextBuilder {
void SetFileTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// Note that if SDCH is enabled without a policy object observing
// the SDCH manager and handling at least Get-Dictionary events, the
// result will be "Content-Encoding: sdch" advertisements, but no
// dictionaries fetches and no specific dictionaries advertised.
// SdchOwner in net/sdch/sdch_owner.h is a simple policy object.
void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; }
URLRequestContext* Build();
private:
......@@ -221,6 +227,7 @@ class NET_EXPORT URLRequestContextBuilder {
#endif
bool http_cache_enabled_;
bool throttling_enabled_;
bool sdch_enabled_;
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
HttpCacheParams http_cache_params_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment