[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 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 |
| 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 | |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 10 | #include "base/macros.h" |
xunjieli | da7f7702 | 2016-03-28 16:36:36 | [diff] [blame^] | 11 | #include "base/memory/ref_counted.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 13 | #include "base/memory/scoped_vector.h" |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 14 | #include "base/time/time.h" |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 15 | #include "net/base/hash_value.h" |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 16 | |
xunjieli | da7f7702 | 2016-03-28 16:36:36 | [diff] [blame^] | 17 | namespace base { |
| 18 | class SequencedTaskRunner; |
| 19 | } // namespace base |
| 20 | |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 21 | namespace net { |
xunjieli | 013145f | 2015-10-20 23:20:11 | [diff] [blame] | 22 | class CertVerifier; |
pauljensen | e92c409 | 2015-12-09 19:13:48 | [diff] [blame] | 23 | class NetLog; |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 24 | class URLRequestContextBuilder; |
| 25 | } // namespace net |
| 26 | |
| 27 | namespace cronet { |
| 28 | |
| 29 | // Common configuration parameters used by Cronet to configure |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 30 | // URLRequestContext. |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 31 | struct URLRequestContextConfig { |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 32 | // 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 | |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 43 | // App-provided hint that server supports QUIC. |
| 44 | struct QuicHint { |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 45 | QuicHint(const std::string& host, int port, int alternate_port); |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 46 | ~QuicHint(); |
| 47 | |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 48 | // Host name of the server that supports QUIC. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 49 | const std::string host; |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 50 | // Port of the server that supports QUIC. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 51 | const int port; |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 52 | // Alternate protocol port. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 53 | const int alternate_port; |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 54 | |
| 55 | private: |
| 56 | DISALLOW_COPY_AND_ASSIGN(QuicHint); |
| 57 | }; |
| 58 | |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 59 | // Public-Key-Pinning configuration structure. |
| 60 | struct Pkp { |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 61 | Pkp(const std::string& host, |
| 62 | bool include_subdomains, |
| 63 | const base::Time& expiration_date); |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 64 | ~Pkp(); |
| 65 | |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 66 | // Host name. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 67 | const std::string host; |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 68 | // Pin hashes (currently SHA256 only). |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 69 | net::HashValueVector pin_hashes; |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 70 | // Indicates whether the pinning should apply to the pinned host subdomains. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 71 | const bool include_subdomains; |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 72 | // Expiration date for the pins. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 73 | const base::Time expiration_date; |
kapishnikov | df5ccab | 2015-12-03 18:38:50 | [diff] [blame] | 74 | |
| 75 | private: |
| 76 | DISALLOW_COPY_AND_ASSIGN(Pkp); |
| 77 | }; |
| 78 | |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 79 | URLRequestContextConfig( |
| 80 | // Enable QUIC. |
| 81 | bool enable_quic, |
mef | c5da571 | 2016-02-09 20:14:23 | [diff] [blame] | 82 | // QUIC User Agent ID. |
| 83 | const std::string& quic_user_agent_id, |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 84 | // 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] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 111 | ~URLRequestContextConfig(); |
| 112 | |
| 113 | // Configure |context_builder| based on |this|. |
| 114 | void ConfigureURLRequestContextBuilder( |
pauljensen | e92c409 | 2015-12-09 19:13:48 | [diff] [blame] | 115 | net::URLRequestContextBuilder* context_builder, |
xunjieli | da7f7702 | 2016-03-28 16:36:36 | [diff] [blame^] | 116 | net::NetLog* net_log, |
| 117 | const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 118 | |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 119 | // Enable QUIC. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 120 | const bool enable_quic; |
mef | c5da571 | 2016-02-09 20:14:23 | [diff] [blame] | 121 | // QUIC User Agent ID. |
| 122 | const std::string quic_user_agent_id; |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 123 | // Enable SPDY. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 124 | const bool enable_spdy; |
xunjieli | b8a6d56f | 2015-04-29 17:36:14 | [diff] [blame] | 125 | // Enable SDCH. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 126 | const bool enable_sdch; |
| 127 | // Type of http cache. |
| 128 | const HttpCacheType http_cache; |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 129 | // Max size of http cache in bytes. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 130 | const int http_cache_max_size; |
mef | bb4f45c | 2015-01-12 18:03:25 | [diff] [blame] | 131 | // Disable caching for HTTP responses. Other information may be stored in |
| 132 | // the cache. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 133 | const bool load_disable_cache; |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 134 | // Storage path for http cache and cookie storage. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 135 | const std::string storage_path; |
mef | d190710 | 2014-11-07 17:46:48 | [diff] [blame] | 136 | // User-Agent request header field. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 137 | const std::string user_agent; |
xunjieli | 61b1eaa | 2015-11-17 22:44:55 | [diff] [blame] | 138 | // 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", ...}, ...} |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 144 | const std::string experimental_options; |
bengr | 59cb696 | 2015-05-13 17:55:58 | [diff] [blame] | 145 | // Enable Data Reduction Proxy with authentication key. |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 146 | 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; |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 150 | |
xunjieli | 013145f | 2015-10-20 23:20:11 | [diff] [blame] | 151 | // Certificate verifier for testing. |
| 152 | scoped_ptr<net::CertVerifier> mock_cert_verifier; |
| 153 | |
pauljensen | 9041eb3c | 2015-12-09 12:29:01 | [diff] [blame] | 154 | // 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 | |
mef | c71361c | 2014-09-16 14:48:56 | [diff] [blame] | 160 | private: |
| 161 | DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); |
[email protected] | 94de3e0 | 2014-06-17 00:09:51 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | } // namespace cronet |
| 165 | |
| 166 | #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ |