| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 QuicTagVector quic_connection_options; | 105 QuicTagVector quic_connection_options; |
| 106 bool quic_close_sessions_on_ip_change; | 106 bool quic_close_sessions_on_ip_change; |
| 107 int quic_idle_connection_timeout_seconds; | 107 int quic_idle_connection_timeout_seconds; |
| 108 bool quic_migrate_sessions_on_network_change; | 108 bool quic_migrate_sessions_on_network_change; |
| 109 bool quic_migrate_sessions_early; | 109 bool quic_migrate_sessions_early; |
| 110 bool quic_disable_bidirectional_streams; | 110 bool quic_disable_bidirectional_streams; |
| 111 bool quic_race_cert_verification; | 111 bool quic_race_cert_verification; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 URLRequestContextBuilder(); | 114 URLRequestContextBuilder(); |
| 115 virtual ~URLRequestContextBuilder(); | 115 ~URLRequestContextBuilder(); |
| 116 | 116 |
| 117 // Sets a name for this URLRequestContext. Currently the name is used in | 117 // Sets a name for this URLRequestContext. Currently the name is used in |
| 118 // MemoryDumpProvier to annotate memory usage. The name does not need to be | 118 // MemoryDumpProvier to annotate memory usage. The name does not need to be |
| 119 // unique. | 119 // unique. |
| 120 void set_name(const char* name) { name_ = name; } | 120 void set_name(const char* name) { name_ = name; } |
| 121 | 121 |
| 122 // Sets whether Brotli compression is enabled. Disabled by default; | 122 // Sets whether Brotli compression is enabled. Disabled by default; |
| 123 void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } | 123 void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } |
| 124 | 124 |
| 125 // Unlike most other setters, the builder does not take ownership of the | 125 // Unlike most other setters, the builder does not take ownership of the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 136 static void SetHttpNetworkSessionComponents( | 136 static void SetHttpNetworkSessionComponents( |
| 137 const URLRequestContext* context, | 137 const URLRequestContext* context, |
| 138 HttpNetworkSession::Params* params); | 138 HttpNetworkSession::Params* params); |
| 139 | 139 |
| 140 // These functions are mutually exclusive. The ProxyConfigService, if | 140 // These functions are mutually exclusive. The ProxyConfigService, if |
| 141 // set, will be used to construct a ProxyService. | 141 // set, will be used to construct a ProxyService. |
| 142 void set_proxy_config_service( | 142 void set_proxy_config_service( |
| 143 std::unique_ptr<ProxyConfigService> proxy_config_service) { | 143 std::unique_ptr<ProxyConfigService> proxy_config_service) { |
| 144 proxy_config_service_ = std::move(proxy_config_service); | 144 proxy_config_service_ = std::move(proxy_config_service); |
| 145 } | 145 } |
| 146 | |
| 147 // Sets the proxy service. If one is not provided, by default, uses system | |
| 148 // libraries to evaluate PAC scripts, if available (And if not, skips PAC | |
| 149 // resolution). Subclasses may override CreateProxyService for different | |
| 150 // default behavior. | |
| 151 void set_proxy_service(std::unique_ptr<ProxyService> proxy_service) { | 146 void set_proxy_service(std::unique_ptr<ProxyService> proxy_service) { |
| 152 proxy_service_ = std::move(proxy_service); | 147 proxy_service_ = std::move(proxy_service); |
| 153 } | 148 } |
| 154 | 149 |
| 155 // Call these functions to specify hard-coded Accept-Language | 150 // Call these functions to specify hard-coded Accept-Language |
| 156 // or User-Agent header values for all requests that don't | 151 // or User-Agent header values for all requests that don't |
| 157 // have the headers already set. | 152 // have the headers already set. |
| 158 void set_accept_language(const std::string& accept_language) { | 153 void set_accept_language(const std::string& accept_language) { |
| 159 accept_language_ = accept_language; | 154 accept_language_ = accept_language; |
| 160 } | 155 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. | 324 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. |
| 330 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } | 325 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } |
| 331 | 326 |
| 332 // Sets a specific HttpServerProperties for use in the | 327 // Sets a specific HttpServerProperties for use in the |
| 333 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. | 328 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. |
| 334 void SetHttpServerProperties( | 329 void SetHttpServerProperties( |
| 335 std::unique_ptr<HttpServerProperties> http_server_properties); | 330 std::unique_ptr<HttpServerProperties> http_server_properties); |
| 336 | 331 |
| 337 std::unique_ptr<URLRequestContext> Build(); | 332 std::unique_ptr<URLRequestContext> Build(); |
| 338 | 333 |
| 339 protected: | |
| 340 // Lets subclasses override ProxyService creation, using a ProxyService that | |
| 341 // uses the URLRequestContext itself to get PAC scripts. When this method is | |
| 342 // invoked, the URLRequestContext is not yet ready to service requests. | |
| 343 virtual std::unique_ptr<ProxyService> CreateProxyService( | |
| 344 std::unique_ptr<ProxyConfigService> proxy_config_service, | |
| 345 URLRequestContext* url_request_context, | |
| 346 HostResolver* host_resolver, | |
| 347 NetworkDelegate* network_delegate, | |
| 348 NetLog* net_log); | |
| 349 | |
| 350 private: | 334 private: |
| 351 const char* name_; | 335 const char* name_; |
| 352 bool enable_brotli_; | 336 bool enable_brotli_; |
| 353 NetworkQualityEstimator* network_quality_estimator_; | 337 NetworkQualityEstimator* network_quality_estimator_; |
| 354 | 338 |
| 355 std::string accept_language_; | 339 std::string accept_language_; |
| 356 std::string user_agent_; | 340 std::string user_agent_; |
| 357 // Include support for data:// requests. | 341 // Include support for data:// requests. |
| 358 bool data_enabled_; | 342 bool data_enabled_; |
| 359 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) | 343 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // Not owned by the context builder. Once it is set to a non-null value, it | 376 // Not owned by the context builder. Once it is set to a non-null value, it |
| 393 // is guaranteed to be non-null during the lifetime of |this|. | 377 // is guaranteed to be non-null during the lifetime of |this|. |
| 394 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; | 378 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; |
| 395 | 379 |
| 396 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 380 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 397 }; | 381 }; |
| 398 | 382 |
| 399 } // namespace net | 383 } // namespace net |
| 400 | 384 |
| 401 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 385 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |