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 ~URLRequestContextBuilder(); | 115 virtual ~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, uses system libraries to | |
eroman
2017/05/16 20:21:20
Is this comment accurate? Given that the CreatePro
mmenke
2017/05/17 02:29:58
It's accurate for the base implementation, not the
| |
148 // evaluate PAC scripts, if available (And if not, skips PAC resolution). | |
146 void set_proxy_service(std::unique_ptr<ProxyService> proxy_service) { | 149 void set_proxy_service(std::unique_ptr<ProxyService> proxy_service) { |
147 proxy_service_ = std::move(proxy_service); | 150 proxy_service_ = std::move(proxy_service); |
148 } | 151 } |
149 | 152 |
150 // Call these functions to specify hard-coded Accept-Language | 153 // Call these functions to specify hard-coded Accept-Language |
151 // or User-Agent header values for all requests that don't | 154 // or User-Agent header values for all requests that don't |
152 // have the headers already set. | 155 // have the headers already set. |
153 void set_accept_language(const std::string& accept_language) { | 156 void set_accept_language(const std::string& accept_language) { |
154 accept_language_ = accept_language; | 157 accept_language_ = accept_language; |
155 } | 158 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. | 327 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. |
325 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } | 328 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } |
326 | 329 |
327 // Sets a specific HttpServerProperties for use in the | 330 // Sets a specific HttpServerProperties for use in the |
328 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. | 331 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. |
329 void SetHttpServerProperties( | 332 void SetHttpServerProperties( |
330 std::unique_ptr<HttpServerProperties> http_server_properties); | 333 std::unique_ptr<HttpServerProperties> http_server_properties); |
331 | 334 |
332 std::unique_ptr<URLRequestContext> Build(); | 335 std::unique_ptr<URLRequestContext> Build(); |
333 | 336 |
337 protected: | |
338 // Lets subclasses override ProxyService creation, using a ProxyService that | |
339 // uses the URLRequestContext itself to get PAC scripts. When this method is | |
340 // invoked, the URLRequestContext is not yet ready to service requests. | |
341 virtual std::unique_ptr<ProxyService> CreateProxyService( | |
342 std::unique_ptr<ProxyConfigService> proxy_config_service, | |
343 URLRequestContext* url_request_context, | |
344 HostResolver* host_resolver, | |
345 NetworkDelegate* network_delegate, | |
346 NetLog* net_log); | |
347 | |
334 private: | 348 private: |
335 const char* name_; | 349 const char* name_; |
336 bool enable_brotli_; | 350 bool enable_brotli_; |
337 NetworkQualityEstimator* network_quality_estimator_; | 351 NetworkQualityEstimator* network_quality_estimator_; |
338 | 352 |
339 std::string accept_language_; | 353 std::string accept_language_; |
340 std::string user_agent_; | 354 std::string user_agent_; |
341 // Include support for data:// requests. | 355 // Include support for data:// requests. |
342 bool data_enabled_; | 356 bool data_enabled_; |
343 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) | 357 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 // Not owned by the context builder. Once it is set to a non-null value, it | 390 // Not owned by the context builder. Once it is set to a non-null value, it |
377 // is guaranteed to be non-null during the lifetime of |this|. | 391 // is guaranteed to be non-null during the lifetime of |this|. |
378 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; | 392 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; |
379 | 393 |
380 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 394 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
381 }; | 395 }; |
382 | 396 |
383 } // namespace net | 397 } // namespace net |
384 | 398 |
385 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 399 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
OLD | NEW |