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

Side by Side Diff: chrome/browser/profiles/profile_io_data.h

Issue 2978443002: Make ProfileIOData use URLRequestContextBuilder (Closed)
Patch Set: Merge 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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 namespace net { 75 namespace net {
76 class CertVerifier; 76 class CertVerifier;
77 class ChannelIDService; 77 class ChannelIDService;
78 class ClientCertStore; 78 class ClientCertStore;
79 class CookieStore; 79 class CookieStore;
80 class HttpTransactionFactory; 80 class HttpTransactionFactory;
81 class ProxyConfigService; 81 class ProxyConfigService;
82 class ReportingService; 82 class ReportingService;
83 class ReportSender; 83 class ReportSender;
84 class SSLConfigService; 84 class SSLConfigService;
85 class TransportSecurityPersister; 85 class URLRequestContextBuilder;
86 class URLRequestContextStorage;
87 class URLRequestJobFactoryImpl; 86 class URLRequestJobFactoryImpl;
88 } // namespace net 87 } // namespace net
89 88
90 namespace policy { 89 namespace policy {
91 class PolicyCertVerifier; 90 class PolicyCertVerifier;
92 class PolicyHeaderIOHelper; 91 class PolicyHeaderIOHelper;
93 class URLBlacklistManager; 92 class URLBlacklistManager;
94 } // namespace policy 93 } // namespace policy
95 94
96 namespace previews { 95 namespace previews {
(...skipping 18 matching lines...) Expand all
115 // net::URLRequest. 114 // net::URLRequest.
116 static bool IsHandledProtocol(const std::string& scheme); 115 static bool IsHandledProtocol(const std::string& scheme);
117 116
118 // Returns true if |url| is handled in Chrome, or by default handlers in 117 // Returns true if |url| is handled in Chrome, or by default handlers in
119 // net::URLRequest. 118 // net::URLRequest.
120 static bool IsHandledURL(const GURL& url); 119 static bool IsHandledURL(const GURL& url);
121 120
122 // Utility to install additional WebUI handlers into the |job_factory|. 121 // Utility to install additional WebUI handlers into the |job_factory|.
123 // Ownership of the handlers is transfered from |protocol_handlers| 122 // Ownership of the handlers is transfered from |protocol_handlers|
124 // to the |job_factory|. 123 // to the |job_factory|.
124 // TODO(mmenke): Remove this, once only AddProtocolHandlersToBuilder is used.
125 static void InstallProtocolHandlers( 125 static void InstallProtocolHandlers(
126 net::URLRequestJobFactoryImpl* job_factory, 126 net::URLRequestJobFactoryImpl* job_factory,
127 content::ProtocolHandlerMap* protocol_handlers); 127 content::ProtocolHandlerMap* protocol_handlers);
128 128
129 // Utility to install additional WebUI handlers into |builder|. Ownership of
130 // the handlers is transfered from |protocol_handlers| to |builder|.
131 static void AddProtocolHandlersToBuilder(
132 net::URLRequestContextBuilder* builder,
133 content::ProtocolHandlerMap* protocol_handlers);
134
129 // Sets a global CertVerifier to use when initializing all profiles. 135 // Sets a global CertVerifier to use when initializing all profiles.
130 static void SetCertVerifierForTesting(net::CertVerifier* cert_verifier); 136 static void SetCertVerifierForTesting(net::CertVerifier* cert_verifier);
131 137
132 // Called by Profile. 138 // Called by Profile.
133 content::ResourceContext* GetResourceContext() const; 139 content::ResourceContext* GetResourceContext() const;
134 140
135 // Initializes the ProfileIOData object and primes the RequestContext 141 // Initializes the ProfileIOData object and primes the RequestContext
136 // generation. Must be called prior to any of the Get*() methods other than 142 // generation. Must be called prior to any of the Get*() methods other than
137 // GetResouceContext or GetMetricsEnabledStateOnIOThread. 143 // GetResouceContext or GetMetricsEnabledStateOnIOThread.
138 void Init( 144 void Init(
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 342
337 // The profile this struct was populated from. It's passed as a void* to 343 // The profile this struct was populated from. It's passed as a void* to
338 // ensure it's not accidently used on the IO thread. Before using it on the 344 // ensure it's not accidently used on the IO thread. Before using it on the
339 // UI thread, call ProfileManager::IsValidProfile to ensure it's alive. 345 // UI thread, call ProfileManager::IsValidProfile to ensure it's alive.
340 void* profile; 346 void* profile;
341 }; 347 };
342 348
343 explicit ProfileIOData(Profile::ProfileType profile_type); 349 explicit ProfileIOData(Profile::ProfileType profile_type);
344 350
345 void InitializeOnUIThread(Profile* profile); 351 void InitializeOnUIThread(Profile* profile);
346 void ApplyProfileParamsToContext(net::URLRequestContext* context) const;
347 352
348 // Does common setup of the URLRequestJobFactories. Adds default 353 // Does common setup of the URLRequestJobFactories. Adds default
349 // ProtocolHandlers to |job_factory|, adds URLRequestInterceptors in front of 354 // ProtocolHandlers to |job_factory|, adds URLRequestInterceptors in front of
350 // it as needed, and returns the result. 355 // it as needed, and returns the result.
351 // 356 //
352 // |protocol_handler_interceptor| is configured to intercept URLRequests 357 // |protocol_handler_interceptor| is configured to intercept URLRequests
353 // before all other URLRequestInterceptors, if non-null. 358 // before all other URLRequestInterceptors, if non-null.
354 // |host_resolver| is needed to set up the FtpProtocolHandler. 359 // |host_resolver| is needed to set up the FtpProtocolHandler.
355 std::unique_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( 360 std::unique_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
356 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory, 361 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory,
357 content::URLRequestInterceptorScopedVector request_interceptors, 362 content::URLRequestInterceptorScopedVector request_interceptors,
358 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 363 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
359 protocol_handler_interceptor, 364 protocol_handler_interceptor,
360 net::NetworkDelegate* network_delegate, 365 net::NetworkDelegate* network_delegate,
361 net::HostResolver* host_resolver) const; 366 net::HostResolver* host_resolver) const;
362 367
368 // Does common setup of the URLRequestJobFactories. Adds default
369 // ProtocolHandlers to |builder|, and adds URLRequestInterceptors in front of
370 // them as needed.
371 //
372 // |protocol_handler_interceptor| is configured to intercept URLRequests
373 // before all other URLRequestInterceptors, if non-null.
374 // |host_resolver| is needed to set up the FtpProtocolHandler.
375 void SetUpJobFactoryDefaultsForBuilder(
376 net::URLRequestContextBuilder* builder,
377 content::URLRequestInterceptorScopedVector request_interceptors,
378 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
379 protocol_handler_interceptor,
380 net::HostResolver* host_resolver) const;
381
363 // Called when the Profile is destroyed. |context_getters| must include all 382 // Called when the Profile is destroyed. |context_getters| must include all
364 // URLRequestContextGetters that refer to the ProfileIOData's 383 // URLRequestContextGetters that refer to the ProfileIOData's
365 // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts 384 // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts
366 // down |context_getters| safely on the IO thread. 385 // down |context_getters| safely on the IO thread.
367 // TODO(mmenke): Passing all those URLRequestContextGetters around like this 386 // TODO(mmenke): Passing all those URLRequestContextGetters around like this
368 // is really silly. Can we do something cleaner? 387 // is really silly. Can we do something cleaner?
369 void ShutdownOnUIThread( 388 void ShutdownOnUIThread(
370 std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters); 389 std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters);
371 390
372 void set_data_reduction_proxy_io_data( 391 void set_data_reduction_proxy_io_data(
373 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> 392 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
374 data_reduction_proxy_io_data) const; 393 data_reduction_proxy_io_data) const;
375 394
376 void set_previews_io_data( 395 void set_previews_io_data(
377 std::unique_ptr<previews::PreviewsIOData> previews_io_data) const; 396 std::unique_ptr<previews::PreviewsIOData> previews_io_data) const;
378 397
379 net::URLRequestContext* main_request_context() const { 398 net::URLRequestContext* main_request_context() const {
380 return main_request_context_.get(); 399 return main_request_context_.get();
381 } 400 }
382 401
383 // Storage for |main_request_context_|, to allow objects created by subclasses
384 // to live until the ProfileIOData destructor is invoked, so it can safely
385 // cancel URLRequests.
386 net::URLRequestContextStorage* main_request_context_storage() const {
387 return main_request_context_storage_.get();
388 }
389
390 bool initialized() const { 402 bool initialized() const {
391 return initialized_; 403 return initialized_;
392 } 404 }
393 405
394 // Destroys the ResourceContext first, to cancel any URLRequests that are 406 // Destroys the ResourceContext first, to cancel any URLRequests that are
395 // using it still, before we destroy the member variables that those 407 // using it still, before we destroy the member variables that those
396 // URLRequests may be accessing. 408 // URLRequests may be accessing.
397 void DestroyResourceContext(); 409 void DestroyResourceContext();
398 410
399 std::unique_ptr<net::HttpNetworkSession> CreateHttpNetworkSession(
400 const ProfileParams& profile_params) const;
401
402 // Creates main network transaction factory. 411 // Creates main network transaction factory.
403 std::unique_ptr<net::HttpCache> CreateMainHttpFactory( 412 std::unique_ptr<net::HttpCache> CreateMainHttpFactory(
404 net::HttpNetworkSession* session, 413 net::HttpNetworkSession* session,
405 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const; 414 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const;
406 415
407 // Creates network transaction factory. The created factory will share 416 // Creates network transaction factory. The created factory will share
408 // HttpNetworkSession with |main_http_factory|. 417 // HttpNetworkSession with |main_http_factory|.
409 std::unique_ptr<net::HttpCache> CreateHttpFactory( 418 std::unique_ptr<net::HttpCache> CreateHttpFactory(
410 net::HttpTransactionFactory* main_http_factory, 419 net::HttpTransactionFactory* main_http_factory,
411 std::unique_ptr<net::HttpCache::BackendFactory> backend) const; 420 std::unique_ptr<net::HttpCache::BackendFactory> backend) const;
(...skipping 29 matching lines...) Expand all
441 // Virtual interface for subtypes to implement: 450 // Virtual interface for subtypes to implement:
442 // -------------------------------------------- 451 // --------------------------------------------
443 452
444 // Does any necessary additional configuration of the network delegate, 453 // Does any necessary additional configuration of the network delegate,
445 // including composing it with other NetworkDelegates, if needed. By default, 454 // including composing it with other NetworkDelegates, if needed. By default,
446 // just returns the input NetworkDelegate. 455 // just returns the input NetworkDelegate.
447 virtual std::unique_ptr<net::NetworkDelegate> ConfigureNetworkDelegate( 456 virtual std::unique_ptr<net::NetworkDelegate> ConfigureNetworkDelegate(
448 IOThread* io_thread, 457 IOThread* io_thread,
449 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const; 458 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const;
450 459
451 // Does the actual initialization of the ProfileIOData subtype. Subtypes 460 // Does the initialization of the URLRequestContextBuilder for a ProfileIOData
452 // should use the static helper functions above to implement this. 461 // subclass. Subclasseses should use the static helper functions above to
462 // implement this.
453 virtual void InitializeInternal( 463 virtual void InitializeInternal(
464 net::URLRequestContextBuilder* builder,
454 ProfileParams* profile_params, 465 ProfileParams* profile_params,
455 content::ProtocolHandlerMap* protocol_handlers, 466 content::ProtocolHandlerMap* protocol_handlers,
456 content::URLRequestInterceptorScopedVector request_interceptors) 467 content::URLRequestInterceptorScopedVector request_interceptors)
457 const = 0; 468 const = 0;
458 469
470 // Called after the main URLRequestContext has been initialized, just after
471 // InitializeInternal().
472 virtual void OnMainRequestContextCreated(
473 ProfileParams* profile_params) const = 0;
474
459 // Initializes the RequestContext for extensions. 475 // Initializes the RequestContext for extensions.
460 virtual void InitializeExtensionsRequestContext( 476 virtual void InitializeExtensionsRequestContext(
461 ProfileParams* profile_params) const = 0; 477 ProfileParams* profile_params) const = 0;
462 // Does an on-demand initialization of a RequestContext for the given 478 // Does an on-demand initialization of a RequestContext for the given
463 // isolated app. 479 // isolated app.
464 virtual net::URLRequestContext* InitializeAppRequestContext( 480 virtual net::URLRequestContext* InitializeAppRequestContext(
465 net::URLRequestContext* main_context, 481 net::URLRequestContext* main_context,
466 const StoragePartitionDescriptor& details, 482 const StoragePartitionDescriptor& details,
467 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 483 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
468 protocol_handler_interceptor, 484 protocol_handler_interceptor,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 #if defined(OS_CHROMEOS) 573 #if defined(OS_CHROMEOS)
558 // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that 574 // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that
559 // case, the verifier is owned by |cert_verifier_|. Otherwise, set to NULL. 575 // case, the verifier is owned by |cert_verifier_|. Otherwise, set to NULL.
560 mutable std::unique_ptr<net::CertVerifier> cert_verifier_; 576 mutable std::unique_ptr<net::CertVerifier> cert_verifier_;
561 mutable policy::PolicyCertVerifier* policy_cert_verifier_; 577 mutable policy::PolicyCertVerifier* policy_cert_verifier_;
562 mutable std::string username_hash_; 578 mutable std::string username_hash_;
563 mutable bool use_system_key_slot_; 579 mutable bool use_system_key_slot_;
564 mutable std::unique_ptr<chromeos::CertificateProvider> certificate_provider_; 580 mutable std::unique_ptr<chromeos::CertificateProvider> certificate_provider_;
565 #endif 581 #endif
566 582
567 // Owns the subset of URLRequestContext's elements that are created by
568 // subclasses of ProfileImplIOData, to ensure proper destruction ordering.
569 // TODO(mmenke): Move ownship of net objects owned by the ProfileIOData
570 // itself to this class, to improve destruction ordering.
571 mutable std::unique_ptr<net::URLRequestContextStorage>
572 main_request_context_storage_;
573 mutable std::unique_ptr<net::URLRequestContext> main_request_context_; 583 mutable std::unique_ptr<net::URLRequestContext> main_request_context_;
574 584
575 // Pointed to by the TransportSecurityState (owned by 585 // Pointed to by the TransportSecurityState (owned by
576 // URLRequestContextStorage), and must be disconnected from it before it's 586 // URLRequestContextStorage), and must be disconnected from it before it's
577 // destroyed. 587 // destroyed.
578 mutable std::unique_ptr<net::TransportSecurityPersister>
579 transport_security_persister_;
580 mutable std::unique_ptr<net::ReportSender> certificate_report_sender_; 588 mutable std::unique_ptr<net::ReportSender> certificate_report_sender_;
581 mutable std::unique_ptr<certificate_transparency::CTPolicyManager> 589 mutable std::unique_ptr<certificate_transparency::CTPolicyManager>
582 ct_policy_manager_; 590 ct_policy_manager_;
583 591
584 mutable std::unique_ptr<net::URLRequestContext> extensions_request_context_; 592 mutable std::unique_ptr<net::URLRequestContext> extensions_request_context_;
585 // One URLRequestContext per isolated app for main and media requests. 593 // One URLRequestContext per isolated app for main and media requests.
586 mutable URLRequestContextMap app_request_context_map_; 594 mutable URLRequestContextMap app_request_context_map_;
587 mutable URLRequestContextMap isolated_media_request_context_map_; 595 mutable URLRequestContextMap isolated_media_request_context_map_;
588 596
589 mutable std::unique_ptr<ResourceContext> resource_context_; 597 mutable std::unique_ptr<ResourceContext> resource_context_;
(...skipping 19 matching lines...) Expand all
609 mutable std::unique_ptr<certificate_transparency::TreeStateTracker> 617 mutable std::unique_ptr<certificate_transparency::TreeStateTracker>
610 ct_tree_tracker_; 618 ct_tree_tracker_;
611 mutable base::Closure ct_tree_tracker_unregistration_; 619 mutable base::Closure ct_tree_tracker_unregistration_;
612 620
613 const Profile::ProfileType profile_type_; 621 const Profile::ProfileType profile_type_;
614 622
615 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 623 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
616 }; 624 };
617 625
618 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 626 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698