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 10 #include "base/json/json_value_converter.h" 11 #include "base/macros.h" 12 #include "base/memory/scoped_vector.h" 13 14 namespace net { 15 class URLRequestContextBuilder; 16 } // namespace net 17 18 namespace cronet { 19 20 // Common configuration parameters used by Cronet to configure 21 // URLRequestContext. Can be parsed from JSON string passed through JNI. 22 struct URLRequestContextConfig { 23 // App-provided hint that server supports QUIC. 24 struct QuicHint { 25 QuicHint(); 26 ~QuicHint(); 27 28 // Register |converter| for use in converter.Convert(). 29 static void RegisterJSONConverter( 30 base::JSONValueConverter<QuicHint>* converter); 31 32 // Host name of the server that supports QUIC. 33 std::string host; 34 // Port of the server that supports QUIC. 35 int port; 36 // Alternate protocol port. 37 int alternate_port; 38 39 private: 40 DISALLOW_COPY_AND_ASSIGN(QuicHint); 41 }; 42 43 URLRequestContextConfig(); 44 ~URLRequestContextConfig(); 45 46 // Configure |context_builder| based on |this|. 47 void ConfigureURLRequestContextBuilder( 48 net::URLRequestContextBuilder* context_builder); 49 50 // Register |converter| for use in converter.Convert(). 51 static void RegisterJSONConverter( 52 base::JSONValueConverter<URLRequestContextConfig>* converter); 53 54 // Enable QUIC. 55 bool enable_quic; 56 // Enable SPDY. 57 bool enable_spdy; 58 // Type of http cache: "HTTP_CACHE_DISABLED", "HTTP_CACHE_DISK" or 59 // "HTTP_CACHE_IN_MEMORY". 60 std::string http_cache; 61 // Max size of http cache in bytes. 62 int http_cache_max_size; 63 // Storage path for http cache and cookie storage. 64 std::string storage_path; 65 // App-provided list of servers that support QUIC. 66 ScopedVector<QuicHint> quic_hints; 67 68 private: 69 DISALLOW_COPY_AND_ASSIGN(URLRequestContextConfig); 70 }; 71 72 } // namespace cronet 73 74 #endif // COMPONENTS_CRONET_URL_REQUEST_CONTEXT_CONFIG_H_ 75