| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 net { | 26 namespace net { |
| 27 | 27 |
| 28 class ProxyConfigService; | 28 class ProxyConfigService; |
| 29 class URLRequestContext; | 29 class URLRequestContext; |
| 30 | 30 |
| 31 class NET_EXPORT URLRequestContextBuilder { | 31 class NET_EXPORT URLRequestContextBuilder { |
| 32 public: | 32 public: |
| 33 struct NET_EXPORT HostResolverParams { | |
| 34 HostResolverParams(); | |
| 35 ~HostResolverParams(); | |
| 36 | |
| 37 // The limit on the number of parallel host resolutions. | |
| 38 size_t parallelism; | |
| 39 | |
| 40 // When the host resolution is taking too long, we'll retry this many times, | |
| 41 // in a backing off manner. | |
| 42 size_t retry_attempts; | |
| 43 }; | |
| 44 | |
| 45 struct NET_EXPORT HttpCacheParams { | 33 struct NET_EXPORT HttpCacheParams { |
| 46 enum Type { | 34 enum Type { |
| 47 IN_MEMORY, | 35 IN_MEMORY, |
| 48 DISK, | 36 DISK, |
| 49 }; | 37 }; |
| 50 | 38 |
| 51 HttpCacheParams(); | 39 HttpCacheParams(); |
| 52 ~HttpCacheParams(); | 40 ~HttpCacheParams(); |
| 53 | 41 |
| 54 // The type of HTTP cache. Default is IN_MEMORY. | 42 // The type of HTTP cache. Default is IN_MEMORY. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
| 69 void set_proxy_config_service(ProxyConfigService* proxy_config_service); | 57 void set_proxy_config_service(ProxyConfigService* proxy_config_service); |
| 70 #endif // defined(OS_LINUX) | 58 #endif // defined(OS_LINUX) |
| 71 | 59 |
| 72 // Call this function to specify a hard-coded User-Agent for all requests that | 60 // Call this function to specify a hard-coded User-Agent for all requests that |
| 73 // don't have a User-Agent already set. | 61 // don't have a User-Agent already set. |
| 74 void set_user_agent(const std::string& user_agent) { | 62 void set_user_agent(const std::string& user_agent) { |
| 75 user_agent_ = user_agent; | 63 user_agent_ = user_agent; |
| 76 } | 64 } |
| 77 | 65 |
| 78 // Allows for overriding the default HostResolver params. | |
| 79 void set_host_resolver_params( | |
| 80 const HostResolverParams& host_resolver_params) { | |
| 81 host_resolver_params_ = host_resolver_params; | |
| 82 } | |
| 83 | |
| 84 // By default it's disabled. | 66 // By default it's disabled. |
| 85 void set_ftp_enabled(bool enable) { | 67 void set_ftp_enabled(bool enable) { |
| 86 ftp_enabled_ = enable; | 68 ftp_enabled_ = enable; |
| 87 } | 69 } |
| 88 | 70 |
| 89 // By default HttpCache is enabled with a default constructed HttpCacheParams. | 71 // By default HttpCache is enabled with a default constructed HttpCacheParams. |
| 90 void EnableHttpCache(const HttpCacheParams& params); | 72 void EnableHttpCache(const HttpCacheParams& params); |
| 91 void DisableHttpCache(); | 73 void DisableHttpCache(); |
| 92 | 74 |
| 93 URLRequestContext* Build(); | 75 URLRequestContext* Build(); |
| 94 | 76 |
| 95 private: | 77 private: |
| 96 std::string user_agent_; | 78 std::string user_agent_; |
| 97 bool ftp_enabled_; | 79 bool ftp_enabled_; |
| 98 HostResolverParams host_resolver_params_; | |
| 99 bool http_cache_enabled_; | 80 bool http_cache_enabled_; |
| 100 HttpCacheParams http_cache_params_; | 81 HttpCacheParams http_cache_params_; |
| 101 #if defined(OS_LINUX) | 82 #if defined(OS_LINUX) |
| 102 scoped_ptr<ProxyConfigService> proxy_config_service_; | 83 scoped_ptr<ProxyConfigService> proxy_config_service_; |
| 103 #endif // defined(OS_LINUX) | 84 #endif // defined(OS_LINUX) |
| 104 | 85 |
| 105 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 86 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 106 }; | 87 }; |
| 107 | 88 |
| 108 } // namespace net | 89 } // namespace net |
| 109 | 90 |
| 110 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 91 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |