| 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 // Comma-separated list of QUIC connection options. |
| 69 const std::string& quic_connection_options, |
| 70 // Comma-separated list of QUIC connection options. |
| 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 // Comma-separated list of QUIC connection options. | 103 // Comma-separated list of QUIC connection options. |
| 79 std::string quic_connection_options; | 104 const std::string quic_connection_options; |
| 80 // Enable Data Reduction Proxy with authentication key. | 105 // Enable Data Reduction Proxy with authentication key. |
| 81 std::string data_reduction_proxy_key; | 106 const std::string data_reduction_proxy_key; |
| 82 std::string data_reduction_primary_proxy; | 107 const std::string data_reduction_primary_proxy; |
| 83 std::string data_reduction_fallback_proxy; | 108 const std::string data_reduction_fallback_proxy; |
| 84 std::string data_reduction_secure_proxy_check_url; | 109 const std::string data_reduction_secure_proxy_check_url; |
| 85 | 110 |
| 86 // Certificate verifier for testing. | 111 // Certificate verifier for testing. |
| 87 scoped_ptr<net::CertVerifier> mock_cert_verifier; | 112 scoped_ptr<net::CertVerifier> mock_cert_verifier; |
| 88 | 113 |
| 114 // App-provided list of servers that support QUIC. |
| 115 ScopedVector<QuicHint> quic_hints; |
| 116 |
| 89 private: | 117 private: |
| 90 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); | 118 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); |
| 91 }; | 119 }; |
| 92 | 120 |
| 93 } // namespace cronet | 121 } // namespace cronet |
| 94 | 122 |
| 95 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ | 123 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ |
| OLD | NEW |