Flag myIpAddress requests for chromeos
[chromium-blink-merge.git] / components / cronet / url_request_context_config.cc
blob11f2def56ce009bdc6805ab2cc8c30fc711ecf89
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
3 // found in the LICENSE file.
5 #include "components/cronet/url_request_context_config.h"
7 #include "net/url_request/url_request_context_builder.h"
9 namespace cronet {
11 #define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x;
12 #include "components/cronet/url_request_context_config_list.h"
13 #undef DEFINE_CONTEXT_CONFIG
15 URLRequestContextConfig::URLRequestContextConfig() {
18 URLRequestContextConfig::~URLRequestContextConfig() {
21 void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
22 net::URLRequestContextBuilder* context_builder) {
23 std::string config_cache;
24 if (http_cache != REQUEST_CONTEXT_CONFIG_HTTP_CACHE_DISABLED) {
25 net::URLRequestContextBuilder::HttpCacheParams cache_params;
26 if (http_cache == REQUEST_CONTEXT_CONFIG_HTTP_CACHE_DISK &&
27 !storage_path.empty()) {
28 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK;
29 cache_params.path = base::FilePath(storage_path);
30 } else {
31 cache_params.type =
32 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY;
34 cache_params.max_size = http_cache_max_size;
35 context_builder->EnableHttpCache(cache_params);
36 } else {
37 context_builder->DisableHttpCache();
40 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic);
41 // TODO(mef): Use |config| to set cookies.
44 // static
45 void URLRequestContextConfig::RegisterJSONConverter(
46 base::JSONValueConverter<URLRequestContextConfig>* converter) {
47 converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_QUIC,
48 &URLRequestContextConfig::enable_quic);
49 converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_SPDY,
50 &URLRequestContextConfig::enable_spdy);
51 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_HTTP_CACHE,
52 &URLRequestContextConfig::http_cache);
53 converter->RegisterIntField(REQUEST_CONTEXT_CONFIG_HTTP_CACHE_MAX_SIZE,
54 &URLRequestContextConfig::http_cache_max_size);
55 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_STORAGE_PATH,
56 &URLRequestContextConfig::storage_path);
59 } // namespace cronet