| OLD | NEW |
| 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 #ifndef COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ | 5 #ifndef COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ |
| 6 #define COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ | 6 #define COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "net/base/hash_value.h" | 16 #include "net/base/hash_value.h" |
| 17 #include "net/cert/cert_verifier.h" | 17 #include "net/cert/cert_verifier.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 21 } // namespace base | 21 } // namespace base |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 class CertVerifier; | 24 class CertVerifier; |
| 25 class NetLog; | 25 class NetLog; |
| 26 class NetworkQualityEstimatorParams; |
| 26 class URLRequestContextBuilder; | 27 class URLRequestContextBuilder; |
| 27 } // namespace net | 28 } // namespace net |
| 28 | 29 |
| 29 namespace cronet { | 30 namespace cronet { |
| 30 | 31 |
| 31 // Common configuration parameters used by Cronet to configure | 32 // Common configuration parameters used by Cronet to configure |
| 32 // URLRequestContext. | 33 // URLRequestContext. |
| 33 // TODO(mgersh): This shouldn't be a struct, and experimental option parsing | 34 // TODO(mgersh): This shouldn't be a struct, and experimental option parsing |
| 34 // should be kept more separate from applying the configuration. | 35 // should be kept more separate from applying the configuration. |
| 35 struct URLRequestContextConfig { | 36 struct URLRequestContextConfig { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 const HttpCacheType http_cache; | 135 const HttpCacheType http_cache; |
| 135 // Max size of http cache in bytes. | 136 // Max size of http cache in bytes. |
| 136 const int http_cache_max_size; | 137 const int http_cache_max_size; |
| 137 // Disable caching for HTTP responses. Other information may be stored in | 138 // Disable caching for HTTP responses. Other information may be stored in |
| 138 // the cache. | 139 // the cache. |
| 139 const bool load_disable_cache; | 140 const bool load_disable_cache; |
| 140 // Storage path for http cache and cookie storage. | 141 // Storage path for http cache and cookie storage. |
| 141 const std::string storage_path; | 142 const std::string storage_path; |
| 142 // User-Agent request header field. | 143 // User-Agent request header field. |
| 143 const std::string user_agent; | 144 const std::string user_agent; |
| 144 // Experimental options encoded as a string in a JSON format containing | |
| 145 // experiments and their corresponding configuration options. The format | |
| 146 // is a JSON object with the name of the experiment as the key, and the | |
| 147 // configuration options as the value. An example: | |
| 148 // {"experiment1": {"option1": "option_value1", "option2": "option_value2", | |
| 149 // ...}, "experiment2: {"option3", "option_value3", ...}, ...} | |
| 150 const std::string experimental_options; | |
| 151 | 145 |
| 152 // Certificate verifier for testing. | 146 // Certificate verifier for testing. |
| 153 std::unique_ptr<net::CertVerifier> mock_cert_verifier; | 147 std::unique_ptr<net::CertVerifier> mock_cert_verifier; |
| 154 | 148 |
| 155 // Enable network quality estimator. | 149 // Enable network quality estimator. |
| 156 const bool enable_network_quality_estimator; | 150 const bool enable_network_quality_estimator; |
| 157 | 151 |
| 158 // Enable public key pinning bypass for local trust anchors. | 152 // Enable public key pinning bypass for local trust anchors. |
| 159 const bool bypass_public_key_pinning_for_local_trust_anchors; | 153 const bool bypass_public_key_pinning_for_local_trust_anchors; |
| 160 | 154 |
| 161 // Data to populte CertVerifierCache. | 155 // Data to populte CertVerifierCache. |
| 162 const std::string cert_verifier_data; | 156 const std::string cert_verifier_data; |
| 163 | 157 |
| 164 // App-provided list of servers that support QUIC. | 158 // App-provided list of servers that support QUIC. |
| 165 std::vector<std::unique_ptr<QuicHint>> quic_hints; | 159 std::vector<std::unique_ptr<QuicHint>> quic_hints; |
| 166 | 160 |
| 167 // The list of public key pins. | 161 // The list of public key pins. |
| 168 std::vector<std::unique_ptr<Pkp>> pkp_list; | 162 std::vector<std::unique_ptr<Pkp>> pkp_list; |
| 169 | 163 |
| 170 // Experimental options that are recognized by the config parser. | 164 // Experimental options that are recognized by the config parser. |
| 171 std::unique_ptr<base::DictionaryValue> effective_experimental_options = | 165 std::unique_ptr<base::DictionaryValue> effective_experimental_options = |
| 172 nullptr; | 166 nullptr; |
| 173 | 167 |
| 168 // Configuration parameters for the network quality estimator. |
| 169 std::unique_ptr<net::NetworkQualityEstimatorParams> nqe_params; |
| 170 |
| 174 private: | 171 private: |
| 175 // Parses experimental options and makes appropriate changes to settings in | 172 // Parses experimental options and makes appropriate changes to settings in |
| 176 // the URLRequestContextConfig and URLRequestContextBuilder. | 173 // the URLRequestContextConfig and URLRequestContextBuilder. |
| 177 void ParseAndSetExperimentalOptions( | 174 void ParseAndSetExperimentalOptions( |
| 178 net::URLRequestContextBuilder* context_builder, | 175 net::URLRequestContextBuilder* context_builder, |
| 179 net::NetLog* net_log, | 176 net::NetLog* net_log, |
| 180 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); | 177 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); |
| 181 | 178 |
| 179 // Experimental options encoded as a string in a JSON format containing |
| 180 // experiments and their corresponding configuration options. The format |
| 181 // is a JSON object with the name of the experiment as the key, and the |
| 182 // configuration options as the value. An example: |
| 183 // {"experiment1": {"option1": "option_value1", "option2": "option_value2", |
| 184 // ...}, "experiment2: {"option3", "option_value3", ...}, ...} |
| 185 const std::string experimental_options; |
| 186 |
| 182 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); | 187 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); |
| 183 }; | 188 }; |
| 184 | 189 |
| 185 // Stores intermediate state for URLRequestContextConfig. Initializes with | 190 // Stores intermediate state for URLRequestContextConfig. Initializes with |
| 186 // (mostly) sane defaults, then the appropriate member variables can be | 191 // (mostly) sane defaults, then the appropriate member variables can be |
| 187 // modified, and it can be finalized with Build(). | 192 // modified, and it can be finalized with Build(). |
| 188 struct URLRequestContextConfigBuilder { | 193 struct URLRequestContextConfigBuilder { |
| 189 URLRequestContextConfigBuilder(); | 194 URLRequestContextConfigBuilder(); |
| 190 ~URLRequestContextConfigBuilder(); | 195 ~URLRequestContextConfigBuilder(); |
| 191 | 196 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // Data to populate CertVerifierCache. | 241 // Data to populate CertVerifierCache. |
| 237 std::string cert_verifier_data = ""; | 242 std::string cert_verifier_data = ""; |
| 238 | 243 |
| 239 private: | 244 private: |
| 240 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfigBuilder); | 245 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfigBuilder); |
| 241 }; | 246 }; |
| 242 | 247 |
| 243 } // namespace cronet | 248 } // namespace cronet |
| 244 | 249 |
| 245 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ | 250 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ |
| OLD | NEW |