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