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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_value_converter.h" | |
11 #include "base/macros.h" | 10 #include "base/macros.h" |
12 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
13 | 12 |
14 namespace net { | 13 namespace net { |
15 class CertVerifier; | 14 class CertVerifier; |
16 class URLRequestContextBuilder; | 15 class URLRequestContextBuilder; |
17 } // namespace net | 16 } // namespace net |
18 | 17 |
19 namespace cronet { | 18 namespace cronet { |
20 | 19 |
21 // Common configuration parameters used by Cronet to configure | 20 // Common configuration parameters used by Cronet to configure |
22 // URLRequestContext. Can be parsed from JSON string passed through JNI. | 21 // URLRequestContext. |
23 struct URLRequestContextConfig { | 22 struct URLRequestContextConfig { |
| 23 // Type of HTTP cache. |
| 24 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net |
| 25 enum HttpCacheType { |
| 26 // No HTTP cache. |
| 27 DISABLED, |
| 28 // HTTP cache persisted to disk. |
| 29 DISK, |
| 30 // HTTP cache kept in memory. |
| 31 MEMORY, |
| 32 }; |
| 33 |
24 // App-provided hint that server supports QUIC. | 34 // App-provided hint that server supports QUIC. |
25 struct QuicHint { | 35 struct QuicHint { |
26 QuicHint(); | 36 QuicHint(const std::string& host, int port, int alternate_port); |
27 ~QuicHint(); | 37 ~QuicHint(); |
28 | 38 |
29 // Register |converter| for use in converter.Convert(). | |
30 static void RegisterJSONConverter( | |
31 base::JSONValueConverter<QuicHint>* converter); | |
32 | |
33 // Host name of the server that supports QUIC. | 39 // Host name of the server that supports QUIC. |
34 std::string host; | 40 const std::string host; |
35 // Port of the server that supports QUIC. | 41 // Port of the server that supports QUIC. |
36 int port; | 42 const int port; |
37 // Alternate protocol port. | 43 // Alternate protocol port. |
38 int alternate_port; | 44 const int alternate_port; |
39 | 45 |
40 private: | 46 private: |
41 DISALLOW_COPY_AND_ASSIGN(QuicHint); | 47 DISALLOW_COPY_AND_ASSIGN(QuicHint); |
42 }; | 48 }; |
43 | 49 |
44 URLRequestContextConfig(); | 50 URLRequestContextConfig( |
| 51 // Enable QUIC. |
| 52 bool enable_quic, |
| 53 // Enable SPDY. |
| 54 bool enable_spdy, |
| 55 // Enable SDCH. |
| 56 bool enable_sdch, |
| 57 // Type of http cache. |
| 58 HttpCacheType http_cache, |
| 59 // Max size of http cache in bytes. |
| 60 int http_cache_max_size, |
| 61 // Disable caching for HTTP responses. Other information may be stored in |
| 62 // the cache. |
| 63 bool load_disable_cache, |
| 64 // Storage path for http cache and cookie storage. |
| 65 const std::string& storage_path, |
| 66 // User-Agent request header field. |
| 67 const std::string& user_agent, |
| 68 // JSON encoded experimental options. |
| 69 const std::string& experimental_options, |
| 70 // Data reduction proxy key. |
| 71 const std::string& data_reduction_proxy_key, |
| 72 // Data reduction proxy. |
| 73 const std::string& data_reduction_primary_proxy, |
| 74 // Fallback data reduction proxy. |
| 75 const std::string& data_reduction_fallback_proxy, |
| 76 // Data reduction proxy secure proxy check URL. |
| 77 const std::string& data_reduction_secure_proxy_check_url, |
| 78 // MockCertVerifier to use for testing purposes. |
| 79 scoped_ptr<net::CertVerifier> mock_cert_verifier); |
45 ~URLRequestContextConfig(); | 80 ~URLRequestContextConfig(); |
46 | 81 |
47 // Load config values from JSON format. | |
48 bool LoadFromJSON(const std::string& config_string); | |
49 | |
50 // Configure |context_builder| based on |this|. | 82 // Configure |context_builder| based on |this|. |
51 void ConfigureURLRequestContextBuilder( | 83 void ConfigureURLRequestContextBuilder( |
52 net::URLRequestContextBuilder* context_builder); | 84 net::URLRequestContextBuilder* context_builder); |
53 | 85 |
54 // Register |converter| for use in converter.Convert(). | |
55 static void RegisterJSONConverter( | |
56 base::JSONValueConverter<URLRequestContextConfig>* converter); | |
57 | |
58 // Enable QUIC. | 86 // Enable QUIC. |
59 bool enable_quic; | 87 const bool enable_quic; |
60 // Enable SPDY. | 88 // Enable SPDY. |
61 bool enable_spdy; | 89 const bool enable_spdy; |
62 // Enable SDCH. | 90 // Enable SDCH. |
63 bool enable_sdch; | 91 const bool enable_sdch; |
64 // Type of http cache: "HTTP_CACHE_DISABLED", "HTTP_CACHE_DISK" or | 92 // Type of http cache. |
65 // "HTTP_CACHE_IN_MEMORY". | 93 const HttpCacheType http_cache; |
66 std::string http_cache; | |
67 // Max size of http cache in bytes. | 94 // Max size of http cache in bytes. |
68 int http_cache_max_size; | 95 const int http_cache_max_size; |
69 // Disable caching for HTTP responses. Other information may be stored in | 96 // Disable caching for HTTP responses. Other information may be stored in |
70 // the cache. | 97 // the cache. |
71 bool load_disable_cache; | 98 const bool load_disable_cache; |
72 // Storage path for http cache and cookie storage. | 99 // Storage path for http cache and cookie storage. |
73 std::string storage_path; | 100 const std::string storage_path; |
74 // User-Agent request header field. | 101 // User-Agent request header field. |
75 std::string user_agent; | 102 const std::string user_agent; |
76 // App-provided list of servers that support QUIC. | |
77 ScopedVector<QuicHint> quic_hints; | |
78 // Experimental options encoded as a string in a JSON format containing | 103 // Experimental options encoded as a string in a JSON format containing |
79 // experiments and their corresponding configuration options. The format | 104 // experiments and their corresponding configuration options. The format |
80 // is a JSON object with the name of the experiment as the key, and the | 105 // is a JSON object with the name of the experiment as the key, and the |
81 // configuration options as the value. An example: | 106 // configuration options as the value. An example: |
82 // {"experiment1": {"option1": "option_value1", "option2": "option_value2", | 107 // {"experiment1": {"option1": "option_value1", "option2": "option_value2", |
83 // ...}, "experiment2: {"option3", "option_value3", ...}, ...} | 108 // ...}, "experiment2: {"option3", "option_value3", ...}, ...} |
84 std::string experimental_options; | 109 const std::string experimental_options; |
85 // Enable Data Reduction Proxy with authentication key. | 110 // Enable Data Reduction Proxy with authentication key. |
86 std::string data_reduction_proxy_key; | 111 const std::string data_reduction_proxy_key; |
87 std::string data_reduction_primary_proxy; | 112 const std::string data_reduction_primary_proxy; |
88 std::string data_reduction_fallback_proxy; | 113 const std::string data_reduction_fallback_proxy; |
89 std::string data_reduction_secure_proxy_check_url; | 114 const std::string data_reduction_secure_proxy_check_url; |
90 | 115 |
91 // Certificate verifier for testing. | 116 // Certificate verifier for testing. |
92 scoped_ptr<net::CertVerifier> mock_cert_verifier; | 117 scoped_ptr<net::CertVerifier> mock_cert_verifier; |
93 | 118 |
| 119 // App-provided list of servers that support QUIC. |
| 120 ScopedVector<QuicHint> quic_hints; |
| 121 |
94 private: | 122 private: |
95 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); | 123 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); |
96 }; | 124 }; |
97 | 125 |
98 } // namespace cronet | 126 } // namespace cronet |
99 | 127 |
100 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ | 128 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ |
OLD | NEW |