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

Unified Diff: components/cronet/url_request_context_config.cc

Issue 1429863008: [Cronet] Remove JSON serialization of CronetEngine.Builder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 5 years, 1 month 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/url_request_context_config.cc
diff --git a/components/cronet/url_request_context_config.cc b/components/cronet/url_request_context_config.cc
index ef94d0d89ca66831f883193f1a983adfb551ba54..79ff14351f4e2f7944e3ad31af63f1e91870aa5a 100644
--- a/components/cronet/url_request_context_config.cc
+++ b/components/cronet/url_request_context_config.cc
@@ -29,18 +29,6 @@ const char kQuicMaxNumberOfLossyConnections[] =
"max_number_of_lossy_connections";
const char kQuicPacketLossThreshold[] = "packet_loss_threshold";
-// Using a reference to scoped_ptr is unavoidable because of the semantics of
-// RegisterCustomField.
-// TODO(xunjieli): Remove this once crbug.com/544976 is fixed.
-bool GetMockCertVerifierFromString(
- const base::StringPiece& mock_cert_verifier_string,
- scoped_ptr<net::CertVerifier>* result) {
- int64 val;
- bool success = base::StringToInt64(mock_cert_verifier_string, &val);
- *result = make_scoped_ptr(reinterpret_cast<net::CertVerifier*>(val));
- return success;
-}
-
void ParseAndSetExperimentalOptions(
const std::string& experimental_options,
net::URLRequestContextBuilder* context_builder) {
@@ -105,55 +93,53 @@ void ParseAndSetExperimentalOptions(
} // namespace
-#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::QuicHint::QuicHint() {
-}
+URLRequestContextConfig::QuicHint::QuicHint(const std::string& host,
+ int port,
+ int alternate_port)
+ : host(host), port(port), alternate_port(alternate_port) {}
URLRequestContextConfig::QuicHint::~QuicHint() {
}
-// static
-void URLRequestContextConfig::QuicHint::RegisterJSONConverter(
- base::JSONValueConverter<URLRequestContextConfig::QuicHint>* converter) {
- converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_QUIC_HINT_HOST,
- &URLRequestContextConfig::QuicHint::host);
- converter->RegisterIntField(
- REQUEST_CONTEXT_CONFIG_QUIC_HINT_PORT,
- &URLRequestContextConfig::QuicHint::port);
- converter->RegisterIntField(
- REQUEST_CONTEXT_CONFIG_QUIC_HINT_ALT_PORT,
- &URLRequestContextConfig::QuicHint::alternate_port);
-}
-
-URLRequestContextConfig::URLRequestContextConfig() {}
+URLRequestContextConfig::URLRequestContextConfig(
+ bool enable_quic,
+ bool enable_spdy,
+ bool enable_sdch,
+ HttpCacheType http_cache,
+ int http_cache_max_size,
+ bool load_disable_cache,
+ const std::string& storage_path,
+ const std::string& user_agent,
+ const std::string& experimental_options,
+ const std::string& data_reduction_proxy_key,
+ const std::string& data_reduction_primary_proxy,
+ const std::string& data_reduction_fallback_proxy,
+ const std::string& data_reduction_secure_proxy_check_url,
+ scoped_ptr<net::CertVerifier> mock_cert_verifier)
+ : enable_quic(enable_quic),
+ enable_spdy(enable_spdy),
+ enable_sdch(enable_sdch),
+ http_cache(http_cache),
+ http_cache_max_size(http_cache_max_size),
+ load_disable_cache(load_disable_cache),
+ storage_path(storage_path),
+ user_agent(user_agent),
+ experimental_options(experimental_options),
+ data_reduction_proxy_key(data_reduction_proxy_key),
+ data_reduction_primary_proxy(data_reduction_primary_proxy),
+ data_reduction_fallback_proxy(data_reduction_fallback_proxy),
+ data_reduction_secure_proxy_check_url(
+ data_reduction_secure_proxy_check_url),
+ mock_cert_verifier(mock_cert_verifier.Pass()) {}
xunjieli 2015/12/01 20:40:20 nit: std::move is now preferred over .Pass(). see:
pauljensen 2015/12/02 03:50:02 Done.
URLRequestContextConfig::~URLRequestContextConfig() {}
-bool URLRequestContextConfig::LoadFromJSON(const std::string& config_string) {
- scoped_ptr<base::Value> config_value = base::JSONReader::Read(config_string);
- if (!config_value || !config_value->IsType(base::Value::TYPE_DICTIONARY)) {
- DLOG(ERROR) << "Bad JSON: " << config_string;
- return false;
- }
-
- base::JSONValueConverter<URLRequestContextConfig> converter;
- if (!converter.Convert(*config_value, this)) {
- DLOG(ERROR) << "Bad Config: " << config_value;
- return false;
- }
- return true;
-}
-
void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
net::URLRequestContextBuilder* context_builder) {
std::string config_cache;
- if (http_cache != REQUEST_CONTEXT_CONFIG_HTTP_CACHE_DISABLED) {
+ if (http_cache != DISABLED) {
net::URLRequestContextBuilder::HttpCacheParams cache_params;
- if (http_cache == REQUEST_CONTEXT_CONFIG_HTTP_CACHE_DISK &&
- !storage_path.empty()) {
+ if (http_cache == DISK && !storage_path.empty()) {
cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK;
cache_params.path = base::FilePath(storage_path);
} else {
@@ -176,48 +162,4 @@ void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
// TODO(mef): Use |config| to set cookies.
}
-// static
-void URLRequestContextConfig::RegisterJSONConverter(
- base::JSONValueConverter<URLRequestContextConfig>* converter) {
- converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_USER_AGENT,
- &URLRequestContextConfig::user_agent);
- converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_STORAGE_PATH,
- &URLRequestContextConfig::storage_path);
- converter->RegisterBoolField(REQUEST_CONTEXT_CONFIG_ENABLE_QUIC,
- &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,
- &URLRequestContextConfig::load_disable_cache);
- converter->RegisterIntField(REQUEST_CONTEXT_CONFIG_HTTP_CACHE_MAX_SIZE,
- &URLRequestContextConfig::http_cache_max_size);
- converter->RegisterRepeatedMessage(REQUEST_CONTEXT_CONFIG_QUIC_HINTS,
- &URLRequestContextConfig::quic_hints);
- converter->RegisterStringField(
- REQUEST_CONTEXT_CONFIG_EXPERIMENTAL_OPTIONS,
- &URLRequestContextConfig::experimental_options);
- converter->RegisterStringField(
- REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PRIMARY_PROXY,
- &URLRequestContextConfig::data_reduction_primary_proxy);
- converter->RegisterStringField(
- REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_FALLBACK_PROXY,
- &URLRequestContextConfig::data_reduction_fallback_proxy);
- converter->RegisterStringField(
- REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_SECURE_PROXY_CHECK_URL,
- &URLRequestContextConfig::data_reduction_secure_proxy_check_url);
- converter->RegisterStringField(
- REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY,
- &URLRequestContextConfig::data_reduction_proxy_key);
-
- // For Testing.
- converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>(
- REQUEST_CONTEXT_CONFIG_MOCK_CERT_VERIFIER,
- &URLRequestContextConfig::mock_cert_verifier,
- &GetMockCertVerifierFromString);
-}
-
} // namespace cronet

Powered by Google App Engine
This is Rietveld 408576698