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

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

Issue 1239393003: Refactor main URLRequestContext creation to use URLRequestContextBuilder Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/io_thread.h" 21 #include "chrome/browser/io_thread.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/profiles/storage_partition_descriptor.h" 23 #include "chrome/browser/profiles/storage_partition_descriptor.h"
24 #include "components/content_settings/core/common/content_settings_types.h" 24 #include "components/content_settings/core/common/content_settings_types.h"
25 #include "content/public/browser/content_browser_client.h" 25 #include "content/public/browser/content_browser_client.h"
26 #include "content/public/browser/resource_context.h" 26 #include "content/public/browser/resource_context.h"
27 #include "net/cookies/cookie_monster.h" 27 #include "net/cookies/cookie_monster.h"
28 #include "net/http/http_cache.h" 28 #include "net/http/http_cache.h"
29 #include "net/http/http_network_session.h" 29 #include "net/http/http_network_session.h"
30 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
31 #include "net/url_request/url_request_context_builder.h"
31 #include "net/url_request/url_request_interceptor.h" 32 #include "net/url_request/url_request_interceptor.h"
32 #include "net/url_request/url_request_job_factory.h" 33 #include "net/url_request/url_request_job_factory.h"
33 34
34 class ChromeHttpUserAgentSettings; 35 class ChromeHttpUserAgentSettings;
35 class ChromeNetworkDelegate; 36 class ChromeNetworkDelegate;
36 class ChromeURLRequestContextGetter; 37 class ChromeURLRequestContextGetter;
37 class DevToolsNetworkController; 38 class DevToolsNetworkController;
38 class HostContentSettingsMap; 39 class HostContentSettingsMap;
39 class MediaDeviceIDSalt; 40 class MediaDeviceIDSalt;
40 class ProtocolHandlerRegistry; 41 class ProtocolHandlerRegistry;
(...skipping 22 matching lines...) Expand all
63 class CookieStore; 64 class CookieStore;
64 class FraudulentCertificateReporter; 65 class FraudulentCertificateReporter;
65 class FtpTransactionFactory; 66 class FtpTransactionFactory;
66 class HttpServerProperties; 67 class HttpServerProperties;
67 class HttpTransactionFactory; 68 class HttpTransactionFactory;
68 class ProxyConfigService; 69 class ProxyConfigService;
69 class ProxyService; 70 class ProxyService;
70 class SSLConfigService; 71 class SSLConfigService;
71 class TransportSecurityPersister; 72 class TransportSecurityPersister;
72 class TransportSecurityState; 73 class TransportSecurityState;
74 class URLRequestContextBuilder;
73 class URLRequestJobFactoryImpl; 75 class URLRequestJobFactoryImpl;
74 } // namespace net 76 } // namespace net
75 77
76 namespace policy { 78 namespace policy {
77 class PolicyCertVerifier; 79 class PolicyCertVerifier;
78 class PolicyHeaderIOHelper; 80 class PolicyHeaderIOHelper;
79 class URLBlacklistManager; 81 class URLBlacklistManager;
80 } // namespace policy 82 } // namespace policy
81 83
82 // Conceptually speaking, the ProfileIOData represents data that lives on the IO 84 // Conceptually speaking, the ProfileIOData represents data that lives on the IO
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 IntegerPrefMember* network_prediction_options() const { 169 IntegerPrefMember* network_prediction_options() const {
168 return &network_prediction_options_; 170 return &network_prediction_options_;
169 } 171 }
170 172
171 content::ResourceContext::SaltCallback GetMediaDeviceIDSalt() const; 173 content::ResourceContext::SaltCallback GetMediaDeviceIDSalt() const;
172 174
173 DevToolsNetworkController* network_controller() const { 175 DevToolsNetworkController* network_controller() const {
174 return network_controller_.get(); 176 return network_controller_.get();
175 } 177 }
176 178
177 net::TransportSecurityState* transport_security_state() const { 179 net::TransportSecurityState* transport_security_state() const;
178 return transport_security_state_.get();
179 }
180 180
181 #if defined(OS_CHROMEOS) 181 #if defined(OS_CHROMEOS)
182 std::string username_hash() const { 182 std::string username_hash() const {
183 return username_hash_; 183 return username_hash_;
184 } 184 }
185 185
186 bool use_system_key_slot() const { return use_system_key_slot_; } 186 bool use_system_key_slot() const { return use_system_key_slot_; }
187 #endif 187 #endif
188 188
189 Profile::ProfileType profile_type() const { 189 Profile::ProfileType profile_type() const {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 std::string username_hash; 311 std::string username_hash;
312 bool use_system_key_slot; 312 bool use_system_key_slot;
313 #endif 313 #endif
314 314
315 // The profile this struct was populated from. It's passed as a void* to 315 // The profile this struct was populated from. It's passed as a void* to
316 // ensure it's not accidently used on the IO thread. Before using it on the 316 // ensure it's not accidently used on the IO thread. Before using it on the
317 // UI thread, call ProfileManager::IsValidProfile to ensure it's alive. 317 // UI thread, call ProfileManager::IsValidProfile to ensure it's alive.
318 void* profile; 318 void* profile;
319 }; 319 };
320 320
321 // Declared here to allow access to ProfileParams.
322 class HttpTransactionFactoryDelegate
323 : public net::HttpTransactionFactoryFactory {
324 public:
325 HttpTransactionFactoryDelegate(const ProfileIOData* owner,
326 const ProfileParams* profile_params,
327 net::HttpCache::BackendFactory* main_backend)
328 : owner_(owner),
329 profile_params_(profile_params),
330 main_backend_(main_backend) {}
331
332 net::HttpTransactionFactory* Create(
333 net::URLRequestContext* context) override;
334
335 private:
336 const ProfileIOData* owner_;
337 const ProfileParams* profile_params_;
338 net::HttpCache::BackendFactory* main_backend_;
339 };
340
341 // Declared here to allow access to protected functions.
342 class CertVerifierDelegateMainContext : public net::CertVerifierDelegate {
343 public:
344 CertVerifierDelegateMainContext(const ProfileIOData* owner)
345 : owner_(owner) {}
346
347 net::CertVerifier* Get(net::URLRequestContext* context) override;
348
349 private:
350 const ProfileIOData* owner_;
351 };
352
353 net::CertVerifier* GetCertVerifierForMainContext(
354 net::URLRequestContext* context) const;
355
321 explicit ProfileIOData(Profile::ProfileType profile_type); 356 explicit ProfileIOData(Profile::ProfileType profile_type);
322 357
323 static std::string GetSSLSessionCacheShard(); 358 static std::string GetSSLSessionCacheShard();
324 359
325 void InitializeOnUIThread(Profile* profile); 360 void InitializeOnUIThread(Profile* profile);
326 void ApplyProfileParamsToContext(net::URLRequestContext* context) const; 361 void ApplyProfileParamsToContext(net::URLRequestContext* context) const;
362 void ApplyProfileParamsToContext(
363 net::URLRequestContextBuilder* context_builder) const;
327 364
328 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( 365 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
329 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, 366 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory,
330 content::URLRequestInterceptorScopedVector request_interceptors, 367 content::URLRequestInterceptorScopedVector request_interceptors,
331 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 368 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
332 protocol_handler_interceptor, 369 protocol_handler_interceptor,
333 net::NetworkDelegate* network_delegate, 370 net::NetworkDelegate* network_delegate,
334 net::FtpTransactionFactory* ftp_transaction_factory) const; 371 net::FtpTransactionFactory* ftp_transaction_factory) const;
335 372
336 // Called when the Profile is destroyed. |context_getters| must include all 373 // Called when the Profile is destroyed. |context_getters| must include all
337 // URLRequestContextGetters that refer to the ProfileIOData's 374 // URLRequestContextGetters that refer to the ProfileIOData's
338 // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts 375 // URLRequestContexts. Triggers destruction of the ProfileIOData and shuts
339 // down |context_getters| safely on the IO thread. 376 // down |context_getters| safely on the IO thread.
340 // TODO(mmenke): Passing all those URLRequestContextGetters around like this 377 // TODO(mmenke): Passing all those URLRequestContextGetters around like this
341 // is really silly. Can we do something cleaner? 378 // is really silly. Can we do something cleaner?
342 void ShutdownOnUIThread( 379 void ShutdownOnUIThread(
343 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters); 380 scoped_ptr<ChromeURLRequestContextGetterVector> context_getters);
344 381
345 // A ChannelIDService object is created by a derived class of
346 // ProfileIOData, and the derived class calls this method to set the
347 // channel_id_service_ member and transfers ownership to the base
348 // class.
349 void set_channel_id_service(
350 net::ChannelIDService* channel_id_service) const;
351
352 void set_data_reduction_proxy_io_data( 382 void set_data_reduction_proxy_io_data(
353 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> 383 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
354 data_reduction_proxy_io_data) const; 384 data_reduction_proxy_io_data) const;
355 385
356 net::FraudulentCertificateReporter* fraudulent_certificate_reporter() const { 386 net::FraudulentCertificateReporter* fraudulent_certificate_reporter() const;
357 return fraudulent_certificate_reporter_.get();
358 }
359 387
360 net::ProxyService* proxy_service() const { 388 net::ProxyService* proxy_service() const {
361 return proxy_service_.get(); 389 return proxy_service_.get();
362 } 390 }
363 391
364 base::WeakPtr<net::HttpServerProperties> http_server_properties() const; 392 base::WeakPtr<net::HttpServerProperties> http_server_properties() const;
365 393
366 void set_http_server_properties( 394 void set_http_server_properties(
367 scoped_ptr<net::HttpServerProperties> http_server_properties) const; 395 scoped_ptr<net::HttpServerProperties> http_server_properties) const;
368 396
369 net::URLRequestContext* main_request_context() const { 397 net::URLRequestContext* main_request_context() const {
370 return main_request_context_.get(); 398 return main_request_context_.get();
371 } 399 }
372 400
373 bool initialized() const { 401 bool initialized() const {
374 return initialized_; 402 return initialized_;
375 } 403 }
376 404
377 // Destroys the ResourceContext first, to cancel any URLRequests that are 405 // Destroys the ResourceContext first, to cancel any URLRequests that are
378 // using it still, before we destroy the member variables that those 406 // using it still, before we destroy the member variables that those
379 // URLRequests may be accessing. 407 // URLRequests may be accessing.
380 void DestroyResourceContext(); 408 void DestroyResourceContext();
381 409
382 // Creates network session and main network transaction factory. 410 // Creates network session and main network transaction factory.
383 scoped_ptr<net::HttpCache> CreateMainHttpFactory( 411 scoped_ptr<net::HttpCache> CreateMainHttpFactory(
384 const ProfileParams* profile_params, 412 const ProfileParams* profile_params,
385 net::HttpCache::BackendFactory* main_backend) const; 413 net::HttpCache::BackendFactory* main_backend,
414 net::URLRequestContext* context) const;
386 415
387 // Creates network transaction factory. 416 // Creates network transaction factory.
388 scoped_ptr<net::HttpCache> CreateHttpFactory( 417 scoped_ptr<net::HttpCache> CreateHttpFactory(
389 net::HttpNetworkSession* shared_session, 418 net::HttpNetworkSession* shared_session,
390 net::HttpCache::BackendFactory* backend) const; 419 net::HttpCache::BackendFactory* backend) const;
391 420
392 void SetCookieSettingsForTesting( 421 void SetCookieSettingsForTesting(
393 content_settings::CookieSettings* cookie_settings); 422 content_settings::CookieSettings* cookie_settings);
394 423
395 private: 424 private:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // -------------------------------------------- 456 // --------------------------------------------
428 // Virtual interface for subtypes to implement: 457 // Virtual interface for subtypes to implement:
429 // -------------------------------------------- 458 // --------------------------------------------
430 459
431 // Does the actual initialization of the ProfileIOData subtype. Subtypes 460 // Does the actual initialization of the ProfileIOData subtype. Subtypes
432 // should use the static helper functions above to implement this. 461 // should use the static helper functions above to implement this.
433 virtual void InitializeInternal( 462 virtual void InitializeInternal(
434 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate, 463 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate,
435 ProfileParams* profile_params, 464 ProfileParams* profile_params,
436 content::ProtocolHandlerMap* protocol_handlers, 465 content::ProtocolHandlerMap* protocol_handlers,
437 content::URLRequestInterceptorScopedVector 466 content::URLRequestInterceptorScopedVector request_interceptors,
438 request_interceptors) const = 0; 467 net::URLRequestContextBuilder* context_builder) const = 0;
439 468
440 // Initializes the RequestContext for extensions. 469 // Initializes the RequestContext for extensions.
441 virtual void InitializeExtensionsRequestContext( 470 virtual void InitializeExtensionsRequestContext(
442 ProfileParams* profile_params) const = 0; 471 ProfileParams* profile_params) const = 0;
443 // Does an on-demand initialization of a RequestContext for the given 472 // Does an on-demand initialization of a RequestContext for the given
444 // isolated app. 473 // isolated app.
445 virtual net::URLRequestContext* InitializeAppRequestContext( 474 virtual net::URLRequestContext* InitializeAppRequestContext(
446 net::URLRequestContext* main_context, 475 net::URLRequestContext* main_context,
447 const StoragePartitionDescriptor& details, 476 const StoragePartitionDescriptor& details,
448 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 477 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
(...skipping 18 matching lines...) Expand all
467 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 496 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
468 protocol_handler_interceptor, 497 protocol_handler_interceptor,
469 content::ProtocolHandlerMap* protocol_handlers, 498 content::ProtocolHandlerMap* protocol_handlers,
470 content::URLRequestInterceptorScopedVector 499 content::URLRequestInterceptorScopedVector
471 request_interceptors) const = 0; 500 request_interceptors) const = 0;
472 virtual net::URLRequestContext* 501 virtual net::URLRequestContext*
473 AcquireIsolatedMediaRequestContext( 502 AcquireIsolatedMediaRequestContext(
474 net::URLRequestContext* app_context, 503 net::URLRequestContext* app_context,
475 const StoragePartitionDescriptor& partition_descriptor) const = 0; 504 const StoragePartitionDescriptor& partition_descriptor) const = 0;
476 505
506 virtual void InitPostContextSetup(
507 ChromeNetworkDelegate* chrome_network_delegate) const {}
508
477 // The order *DOES* matter for the majority of these member variables, so 509 // The order *DOES* matter for the majority of these member variables, so
478 // don't move them around unless you know what you're doing! 510 // don't move them around unless you know what you're doing!
479 // General rules: 511 // General rules:
480 // * ResourceContext references the URLRequestContexts, so 512 // * ResourceContext references the URLRequestContexts, so
481 // URLRequestContexts must outlive ResourceContext, hence ResourceContext 513 // URLRequestContexts must outlive ResourceContext, hence ResourceContext
482 // should be destroyed first. 514 // should be destroyed first.
483 // * URLRequestContexts reference a whole bunch of members, so 515 // * URLRequestContexts reference a whole bunch of members, so
484 // URLRequestContext needs to be destroyed before them. 516 // URLRequestContext needs to be destroyed before them.
485 // * Therefore, ResourceContext should be listed last, and then the 517 // * Therefore, ResourceContext should be listed last, and then the
486 // URLRequestContexts, and then the URLRequestContext members. 518 // URLRequestContexts, and then the URLRequestContext members.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 #if defined(ENABLE_CONFIGURATION_POLICY) 560 #if defined(ENABLE_CONFIGURATION_POLICY)
529 // Pointed to by NetworkDelegate. 561 // Pointed to by NetworkDelegate.
530 mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_; 562 mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_;
531 mutable scoped_ptr<policy::PolicyHeaderIOHelper> policy_header_helper_; 563 mutable scoped_ptr<policy::PolicyHeaderIOHelper> policy_header_helper_;
532 #endif 564 #endif
533 565
534 // Pointed to by URLRequestContext. 566 // Pointed to by URLRequestContext.
535 #if defined(ENABLE_EXTENSIONS) 567 #if defined(ENABLE_EXTENSIONS)
536 mutable scoped_refptr<extensions::InfoMap> extension_info_map_; 568 mutable scoped_refptr<extensions::InfoMap> extension_info_map_;
537 #endif 569 #endif
538 mutable scoped_ptr<net::ChannelIDService> channel_id_service_;
539 570
540 mutable scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> 571 mutable scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
541 data_reduction_proxy_io_data_; 572 data_reduction_proxy_io_data_;
542 573
543 mutable scoped_ptr<net::FraudulentCertificateReporter> 574 mutable scoped_ptr<net::FraudulentCertificateReporter>
544 fraudulent_certificate_reporter_; 575 fraudulent_certificate_reporter_;
545 mutable scoped_ptr<net::ProxyService> proxy_service_; 576 mutable scoped_ptr<net::ProxyService> proxy_service_;
546 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_;
547 mutable scoped_ptr<net::HttpServerProperties> 577 mutable scoped_ptr<net::HttpServerProperties>
548 http_server_properties_; 578 http_server_properties_;
549 #if defined(OS_CHROMEOS) 579 #if defined(OS_CHROMEOS)
550 // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that 580 // Set to |cert_verifier_| if it references a PolicyCertVerifier. In that
551 // case, the verifier is owned by |cert_verifier_|. Otherwise, set to NULL. 581 // case, the verifier is owned by |cert_verifier_|. Otherwise, set to NULL.
552 mutable policy::PolicyCertVerifier* policy_cert_verifier_; 582 mutable policy::PolicyCertVerifier* policy_cert_verifier_;
553 mutable scoped_ptr<net::CertVerifier> cert_verifier_; 583 mutable scoped_ptr<net::CertVerifier> cert_verifier_;
554 mutable std::string username_hash_; 584 mutable std::string username_hash_;
555 mutable bool use_system_key_slot_; 585 mutable bool use_system_key_slot_;
556 #endif 586 #endif
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 623
594 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 624 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
595 bool initialized_on_UI_thread_; 625 bool initialized_on_UI_thread_;
596 626
597 const Profile::ProfileType profile_type_; 627 const Profile::ProfileType profile_type_;
598 628
599 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 629 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
600 }; 630 };
601 631
602 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 632 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698