blob: 3c84b33c817d48e28b3d74c01fc9b157984bb085 [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
8#include <string>
9
mefc71361c2014-09-16 14:48:5610#include "base/macros.h"
xunjielida7f77022016-03-28 16:36:3611#include "base/memory/ref_counted.h"
12#include "base/memory/scoped_ptr.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.
33 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
34 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.
110 scoped_ptr<net::CertVerifier> mock_cert_verifier);
[email protected]94de3e02014-06-17 00:09:51111 ~URLRequestContextConfig();
112
113 // Configure |context_builder| based on |this|.
114 void ConfigureURLRequestContextBuilder(
pauljensene92c4092015-12-09 19:13:48115 net::URLRequestContextBuilder* context_builder,
xunjielida7f77022016-03-28 16:36:36116 net::NetLog* net_log,
117 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
[email protected]94de3e02014-06-17 00:09:51118
[email protected]94de3e02014-06-17 00:09:51119 // Enable QUIC.
pauljensen9041eb3c2015-12-09 12:29:01120 const bool enable_quic;
mefc5da5712016-02-09 20:14:23121 // QUIC User Agent ID.
122 const std::string quic_user_agent_id;
[email protected]94de3e02014-06-17 00:09:51123 // Enable SPDY.
pauljensen9041eb3c2015-12-09 12:29:01124 const bool enable_spdy;
xunjielib8a6d56f2015-04-29 17:36:14125 // Enable SDCH.
pauljensen9041eb3c2015-12-09 12:29:01126 const bool enable_sdch;
127 // Type of http cache.
128 const HttpCacheType http_cache;
[email protected]94de3e02014-06-17 00:09:51129 // Max size of http cache in bytes.
pauljensen9041eb3c2015-12-09 12:29:01130 const int http_cache_max_size;
mefbb4f45c2015-01-12 18:03:25131 // Disable caching for HTTP responses. Other information may be stored in
132 // the cache.
pauljensen9041eb3c2015-12-09 12:29:01133 const bool load_disable_cache;
[email protected]94de3e02014-06-17 00:09:51134 // Storage path for http cache and cookie storage.
pauljensen9041eb3c2015-12-09 12:29:01135 const std::string storage_path;
mefd1907102014-11-07 17:46:48136 // User-Agent request header field.
pauljensen9041eb3c2015-12-09 12:29:01137 const std::string user_agent;
xunjieli61b1eaa2015-11-17 22:44:55138 // Experimental options encoded as a string in a JSON format containing
139 // experiments and their corresponding configuration options. The format
140 // is a JSON object with the name of the experiment as the key, and the
141 // configuration options as the value. An example:
142 // {"experiment1": {"option1": "option_value1", "option2": "option_value2",
143 // ...}, "experiment2: {"option3", "option_value3", ...}, ...}
pauljensen9041eb3c2015-12-09 12:29:01144 const std::string experimental_options;
bengr59cb6962015-05-13 17:55:58145 // Enable Data Reduction Proxy with authentication key.
pauljensen9041eb3c2015-12-09 12:29:01146 const std::string data_reduction_proxy_key;
147 const std::string data_reduction_primary_proxy;
148 const std::string data_reduction_fallback_proxy;
149 const std::string data_reduction_secure_proxy_check_url;
mefc71361c2014-09-16 14:48:56150
xunjieli013145f2015-10-20 23:20:11151 // Certificate verifier for testing.
152 scoped_ptr<net::CertVerifier> mock_cert_verifier;
153
pauljensen9041eb3c2015-12-09 12:29:01154 // App-provided list of servers that support QUIC.
155 ScopedVector<QuicHint> quic_hints;
156
157 // The list of public key pins.
158 ScopedVector<Pkp> pkp_list;
159
mefc71361c2014-09-16 14:48:56160 private:
161 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig);
[email protected]94de3e02014-06-17 00:09:51162};
163
164} // namespace cronet
165
166#endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_