| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This class is useful for building a simple URLRequestContext. Most creators | 5 // This class is useful for building a simple URLRequestContext. Most creators |
| 6 // of new URLRequestContexts should use this helper class to construct it. Call | 6 // of new URLRequestContexts should use this helper class to construct it. Call |
| 7 // any configuration params, and when done, invoke Build() to construct the | 7 // any configuration params, and when done, invoke Build() to construct the |
| 8 // URLRequestContext. This URLRequestContext will own all its own storage. | 8 // URLRequestContext. This URLRequestContext will own all its own storage. |
| 9 // | 9 // |
| 10 // URLRequestContextBuilder and its associated params classes are initially | 10 // URLRequestContextBuilder and its associated params classes are initially |
| 11 // populated with "sane" default values. Read through the comments to figure out | 11 // populated with "sane" default values. Read through the comments to figure out |
| 12 // what these are. | 12 // what these are. |
| 13 | 13 |
| 14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| 15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| 16 | 16 |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
| 21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "net/base/net_export.h" | 24 #include "net/base/net_export.h" |
| 25 | 25 |
| 26 namespace base { |
| 27 class SingleThreadTaskRunner; |
| 28 } // namespace base |
| 29 |
| 26 namespace net { | 30 namespace net { |
| 27 | 31 |
| 28 class HostMappingRules; | 32 class HostMappingRules; |
| 29 class ProxyConfigService; | |
| 30 class URLRequestContext; | 33 class URLRequestContext; |
| 31 | 34 |
| 32 class NET_EXPORT URLRequestContextBuilder { | 35 class NET_EXPORT URLRequestContextBuilder { |
| 33 public: | 36 public: |
| 34 struct NET_EXPORT HostResolverParams { | 37 struct NET_EXPORT HostResolverParams { |
| 35 HostResolverParams(); | 38 HostResolverParams(); |
| 36 ~HostResolverParams(); | 39 ~HostResolverParams(); |
| 37 | 40 |
| 38 // The limit on the number of parallel host resolutions. | 41 // The limit on the number of parallel host resolutions. |
| 39 size_t parallelism; | 42 size_t parallelism; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool http_pipelining_enabled; | 76 bool http_pipelining_enabled; |
| 74 uint16 testing_fixed_http_port; | 77 uint16 testing_fixed_http_port; |
| 75 uint16 testing_fixed_https_port; | 78 uint16 testing_fixed_https_port; |
| 76 std::string trusted_spdy_proxy; | 79 std::string trusted_spdy_proxy; |
| 77 }; | 80 }; |
| 78 | 81 |
| 79 URLRequestContextBuilder(); | 82 URLRequestContextBuilder(); |
| 80 ~URLRequestContextBuilder(); | 83 ~URLRequestContextBuilder(); |
| 81 | 84 |
| 82 #if defined(OS_LINUX) | 85 #if defined(OS_LINUX) |
| 83 void set_proxy_config_service(ProxyConfigService* proxy_config_service); | 86 void set_glib_task_runner(base::SingleThreadTaskRunner* glib_task_runner); |
| 84 #endif // defined(OS_LINUX) | 87 #endif // defined(OS_LINUX) |
| 85 | 88 |
| 86 // Call this function to specify a hard-coded User-Agent for all requests that | 89 // Call this function to specify a hard-coded User-Agent for all requests that |
| 87 // don't have a User-Agent already set. | 90 // don't have a User-Agent already set. |
| 88 void set_user_agent(const std::string& user_agent) { | 91 void set_user_agent(const std::string& user_agent) { |
| 89 user_agent_ = user_agent; | 92 user_agent_ = user_agent; |
| 90 } | 93 } |
| 91 | 94 |
| 92 // Allows for overriding the default HostResolver params. | 95 // Allows for overriding the default HostResolver params. |
| 93 void set_host_resolver_params( | 96 void set_host_resolver_params( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 108 void set_http_network_session_params( | 111 void set_http_network_session_params( |
| 109 const HttpNetworkSessionParams& http_network_session_params) { | 112 const HttpNetworkSessionParams& http_network_session_params) { |
| 110 http_network_session_params_ = http_network_session_params; | 113 http_network_session_params_ = http_network_session_params; |
| 111 } | 114 } |
| 112 | 115 |
| 113 URLRequestContext* Build(); | 116 URLRequestContext* Build(); |
| 114 | 117 |
| 115 private: | 118 private: |
| 116 std::string user_agent_; | 119 std::string user_agent_; |
| 117 bool ftp_enabled_; | 120 bool ftp_enabled_; |
| 121 #if defined(OS_LINUX) |
| 122 base::SingleThreadTaskRunner* glib_task_runner_; |
| 123 #endif // defined(OS_LINUX) |
| 118 HostResolverParams host_resolver_params_; | 124 HostResolverParams host_resolver_params_; |
| 119 bool http_cache_enabled_; | 125 bool http_cache_enabled_; |
| 120 HttpCacheParams http_cache_params_; | 126 HttpCacheParams http_cache_params_; |
| 121 HttpNetworkSessionParams http_network_session_params_; | 127 HttpNetworkSessionParams http_network_session_params_; |
| 122 #if defined(OS_LINUX) | |
| 123 scoped_ptr<ProxyConfigService> proxy_config_service_; | |
| 124 #endif // defined(OS_LINUX) | |
| 125 | 128 |
| 126 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 129 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 } // namespace net | 132 } // namespace net |
| 130 | 133 |
| 131 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 134 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |