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

Side by Side Diff: components/cronet/url_request_context_config.cc

Issue 2954753002: Add Cronet experimental option for host cache persistence (Closed)
Patch Set: address comments Created 3 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cronet/url_request_context_config.h" 5 #include "components/cronet/url_request_context_config.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const char kStaleDnsDelayMs[] = "delay_ms"; 66 const char kStaleDnsDelayMs[] = "delay_ms";
67 // Name of integer maximum age (past expiration) in milliseconds of a stale DNS 67 // Name of integer maximum age (past expiration) in milliseconds of a stale DNS
68 // result that will be used, or 0 for no limit. 68 // result that will be used, or 0 for no limit.
69 const char kStaleDnsMaxExpiredTimeMs[] = "max_expired_time_ms"; 69 const char kStaleDnsMaxExpiredTimeMs[] = "max_expired_time_ms";
70 // Name of integer maximum times each stale DNS result can be used, or 0 for no 70 // Name of integer maximum times each stale DNS result can be used, or 0 for no
71 // limit. 71 // limit.
72 const char kStaleDnsMaxStaleUses[] = "max_stale_uses"; 72 const char kStaleDnsMaxStaleUses[] = "max_stale_uses";
73 // Name of boolean to allow stale DNS results from other networks to be used on 73 // Name of boolean to allow stale DNS results from other networks to be used on
74 // the current network. 74 // the current network.
75 const char kStaleDnsAllowOtherNetwork[] = "allow_other_network"; 75 const char kStaleDnsAllowOtherNetwork[] = "allow_other_network";
76 // Name of boolean to enable persisting the DNS cache to disk.
77 const char kStaleDnsPersist[] = "persist_to_disk";
78 // Name of integer minimum time in milliseconds between writes to disk for DNS
79 // cache persistence. Default value is one minute. Only relevant if
80 // "persist_to_disk" is true.
81 const char kStaleDnsPersistTimer[] = "persist_delay_ms";
76 82
77 // Rules to override DNS resolution. Intended for testing. 83 // Rules to override DNS resolution. Intended for testing.
78 // See explanation of format in net/dns/mapped_host_resolver.h. 84 // See explanation of format in net/dns/mapped_host_resolver.h.
79 const char kHostResolverRulesFieldTrialName[] = "HostResolverRules"; 85 const char kHostResolverRulesFieldTrialName[] = "HostResolverRules";
80 const char kHostResolverRules[] = "host_resolver_rules"; 86 const char kHostResolverRules[] = "host_resolver_rules";
81 87
82 // Disable IPv6 when on WiFi. This is a workaround for a known issue on certain 88 // Disable IPv6 when on WiFi. This is a workaround for a known issue on certain
83 // Android phones, and should not be necessary when not on one of those devices. 89 // Android phones, and should not be necessary when not on one of those devices.
84 // See https://crbug.com/696569 for details. 90 // See https://crbug.com/696569 for details.
85 const char kDisableIPv6OnWifi[] = "disable_ipv6_on_wifi"; 91 const char kDisableIPv6OnWifi[] = "disable_ipv6_on_wifi";
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 base::TimeDelta::FromMilliseconds(max_expired_time_ms); 291 base::TimeDelta::FromMilliseconds(max_expired_time_ms);
286 } 292 }
287 int max_stale_uses; 293 int max_stale_uses;
288 if (stale_dns_args->GetInteger(kStaleDnsMaxStaleUses, &max_stale_uses)) 294 if (stale_dns_args->GetInteger(kStaleDnsMaxStaleUses, &max_stale_uses))
289 stale_dns_options.max_stale_uses = max_stale_uses; 295 stale_dns_options.max_stale_uses = max_stale_uses;
290 bool allow_other_network; 296 bool allow_other_network;
291 if (stale_dns_args->GetBoolean(kStaleDnsAllowOtherNetwork, 297 if (stale_dns_args->GetBoolean(kStaleDnsAllowOtherNetwork,
292 &allow_other_network)) { 298 &allow_other_network)) {
293 stale_dns_options.allow_other_network = allow_other_network; 299 stale_dns_options.allow_other_network = allow_other_network;
294 } 300 }
301 bool persist;
302 if (stale_dns_args->GetBoolean(kStaleDnsPersist, &persist))
303 enable_host_cache_persistence = persist;
304 int persist_timer;
305 if (stale_dns_args->GetInteger(kStaleDnsPersistTimer, &persist_timer))
306 host_cache_persistence_delay_ms = persist_timer;
295 } 307 }
296 } else if (it.key() == kHostResolverRulesFieldTrialName) { 308 } else if (it.key() == kHostResolverRulesFieldTrialName) {
297 const base::DictionaryValue* host_resolver_rules_args = nullptr; 309 const base::DictionaryValue* host_resolver_rules_args = nullptr;
298 if (!it.value().GetAsDictionary(&host_resolver_rules_args)) { 310 if (!it.value().GetAsDictionary(&host_resolver_rules_args)) {
299 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value() 311 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value()
300 << "\" is not a dictionary value"; 312 << "\" is not a dictionary value";
301 effective_experimental_options->Remove(it.key(), nullptr); 313 effective_experimental_options->Remove(it.key(), nullptr);
302 continue; 314 continue;
303 } 315 }
304 host_resolver_rules_enable = host_resolver_rules_args->GetString( 316 host_resolver_rules_enable = host_resolver_rules_args->GetString(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 URLRequestContextConfigBuilder::Build() { 422 URLRequestContextConfigBuilder::Build() {
411 return base::MakeUnique<URLRequestContextConfig>( 423 return base::MakeUnique<URLRequestContextConfig>(
412 enable_quic, quic_user_agent_id, enable_spdy, enable_sdch, enable_brotli, 424 enable_quic, quic_user_agent_id, enable_spdy, enable_sdch, enable_brotli,
413 http_cache, http_cache_max_size, load_disable_cache, storage_path, 425 http_cache, http_cache_max_size, load_disable_cache, storage_path,
414 user_agent, experimental_options, std::move(mock_cert_verifier), 426 user_agent, experimental_options, std::move(mock_cert_verifier),
415 enable_network_quality_estimator, 427 enable_network_quality_estimator,
416 bypass_public_key_pinning_for_local_trust_anchors, cert_verifier_data); 428 bypass_public_key_pinning_for_local_trust_anchors, cert_verifier_data);
417 } 429 }
418 430
419 } // namespace cronet 431 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698