blob: f01564e2094b7cbfb9e1adc6bdf1949f63ec0045 [file] [log] [blame]
[email protected]94de3e02014-06-17 00:09:511// 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.
4
5#ifndef COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_
6#define COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_
7
dchengfe3745e6242016-04-21 23:49:588#include <memory>
[email protected]94de3e02014-06-17 00:09:519#include <string>
10
mefc71361c2014-09-16 14:48:5611#include "base/macros.h"
xunjielida7f77022016-03-28 16:36:3612#include "base/memory/ref_counted.h"
mefc71361c2014-09-16 14:48:5613#include "base/memory/scoped_vector.h"
kapishnikovdf5ccab2015-12-03 18:38:5014#include "base/time/time.h"
pauljensen9041eb3c2015-12-09 12:29:0115#include "net/base/hash_value.h"
[email protected]94de3e02014-06-17 00:09:5116
xunjielida7f77022016-03-28 16:36:3617namespace base {
18class SequencedTaskRunner;
19} // namespace base
20
[email protected]94de3e02014-06-17 00:09:5121namespace net {
xunjieli013145f2015-10-20 23:20:1122class CertVerifier;
pauljensene92c4092015-12-09 19:13:4823class NetLog;
[email protected]94de3e02014-06-17 00:09:5124class URLRequestContextBuilder;
25} // namespace net
26
27namespace cronet {
28
29// Common configuration parameters used by Cronet to configure
pauljensen9041eb3c2015-12-09 12:29:0130// URLRequestContext.
[email protected]94de3e02014-06-17 00:09:5131struct URLRequestContextConfig {
pauljensen9041eb3c2015-12-09 12:29:0132 // Type of HTTP cache.
kapishnikovaa8f338c2016-10-28 16:17:3233 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net.impl
pauljensen9041eb3c2015-12-09 12:29:0134 enum HttpCacheType {
35 // No HTTP cache.
36 DISABLED,
37 // HTTP cache persisted to disk.
38 DISK,
39 // HTTP cache kept in memory.
40 MEMORY,
41 };
42
mefc71361c2014-09-16 14:48:5643 // App-provided hint that server supports QUIC.
44 struct QuicHint {
pauljensen9041eb3c2015-12-09 12:29:0145 QuicHint(const std::string& host, int port, int alternate_port);
mefc71361c2014-09-16 14:48:5646 ~QuicHint();
47
mefc71361c2014-09-16 14:48:5648 // Host name of the server that supports QUIC.
pauljensen9041eb3c2015-12-09 12:29:0149 const std::string host;
mefc71361c2014-09-16 14:48:5650 // Port of the server that supports QUIC.
pauljensen9041eb3c2015-12-09 12:29:0151 const int port;
mefc71361c2014-09-16 14:48:5652 // Alternate protocol port.
pauljensen9041eb3c2015-12-09 12:29:0153 const int alternate_port;
mefc71361c2014-09-16 14:48:5654
55 private:
56 DISALLOW_COPY_AND_ASSIGN(QuicHint);
57 };
58
kapishnikovdf5ccab2015-12-03 18:38:5059 // Public-Key-Pinning configuration structure.
60 struct Pkp {
pauljensen9041eb3c2015-12-09 12:29:0161 Pkp(const std::string& host,
62 bool include_subdomains,
63 const base::Time& expiration_date);
kapishnikovdf5ccab2015-12-03 18:38:5064 ~Pkp();
65
kapishnikovdf5ccab2015-12-03 18:38:5066 // Host name.
pauljensen9041eb3c2015-12-09 12:29:0167 const std::string host;
kapishnikovdf5ccab2015-12-03 18:38:5068 // Pin hashes (currently SHA256 only).
pauljensen9041eb3c2015-12-09 12:29:0169 net::HashValueVector pin_hashes;
kapishnikovdf5ccab2015-12-03 18:38:5070 // Indicates whether the pinning should apply to the pinned host subdomains.
pauljensen9041eb3c2015-12-09 12:29:0171 const bool include_subdomains;
kapishnikovdf5ccab2015-12-03 18:38:5072 // Expiration date for the pins.
pauljensen9041eb3c2015-12-09 12:29:0173 const base::Time expiration_date;
kapishnikovdf5ccab2015-12-03 18:38:5074
75 private:
76 DISALLOW_COPY_AND_ASSIGN(Pkp);
77 };
78
pauljensen9041eb3c2015-12-09 12:29:0179 URLRequestContextConfig(
80 // Enable QUIC.
81 bool enable_quic,
mefc5da5712016-02-09 20:14:2382 // QUIC User Agent ID.
83 const std::string& quic_user_agent_id,
pauljensen9041eb3c2015-12-09 12:29:0184 // Enable SPDY.
85 bool enable_spdy,
86 // Enable SDCH.
87 bool enable_sdch,
88 // Type of http cache.
89 HttpCacheType http_cache,
90 // Max size of http cache in bytes.
91 int http_cache_max_size,
92 // Disable caching for HTTP responses. Other information may be stored in
93 // the cache.
94 bool load_disable_cache,
95 // Storage path for http cache and cookie storage.
96 const std::string& storage_path,
97 // User-Agent request header field.
98 const std::string& user_agent,
99 // JSON encoded experimental options.
100 const std::string& experimental_options,
101 // Data reduction proxy key.
102 const std::string& data_reduction_proxy_key,
103 // Data reduction proxy.
104 const std::string& data_reduction_primary_proxy,
105 // Fallback data reduction proxy.
106 const std::string& data_reduction_fallback_proxy,
107 // Data reduction proxy secure proxy check URL.
108 const std::string& data_reduction_secure_proxy_check_url,
109 // MockCertVerifier to use for testing purposes.
tbansal7018e2a2016-06-25 00:40:39110 std::unique_ptr<net::CertVerifier> mock_cert_verifier,
111 // Enable network quality estimator.
kapishnikov385aa422016-07-01 20:53:02112 bool enable_network_quality_estimator,
113 // Enable bypassing of public key pinning for local trust anchors
rtenneti121f9fa2016-07-07 23:49:28114 bool bypass_public_key_pinning_for_local_trust_anchors,
115 // Certificate verifier cache data.
116 const std::string& cert_verifier_data);
[email protected]94de3e02014-06-17 00:09:51117 ~URLRequestContextConfig();
118
119 // Configure |context_builder| based on |this|.
120 void ConfigureURLRequestContextBuilder(
pauljensene92c4092015-12-09 19:13:48121 net::URLRequestContextBuilder* context_builder,
xunjielida7f77022016-03-28 16:36:36122 net::NetLog* net_log,
123 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
[email protected]94de3e02014-06-17 00:09:51124
[email protected]94de3e02014-06-17 00:09:51125 // Enable QUIC.
pauljensen9041eb3c2015-12-09 12:29:01126 const bool enable_quic;
mefc5da5712016-02-09 20:14:23127 // QUIC User Agent ID.
128 const std::string quic_user_agent_id;
[email protected]94de3e02014-06-17 00:09:51129 // Enable SPDY.
pauljensen9041eb3c2015-12-09 12:29:01130 const bool enable_spdy;
xunjielib8a6d56f2015-04-29 17:36:14131 // Enable SDCH.
pauljensen9041eb3c2015-12-09 12:29:01132 const bool enable_sdch;
133 // Type of http cache.
134 const HttpCacheType http_cache;
[email protected]94de3e02014-06-17 00:09:51135 // Max size of http cache in bytes.
pauljensen9041eb3c2015-12-09 12:29:01136 const int http_cache_max_size;
mefbb4f45c2015-01-12 18:03:25137 // Disable caching for HTTP responses. Other information may be stored in
138 // the cache.
pauljensen9041eb3c2015-12-09 12:29:01139 const bool load_disable_cache;
[email protected]94de3e02014-06-17 00:09:51140 // Storage path for http cache and cookie storage.
pauljensen9041eb3c2015-12-09 12:29:01141 const std::string storage_path;
mefd1907102014-11-07 17:46:48142 // User-Agent request header field.
pauljensen9041eb3c2015-12-09 12:29:01143 const std::string user_agent;
xunjieli61b1eaa2015-11-17 22:44:55144 // 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", ...}, ...}
pauljensen9041eb3c2015-12-09 12:29:01150 const std::string experimental_options;
bengr59cb6962015-05-13 17:55:58151 // Enable Data Reduction Proxy with authentication key.
pauljensen9041eb3c2015-12-09 12:29:01152 const std::string data_reduction_proxy_key;
153 const std::string data_reduction_primary_proxy;
154 const std::string data_reduction_fallback_proxy;
155 const std::string data_reduction_secure_proxy_check_url;
mefc71361c2014-09-16 14:48:56156
xunjieli013145f2015-10-20 23:20:11157 // Certificate verifier for testing.
dchengfe3745e6242016-04-21 23:49:58158 std::unique_ptr<net::CertVerifier> mock_cert_verifier;
xunjieli013145f2015-10-20 23:20:11159
tbansal7018e2a2016-06-25 00:40:39160 // Enable network quality estimator.
161 const bool enable_network_quality_estimator;
162
kapishnikov385aa422016-07-01 20:53:02163 // Enable public key pinning bypass for local trust anchors.
164 const bool bypass_public_key_pinning_for_local_trust_anchors;
165
rtenneti121f9fa2016-07-07 23:49:28166 // Data to populte CertVerifierCache.
167 const std::string cert_verifier_data;
168
pauljensen9041eb3c2015-12-09 12:29:01169 // App-provided list of servers that support QUIC.
170 ScopedVector<QuicHint> quic_hints;
171
172 // The list of public key pins.
173 ScopedVector<Pkp> pkp_list;
174
mefc71361c2014-09-16 14:48:56175 private:
176 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig);
[email protected]94de3e02014-06-17 00:09:51177};
178
179} // namespace cronet
180
181#endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_