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 6072f394d84cdde35069fc3a7e2f44eeb5ce490a..bf7599a68deb94bf9b1e000fe6f573be9224c574 100644 |
--- a/components/cronet/url_request_context_config.cc |
+++ b/components/cronet/url_request_context_config.cc |
@@ -17,71 +17,53 @@ |
namespace cronet { |
-namespace { |
- |
-// 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; |
-} |
- |
-} // 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& quic_connection_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), |
+ quic_connection_options(quic_connection_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()) {} |
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 { |
@@ -103,48 +85,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_QUIC_OPTIONS, |
- &URLRequestContextConfig::quic_connection_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 |