Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: net/url_request/url_request_context_builder.h

Issue 2977693003: Use TaskRunner passed in to URLRequestContextBuilder only for the cache (Closed)
Patch Set: Actually, don't need to set the thread everywhere Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 #include "net/net_features.h" 37 #include "net/net_features.h"
38 #include "net/proxy/proxy_config_service.h" 38 #include "net/proxy/proxy_config_service.h"
39 #include "net/proxy/proxy_service.h" 39 #include "net/proxy/proxy_service.h"
40 #include "net/quic/core/quic_packets.h" 40 #include "net/quic/core/quic_packets.h"
41 #include "net/socket/next_proto.h" 41 #include "net/socket/next_proto.h"
42 #include "net/ssl/ssl_config_service.h" 42 #include "net/ssl/ssl_config_service.h"
43 #include "net/url_request/url_request_job_factory.h" 43 #include "net/url_request/url_request_job_factory.h"
44 44
45 namespace base { 45 namespace base {
46 class SingleThreadTaskRunner; 46 class SingleThreadTaskRunner;
47 class SequencedTaskRunner;
48 class TaskRunner;
49 } 47 }
50 48
51 namespace net { 49 namespace net {
52 50
53 class CertVerifier; 51 class CertVerifier;
54 class ChannelIDService; 52 class ChannelIDService;
55 class CookieStore; 53 class CookieStore;
56 class CTPolicyEnforcer; 54 class CTPolicyEnforcer;
57 class CTVerifier; 55 class CTVerifier;
58 class HttpAuthHandlerFactory; 56 class HttpAuthHandlerFactory;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // If |cookie_store| is not NULL and |channel_id_service| is NULL, 273 // If |cookie_store| is not NULL and |channel_id_service| is NULL,
276 // only ChannelIdService is disabled for this context. 274 // only ChannelIdService is disabled for this context.
277 // Note that a persistent cookie store should not be used with an in-memory 275 // Note that a persistent cookie store should not be used with an in-memory
278 // channel id service, and one cookie store should not be shared between 276 // channel id service, and one cookie store should not be shared between
279 // multiple channel-id stores (or used both with and without a channel id 277 // multiple channel-id stores (or used both with and without a channel id
280 // store). 278 // store).
281 void SetCookieAndChannelIdStores( 279 void SetCookieAndChannelIdStores(
282 std::unique_ptr<CookieStore> cookie_store, 280 std::unique_ptr<CookieStore> cookie_store,
283 std::unique_ptr<ChannelIDService> channel_id_service); 281 std::unique_ptr<ChannelIDService> channel_id_service);
284 282
285 // Sets the task runner used to perform file operations. If not set, 283 // Sets the SingleThreadTaskRunner used to perform cache operations. If not
286 // TaskSchedulers will be used instead. 284 // set, one will be created via a TaskScheduler instead. Other file tasks will
287 void SetFileTaskRunner( 285 // use the task scheduler, but the cache needs a SingleThreadTaskRunner, so
288 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 286 // best to keep that configurable by the consumer.
287 void SetCacheThreadTaskRunner(
288 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_task_runner);
289 289
290 // Note that if SDCH is enabled without a policy object observing 290 // Note that if SDCH is enabled without a policy object observing
291 // the SDCH manager and handling at least Get-Dictionary events, the 291 // the SDCH manager and handling at least Get-Dictionary events, the
292 // result will be "Content-Encoding: sdch" advertisements, but no 292 // result will be "Content-Encoding: sdch" advertisements, but no
293 // dictionaries fetches and no specific dictionaries advertised. 293 // dictionaries fetches and no specific dictionaries advertised.
294 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. 294 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object.
295 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } 295 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; }
296 296
297 // Sets a specific HttpServerProperties for use in the 297 // Sets a specific HttpServerProperties for use in the
298 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. 298 // URLRequestContext rather than creating a default HttpServerPropertiesImpl.
299 void SetHttpServerProperties( 299 void SetHttpServerProperties(
300 std::unique_ptr<HttpServerProperties> http_server_properties); 300 std::unique_ptr<HttpServerProperties> http_server_properties);
301 301
302 // Creates a mostly self-contained URLRequestContext. May only be called once 302 // Creates a mostly self-contained URLRequestContext. May only be called once
303 // per URLRequestContextBuilder. After this is called, the Builder can be 303 // per URLRequestContextBuilder. After this is called, the Builder can be
304 // safely destroyed. 304 // safely destroyed.
305 std::unique_ptr<URLRequestContext> Build(); 305 std::unique_ptr<URLRequestContext> Build();
306 306
307 protected: 307 protected:
308 // Lets subclasses override ProxyService creation, using a ProxyService that 308 // Lets subclasses override ProxyService creation, using a ProxyService that
309 // uses the URLRequestContext itself to get PAC scripts. When this method is 309 // uses the URLRequestContext itself to get PAC scripts. When this method is
310 // invoked, the URLRequestContext is not yet ready to service requests. 310 // invoked, the URLRequestContext is not yet ready to service requests.
311 virtual std::unique_ptr<ProxyService> CreateProxyService( 311 virtual std::unique_ptr<ProxyService> CreateProxyService(
312 std::unique_ptr<ProxyConfigService> proxy_config_service, 312 std::unique_ptr<ProxyConfigService> proxy_config_service,
313 URLRequestContext* url_request_context, 313 URLRequestContext* url_request_context,
314 HostResolver* host_resolver, 314 HostResolver* host_resolver,
315 NetworkDelegate* network_delegate, 315 NetworkDelegate* network_delegate,
316 NetLog* net_log); 316 NetLog* net_log);
317 317
318 // Returns a TaskRunner with the specified traits. If |file_task_runner_| is
319 // non-NULL, uses that. Otherwise, uses base/task_scheduler/ and the specified
320 // traits.
321 scoped_refptr<base::TaskRunner> GetFileTaskRunner(
322 const base::TaskTraits& traits);
323 scoped_refptr<base::SequencedTaskRunner> GetFileSequencedTaskRunner(
324 const base::TaskTraits& traits);
325 scoped_refptr<base::SingleThreadTaskRunner> GetFileSingleThreadTaskRunner(
326 const base::TaskTraits& traits);
327
328 private: 318 private:
329 const char* name_; 319 const char* name_;
330 bool enable_brotli_; 320 bool enable_brotli_;
331 NetworkQualityEstimator* network_quality_estimator_; 321 NetworkQualityEstimator* network_quality_estimator_;
332 322
333 std::string accept_language_; 323 std::string accept_language_;
334 std::string user_agent_; 324 std::string user_agent_;
335 // Include support for data:// requests. 325 // Include support for data:// requests.
336 bool data_enabled_; 326 bool data_enabled_;
337 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) 327 #if !BUILDFLAG(DISABLE_FILE_SUPPORT)
338 // Include support for file:// requests. 328 // Include support for file:// requests.
339 bool file_enabled_; 329 bool file_enabled_;
340 #endif 330 #endif
341 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) 331 #if !BUILDFLAG(DISABLE_FTP_SUPPORT)
342 // Include support for ftp:// requests. 332 // Include support for ftp:// requests.
343 bool ftp_enabled_; 333 bool ftp_enabled_;
344 #endif 334 #endif
345 bool http_cache_enabled_; 335 bool http_cache_enabled_;
346 bool throttling_enabled_; 336 bool throttling_enabled_;
347 bool sdch_enabled_; 337 bool sdch_enabled_;
348 bool cookie_store_set_by_client_; 338 bool cookie_store_set_by_client_;
349 339
350 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 340 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_task_runner_;
351 HttpCacheParams http_cache_params_; 341 HttpCacheParams http_cache_params_;
352 HttpNetworkSession::Params http_network_session_params_; 342 HttpNetworkSession::Params http_network_session_params_;
353 base::FilePath transport_security_persister_path_; 343 base::FilePath transport_security_persister_path_;
354 NetLog* net_log_; 344 NetLog* net_log_;
355 std::unique_ptr<HostResolver> host_resolver_; 345 std::unique_ptr<HostResolver> host_resolver_;
356 std::unique_ptr<ChannelIDService> channel_id_service_; 346 std::unique_ptr<ChannelIDService> channel_id_service_;
357 std::unique_ptr<ProxyConfigService> proxy_config_service_; 347 std::unique_ptr<ProxyConfigService> proxy_config_service_;
358 bool pac_quick_check_enabled_; 348 bool pac_quick_check_enabled_;
359 ProxyService::SanitizeUrlPolicy pac_sanitize_url_policy_; 349 ProxyService::SanitizeUrlPolicy pac_sanitize_url_policy_;
360 std::unique_ptr<ProxyService> proxy_service_; 350 std::unique_ptr<ProxyService> proxy_service_;
(...skipping 12 matching lines...) Expand all
373 std::unique_ptr<HttpServerProperties> http_server_properties_; 363 std::unique_ptr<HttpServerProperties> http_server_properties_;
374 std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>> 364 std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>>
375 protocol_handlers_; 365 protocol_handlers_;
376 366
377 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); 367 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
378 }; 368 };
379 369
380 } // namespace net 370 } // namespace net
381 371
382 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ 372 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_url_request_context_getter.cc ('k') | net/url_request/url_request_context_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698