summaryrefslogtreecommitdiffstats
path: root/components/cronet/url_request_context_config.cc
diff options
context:
space:
mode:
authormef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 00:09:51 +0000
committermef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 00:09:51 +0000
commit94de3e05dbde532c58791bac7f15266d896d3663 (patch)
tree4cfae92f2a2f3d1ff41bd36c424ce89c59db8383 /components/cronet/url_request_context_config.cc
parentc4b47790aa56e82303b224dcdb9be8b5dd79ed80 (diff)
downloadchromium_src-94de3e05dbde532c58791bac7f15266d896d3663.zip
chromium_src-94de3e05dbde532c58791bac7f15266d896d3663.tar.gz
chromium_src-94de3e05dbde532c58791bac7f15266d896d3663.tar.bz2
Added Cronet HttpUrlRequestFactoryConfig.
BUG=354143 Review URL: https://codereview.chromium.org/260553002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/cronet/url_request_context_config.cc')
-rw-r--r--components/cronet/url_request_context_config.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/components/cronet/url_request_context_config.cc b/components/cronet/url_request_context_config.cc
new file mode 100644
index 0000000..11f2def
--- /dev/null
+++ b/components/cronet/url_request_context_config.cc
@@ -0,0 +1,59 @@
+// Copyright 2014 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.
+
+#include "components/cronet/url_request_context_config.h"
+
+#include "net/url_request/url_request_context_builder.h"
+
+namespace cronet {
+
+#define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x;
+#include "components/cronet/url_request_context_config_list.h"
+#undef DEFINE_CONTEXT_CONFIG
+
+URLRequestContextConfig::URLRequestContextConfig() {
+}
+
+URLRequestContextConfig::~URLRequestContextConfig() {
+}
+
+void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
+ net::URLRequestContextBuilder* context_builder) {
+ std::string config_cache;
+ if (http_cache != REQUEST_CONTEXT_CONFIG_HTTP_CACHE_DISABLED) {
+ net::URLRequestContextBuilder::HttpCacheParams cache_params;
+ if (http_cache == REQUEST_CONTEXT_CONFIG_HTTP_CACHE_DISK &&
+ !storage_path.empty()) {
+ cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK;
+ cache_params.path = base::FilePath(storage_path);
+ } else {
+ cache_params.type =
+ net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY;
+ }
+ cache_params.max_size = http_cache_max_size;
+ context_builder->EnableHttpCache(cache_params);
+ } else {
+ context_builder->DisableHttpCache();
+ }
+
+ context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic);
+ // TODO(mef): Use |config| to set cookies.
+}
+
+// static
+void URLRequestContextConfig::RegisterJSONConverter(
+ base::JSONValueConverter<URLRequestContextConfig>* converter) {
+ converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_QUIC,
+ &URLRequestContextConfig::enable_quic);
+ converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_SPDY,
+ &URLRequestContextConfig::enable_spdy);
+ converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_HTTP_CACHE,
+ &URLRequestContextConfig::http_cache);
+ converter->RegisterIntField(REQUEST_CONTEXT_CONFIG_HTTP_CACHE_MAX_SIZE,
+ &URLRequestContextConfig::http_cache_max_size);
+ converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_STORAGE_PATH,
+ &URLRequestContextConfig::storage_path);
+}
+
+} // namespace cronet