| 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 #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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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. |
| 360 // |
| 361 // TODO(mmenke): Remove this once all URLRequestContexts are set up using |
| 362 // URLRequestContextBuilders. |
| 355 std::unique_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( | 363 std::unique_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( |
| 356 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory, | 364 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory, |
| 357 content::URLRequestInterceptorScopedVector request_interceptors, | 365 content::URLRequestInterceptorScopedVector request_interceptors, |
| 358 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 366 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 359 protocol_handler_interceptor, | 367 protocol_handler_interceptor, |
| 360 net::NetworkDelegate* network_delegate, | 368 net::NetworkDelegate* network_delegate, |
| 361 net::HostResolver* host_resolver) const; | 369 net::HostResolver* host_resolver) const; |
| 362 | 370 |
| 371 // Does common setup of the URLRequestJobFactories. Adds default |
| 372 // ProtocolHandlers to |builder|, and adds URLRequestInterceptors in front of |
| 373 // them as needed. |
| 374 // |
| 375 // |protocol_handler_interceptor| is configured to intercept URLRequests |
| 376 // before all other URLRequestInterceptors, if non-null. |
| 377 // |host_resolver| is needed to set up the FtpProtocolHandler. |
| 378 void SetUpJobFactoryDefaultsForBuilder( |
| 379 net::URLRequestContextBuilder* builder, |
| 380 content::URLRequestInterceptorScopedVector request_interceptors, |
| 381 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 382 protocol_handler_interceptor, |
| 383 net::HostResolver* host_resolver) const; |
| 384 |
| 363 // Called when the Profile is destroyed. |context_getters| must include all | 385 // Called when the Profile is destroyed. |context_getters| must include all |
| 364 // URLRequestContextGetters that refer to the ProfileIOData's | 386 // URLRequestContextGetters that refer to the ProfileIOData's |
| 365 // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts | 387 // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts |
| 366 // down |context_getters| safely on the IO thread. | 388 // down |context_getters| safely on the IO thread. |
| 367 // TODO(mmenke): Passing all those URLRequestContextGetters around like this | 389 // TODO(mmenke): Passing all those URLRequestContextGetters around like this |
| 368 // is really silly. Can we do something cleaner? | 390 // is really silly. Can we do something cleaner? |
| 369 void ShutdownOnUIThread( | 391 void ShutdownOnUIThread( |
| 370 std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters); | 392 std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters); |
| 371 | 393 |
| 372 void set_data_reduction_proxy_io_data( | 394 void set_data_reduction_proxy_io_data( |
| 373 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> | 395 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> |
| 374 data_reduction_proxy_io_data) const; | 396 data_reduction_proxy_io_data) const; |
| 375 | 397 |
| 376 void set_previews_io_data( | 398 void set_previews_io_data( |
| 377 std::unique_ptr<previews::PreviewsIOData> previews_io_data) const; | 399 std::unique_ptr<previews::PreviewsIOData> previews_io_data) const; |
| 378 | 400 |
| 379 net::URLRequestContext* main_request_context() const { | 401 net::URLRequestContext* main_request_context() const { |
| 380 return main_request_context_.get(); | 402 return main_request_context_.get(); |
| 381 } | 403 } |
| 382 | 404 |
| 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 { | 405 bool initialized() const { |
| 391 return initialized_; | 406 return initialized_; |
| 392 } | 407 } |
| 393 | 408 |
| 394 // Destroys the ResourceContext first, to cancel any URLRequests that are | 409 // Destroys the ResourceContext first, to cancel any URLRequests that are |
| 395 // using it still, before we destroy the member variables that those | 410 // using it still, before we destroy the member variables that those |
| 396 // URLRequests may be accessing. | 411 // URLRequests may be accessing. |
| 397 void DestroyResourceContext(); | 412 void DestroyResourceContext(); |
| 398 | 413 |
| 399 std::unique_ptr<net::HttpNetworkSession> CreateHttpNetworkSession( | |
| 400 const ProfileParams& profile_params) const; | |
| 401 | |
| 402 // Creates main network transaction factory. | 414 // Creates main network transaction factory. |
| 403 std::unique_ptr<net::HttpCache> CreateMainHttpFactory( | 415 std::unique_ptr<net::HttpCache> CreateMainHttpFactory( |
| 404 net::HttpNetworkSession* session, | 416 net::HttpNetworkSession* session, |
| 405 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const; | 417 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const; |
| 406 | 418 |
| 407 // Creates network transaction factory. The created factory will share | 419 // Creates network transaction factory. The created factory will share |
| 408 // HttpNetworkSession with |main_http_factory|. | 420 // HttpNetworkSession with |main_http_factory|. |
| 409 std::unique_ptr<net::HttpCache> CreateHttpFactory( | 421 std::unique_ptr<net::HttpCache> CreateHttpFactory( |
| 410 net::HttpTransactionFactory* main_http_factory, | 422 net::HttpTransactionFactory* main_http_factory, |
| 411 std::unique_ptr<net::HttpCache::BackendFactory> backend) const; | 423 std::unique_ptr<net::HttpCache::BackendFactory> backend) const; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 441 // Virtual interface for subtypes to implement: | 453 // Virtual interface for subtypes to implement: |
| 442 // -------------------------------------------- | 454 // -------------------------------------------- |
| 443 | 455 |
| 444 // Does any necessary additional configuration of the network delegate, | 456 // Does any necessary additional configuration of the network delegate, |
| 445 // including composing it with other NetworkDelegates, if needed. By default, | 457 // including composing it with other NetworkDelegates, if needed. By default, |
| 446 // just returns the input NetworkDelegate. | 458 // just returns the input NetworkDelegate. |
| 447 virtual std::unique_ptr<net::NetworkDelegate> ConfigureNetworkDelegate( | 459 virtual std::unique_ptr<net::NetworkDelegate> ConfigureNetworkDelegate( |
| 448 IOThread* io_thread, | 460 IOThread* io_thread, |
| 449 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const; | 461 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const; |
| 450 | 462 |
| 451 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 463 // Does the initialization of the URLRequestContextBuilder for a ProfileIOData |
| 452 // should use the static helper functions above to implement this. | 464 // subclass. Subclasseses should use the static helper functions above to |
| 465 // implement this. |
| 453 virtual void InitializeInternal( | 466 virtual void InitializeInternal( |
| 467 net::URLRequestContextBuilder* builder, |
| 454 ProfileParams* profile_params, | 468 ProfileParams* profile_params, |
| 455 content::ProtocolHandlerMap* protocol_handlers, | 469 content::ProtocolHandlerMap* protocol_handlers, |
| 456 content::URLRequestInterceptorScopedVector request_interceptors) | 470 content::URLRequestInterceptorScopedVector request_interceptors) |
| 457 const = 0; | 471 const = 0; |
| 458 | 472 |
| 473 // Called after the main URLRequestContext has been initialized, just after |
| 474 // InitializeInternal(). |
| 475 virtual void OnMainRequestContextCreated( |
| 476 ProfileParams* profile_params) const = 0; |
| 477 |
| 459 // Initializes the RequestContext for extensions. | 478 // Initializes the RequestContext for extensions. |
| 460 virtual void InitializeExtensionsRequestContext( | 479 virtual void InitializeExtensionsRequestContext( |
| 461 ProfileParams* profile_params) const = 0; | 480 ProfileParams* profile_params) const = 0; |
| 462 // Does an on-demand initialization of a RequestContext for the given | 481 // Does an on-demand initialization of a RequestContext for the given |
| 463 // isolated app. | 482 // isolated app. |
| 464 virtual net::URLRequestContext* InitializeAppRequestContext( | 483 virtual net::URLRequestContext* InitializeAppRequestContext( |
| 465 net::URLRequestContext* main_context, | 484 net::URLRequestContext* main_context, |
| 466 const StoragePartitionDescriptor& details, | 485 const StoragePartitionDescriptor& details, |
| 467 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 486 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 468 protocol_handler_interceptor, | 487 protocol_handler_interceptor, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 #if defined(OS_CHROMEOS) | 576 #if defined(OS_CHROMEOS) |
| 558 // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that | 577 // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that |
| 559 // case, the verifier is owned by |cert_verifier_|. Otherwise, set to NULL. | 578 // case, the verifier is owned by |cert_verifier_|. Otherwise, set to NULL. |
| 560 mutable std::unique_ptr<net::CertVerifier> cert_verifier_; | 579 mutable std::unique_ptr<net::CertVerifier> cert_verifier_; |
| 561 mutable policy::PolicyCertVerifier* policy_cert_verifier_; | 580 mutable policy::PolicyCertVerifier* policy_cert_verifier_; |
| 562 mutable std::string username_hash_; | 581 mutable std::string username_hash_; |
| 563 mutable bool use_system_key_slot_; | 582 mutable bool use_system_key_slot_; |
| 564 mutable std::unique_ptr<chromeos::CertificateProvider> certificate_provider_; | 583 mutable std::unique_ptr<chromeos::CertificateProvider> certificate_provider_; |
| 565 #endif | 584 #endif |
| 566 | 585 |
| 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_; | 586 mutable std::unique_ptr<net::URLRequestContext> main_request_context_; |
| 574 | 587 |
| 575 // Pointed to by the TransportSecurityState (owned by | 588 // Pointed to by the TransportSecurityState (owned by |
| 576 // URLRequestContextStorage), and must be disconnected from it before it's | 589 // URLRequestContextStorage), and must be disconnected from it before it's |
| 577 // destroyed. | 590 // destroyed. |
| 578 mutable std::unique_ptr<net::TransportSecurityPersister> | |
| 579 transport_security_persister_; | |
| 580 mutable std::unique_ptr<net::ReportSender> certificate_report_sender_; | 591 mutable std::unique_ptr<net::ReportSender> certificate_report_sender_; |
| 581 mutable std::unique_ptr<certificate_transparency::CTPolicyManager> | 592 mutable std::unique_ptr<certificate_transparency::CTPolicyManager> |
| 582 ct_policy_manager_; | 593 ct_policy_manager_; |
| 583 | 594 |
| 584 mutable std::unique_ptr<net::URLRequestContext> extensions_request_context_; | 595 mutable std::unique_ptr<net::URLRequestContext> extensions_request_context_; |
| 585 // One URLRequestContext per isolated app for main and media requests. | 596 // One URLRequestContext per isolated app for main and media requests. |
| 586 mutable URLRequestContextMap app_request_context_map_; | 597 mutable URLRequestContextMap app_request_context_map_; |
| 587 mutable URLRequestContextMap isolated_media_request_context_map_; | 598 mutable URLRequestContextMap isolated_media_request_context_map_; |
| 588 | 599 |
| 589 mutable std::unique_ptr<ResourceContext> resource_context_; | 600 mutable std::unique_ptr<ResourceContext> resource_context_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 609 mutable std::unique_ptr<certificate_transparency::TreeStateTracker> | 620 mutable std::unique_ptr<certificate_transparency::TreeStateTracker> |
| 610 ct_tree_tracker_; | 621 ct_tree_tracker_; |
| 611 mutable base::Closure ct_tree_tracker_unregistration_; | 622 mutable base::Closure ct_tree_tracker_unregistration_; |
| 612 | 623 |
| 613 const Profile::ProfileType profile_type_; | 624 const Profile::ProfileType profile_type_; |
| 614 | 625 |
| 615 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 626 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 616 }; | 627 }; |
| 617 | 628 |
| 618 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 629 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |