| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // net::URLRequest. | 73 // net::URLRequest. |
| 74 static bool IsHandledProtocol(const std::string& scheme); | 74 static bool IsHandledProtocol(const std::string& scheme); |
| 75 | 75 |
| 76 // Returns true if |url| is handled in Chrome, or by default handlers in | 76 // Returns true if |url| is handled in Chrome, or by default handlers in |
| 77 // net::URLRequest. | 77 // net::URLRequest. |
| 78 static bool IsHandledURL(const GURL& url); | 78 static bool IsHandledURL(const GURL& url); |
| 79 | 79 |
| 80 // Called by Profile. | 80 // Called by Profile. |
| 81 content::ResourceContext* GetResourceContext() const; | 81 content::ResourceContext* GetResourceContext() const; |
| 82 | 82 |
| 83 // These should only be called at most once each. Ownership is reversed when | 83 // Initializes the ProfileIOData object and primes the RequestContext |
| 84 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice | 84 // generation. Must be called prior to any of the Get*() methods other than |
| 85 // versa. | 85 // GetResouceContext or GetMetricsEnabledStateOnIOThread. |
| 86 void Init( |
| 87 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 88 blob_protocol_handler, |
| 89 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 90 file_system_protocol_handler, |
| 91 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 92 developer_protocol_handler, |
| 93 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 94 chrome_protocol_handler, |
| 95 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 96 chrome_devtools_protocol_handler) const; |
| 97 |
| 86 ChromeURLRequestContext* GetMainRequestContext() const; | 98 ChromeURLRequestContext* GetMainRequestContext() const; |
| 87 ChromeURLRequestContext* GetMediaRequestContext() const; | 99 ChromeURLRequestContext* GetMediaRequestContext() const; |
| 88 ChromeURLRequestContext* GetExtensionsRequestContext() const; | 100 ChromeURLRequestContext* GetExtensionsRequestContext() const; |
| 89 ChromeURLRequestContext* GetIsolatedAppRequestContext( | 101 ChromeURLRequestContext* GetIsolatedAppRequestContext( |
| 90 ChromeURLRequestContext* main_context, | 102 ChromeURLRequestContext* main_context, |
| 91 const StoragePartitionDescriptor& partition_descriptor, | 103 const StoragePartitionDescriptor& partition_descriptor, |
| 92 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 104 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 93 protocol_handler_interceptor) const; | 105 protocol_handler_interceptor, |
| 106 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 107 blob_protocol_handler, |
| 108 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 109 file_system_protocol_handler, |
| 110 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 111 developer_protocol_handler, |
| 112 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 113 chrome_protocol_handler, |
| 114 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 115 chrome_devtools_protocol_handler) const; |
| 94 ChromeURLRequestContext* GetIsolatedMediaRequestContext( | 116 ChromeURLRequestContext* GetIsolatedMediaRequestContext( |
| 95 ChromeURLRequestContext* app_context, | 117 ChromeURLRequestContext* app_context, |
| 96 const StoragePartitionDescriptor& partition_descriptor) const; | 118 const StoragePartitionDescriptor& partition_descriptor) const; |
| 97 | 119 |
| 98 // These are useful when the Chrome layer is called from the content layer | 120 // These are useful when the Chrome layer is called from the content layer |
| 99 // with a content::ResourceContext, and they want access to Chrome data for | 121 // with a content::ResourceContext, and they want access to Chrome data for |
| 100 // that profile. | 122 // that profile. |
| 101 ExtensionInfoMap* GetExtensionInfoMap() const; | 123 ExtensionInfoMap* GetExtensionInfoMap() const; |
| 102 CookieSettings* GetCookieSettings() const; | 124 CookieSettings* GetCookieSettings() const; |
| 103 | 125 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; | 289 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; |
| 268 | 290 |
| 269 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( | 291 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( |
| 270 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, | 292 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, |
| 271 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 293 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 272 protocol_handler_interceptor, | 294 protocol_handler_interceptor, |
| 273 net::NetworkDelegate* network_delegate, | 295 net::NetworkDelegate* network_delegate, |
| 274 net::FtpTransactionFactory* ftp_transaction_factory, | 296 net::FtpTransactionFactory* ftp_transaction_factory, |
| 275 net::FtpAuthCache* ftp_auth_cache) const; | 297 net::FtpAuthCache* ftp_auth_cache) const; |
| 276 | 298 |
| 277 // Lazy initializes the ProfileIOData object the first time a request context | |
| 278 // is requested. The lazy logic is implemented here. The actual initialization | |
| 279 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper | |
| 280 // functions have been provided to assist in common operations. | |
| 281 void LazyInitialize() const; | |
| 282 | |
| 283 // Called when the profile is destroyed. | 299 // Called when the profile is destroyed. |
| 284 void ShutdownOnUIThread(); | 300 void ShutdownOnUIThread(); |
| 285 | 301 |
| 286 // A ServerBoundCertService object is created by a derived class of | 302 // A ServerBoundCertService object is created by a derived class of |
| 287 // ProfileIOData, and the derived class calls this method to set the | 303 // ProfileIOData, and the derived class calls this method to set the |
| 288 // server_bound_cert_service_ member and transfers ownership to the base | 304 // server_bound_cert_service_ member and transfers ownership to the base |
| 289 // class. | 305 // class. |
| 290 void set_server_bound_cert_service( | 306 void set_server_bound_cert_service( |
| 291 net::ServerBoundCertService* server_bound_cert_service) const; | 307 net::ServerBoundCertService* server_bound_cert_service) const; |
| 292 | 308 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 308 net::HttpServerProperties* http_server_properties) const; | 324 net::HttpServerProperties* http_server_properties) const; |
| 309 | 325 |
| 310 ChromeURLRequestContext* main_request_context() const { | 326 ChromeURLRequestContext* main_request_context() const { |
| 311 return main_request_context_.get(); | 327 return main_request_context_.get(); |
| 312 } | 328 } |
| 313 | 329 |
| 314 chrome_browser_net::LoadTimeStats* load_time_stats() const { | 330 chrome_browser_net::LoadTimeStats* load_time_stats() const { |
| 315 return load_time_stats_; | 331 return load_time_stats_; |
| 316 } | 332 } |
| 317 | 333 |
| 334 bool initialized() const { |
| 335 return initialized_; |
| 336 } |
| 337 |
| 318 // Destroys the ResourceContext first, to cancel any URLRequests that are | 338 // Destroys the ResourceContext first, to cancel any URLRequests that are |
| 319 // using it still, before we destroy the member variables that those | 339 // using it still, before we destroy the member variables that those |
| 320 // URLRequests may be accessing. | 340 // URLRequests may be accessing. |
| 321 void DestroyResourceContext(); | 341 void DestroyResourceContext(); |
| 322 | 342 |
| 323 // Fills in fields of params using values from main_request_context_ and the | 343 // Fills in fields of params using values from main_request_context_ and the |
| 324 // IOThread associated with profile_params. | 344 // IOThread associated with profile_params. |
| 325 void PopulateNetworkSessionParams( | 345 void PopulateNetworkSessionParams( |
| 326 const ProfileParams* profile_params, | 346 const ProfileParams* profile_params, |
| 327 net::HttpNetworkSession::Params* params) const; | 347 net::HttpNetworkSession::Params* params) const; |
| 328 | 348 |
| 329 void SetCookieSettingsForTesting(CookieSettings* cookie_settings); | 349 void SetCookieSettingsForTesting(CookieSettings* cookie_settings); |
| 330 | 350 |
| 331 void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names); | 351 void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names); |
| 332 | 352 |
| 333 private: | 353 private: |
| 334 class ResourceContext : public content::ResourceContext { | 354 class ResourceContext : public content::ResourceContext { |
| 335 public: | 355 public: |
| 336 explicit ResourceContext(ProfileIOData* io_data); | 356 explicit ResourceContext(ProfileIOData* io_data); |
| 337 virtual ~ResourceContext(); | 357 virtual ~ResourceContext(); |
| 338 | 358 |
| 339 // ResourceContext implementation: | 359 // ResourceContext implementation: |
| 340 virtual net::HostResolver* GetHostResolver() OVERRIDE; | 360 virtual net::HostResolver* GetHostResolver() OVERRIDE; |
| 341 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; | 361 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; |
| 342 | 362 |
| 343 private: | 363 private: |
| 344 friend class ProfileIOData; | 364 friend class ProfileIOData; |
| 345 | 365 |
| 346 void EnsureInitialized(); | |
| 347 | |
| 348 ProfileIOData* const io_data_; | 366 ProfileIOData* const io_data_; |
| 349 | 367 |
| 350 net::HostResolver* host_resolver_; | 368 net::HostResolver* host_resolver_; |
| 351 net::URLRequestContext* request_context_; | 369 net::URLRequestContext* request_context_; |
| 352 }; | 370 }; |
| 353 | 371 |
| 354 typedef std::map<StoragePartitionDescriptor, | 372 typedef std::map<StoragePartitionDescriptor, |
| 355 ChromeURLRequestContext*, | 373 ChromeURLRequestContext*, |
| 356 StoragePartitionDescriptorLess> | 374 StoragePartitionDescriptorLess> |
| 357 URLRequestContextMap; | 375 URLRequestContextMap; |
| 358 | 376 |
| 359 // -------------------------------------------- | 377 // -------------------------------------------- |
| 360 // Virtual interface for subtypes to implement: | 378 // Virtual interface for subtypes to implement: |
| 361 // -------------------------------------------- | 379 // -------------------------------------------- |
| 362 | 380 |
| 363 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 381 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
| 364 // should use the static helper functions above to implement this. | 382 // should use the static helper functions above to implement this. |
| 365 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; | 383 virtual void InitializeInternal( |
| 384 ProfileParams* profile_params, |
| 385 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 386 blob_protocol_handler, |
| 387 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 388 file_system_protocol_handler, |
| 389 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 390 developer_protocol_handler, |
| 391 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 392 chrome_protocol_handler, |
| 393 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 394 chrome_devtools_protocol_handler) const = 0; |
| 366 | 395 |
| 367 // Initializes the RequestContext for extensions. | 396 // Initializes the RequestContext for extensions. |
| 368 virtual void InitializeExtensionsRequestContext( | 397 virtual void InitializeExtensionsRequestContext( |
| 369 ProfileParams* profile_params) const = 0; | 398 ProfileParams* profile_params) const = 0; |
| 370 // Does an on-demand initialization of a RequestContext for the given | 399 // Does an on-demand initialization of a RequestContext for the given |
| 371 // isolated app. | 400 // isolated app. |
| 372 virtual ChromeURLRequestContext* InitializeAppRequestContext( | 401 virtual ChromeURLRequestContext* InitializeAppRequestContext( |
| 373 ChromeURLRequestContext* main_context, | 402 ChromeURLRequestContext* main_context, |
| 374 const StoragePartitionDescriptor& details, | 403 const StoragePartitionDescriptor& details, |
| 375 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 404 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 376 protocol_handler_interceptor) const = 0; | 405 protocol_handler_interceptor, |
| 406 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 407 blob_protocol_handler, |
| 408 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 409 file_system_protocol_handler, |
| 410 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 411 developer_protocol_handler, |
| 412 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 413 chrome_protocol_handler, |
| 414 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 415 chrome_devtools_protocol_handler) const = 0; |
| 377 | 416 |
| 378 // Does an on-demand initialization of a media RequestContext for the given | 417 // Does an on-demand initialization of a media RequestContext for the given |
| 379 // isolated app. | 418 // isolated app. |
| 380 virtual ChromeURLRequestContext* InitializeMediaRequestContext( | 419 virtual ChromeURLRequestContext* InitializeMediaRequestContext( |
| 381 ChromeURLRequestContext* original_context, | 420 ChromeURLRequestContext* original_context, |
| 382 const StoragePartitionDescriptor& details) const = 0; | 421 const StoragePartitionDescriptor& details) const = 0; |
| 383 | 422 |
| 384 // These functions are used to transfer ownership of the lazily initialized | 423 // These functions are used to transfer ownership of the lazily initialized |
| 385 // context from ProfileIOData to the URLRequestContextGetter. | 424 // context from ProfileIOData to the URLRequestContextGetter. |
| 386 virtual ChromeURLRequestContext* | 425 virtual ChromeURLRequestContext* |
| 387 AcquireMediaRequestContext() const = 0; | 426 AcquireMediaRequestContext() const = 0; |
| 388 virtual ChromeURLRequestContext* | 427 virtual ChromeURLRequestContext* |
| 389 AcquireIsolatedAppRequestContext( | 428 AcquireIsolatedAppRequestContext( |
| 390 ChromeURLRequestContext* main_context, | 429 ChromeURLRequestContext* main_context, |
| 391 const StoragePartitionDescriptor& partition_descriptor, | 430 const StoragePartitionDescriptor& partition_descriptor, |
| 392 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 431 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 393 protocol_handler_interceptor) const = 0; | 432 protocol_handler_interceptor, |
| 433 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 434 blob_protocol_handler, |
| 435 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 436 file_system_protocol_handler, |
| 437 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 438 developer_protocol_handler, |
| 439 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 440 chrome_protocol_handler, |
| 441 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 442 chrome_devtools_protocol_handler) const = 0; |
| 394 virtual ChromeURLRequestContext* | 443 virtual ChromeURLRequestContext* |
| 395 AcquireIsolatedMediaRequestContext( | 444 AcquireIsolatedMediaRequestContext( |
| 396 ChromeURLRequestContext* app_context, | 445 ChromeURLRequestContext* app_context, |
| 397 const StoragePartitionDescriptor& partition_descriptor) const = 0; | 446 const StoragePartitionDescriptor& partition_descriptor) const = 0; |
| 398 | 447 |
| 399 // Returns the LoadTimeStats object to be used for this profile. | 448 // Returns the LoadTimeStats object to be used for this profile. |
| 400 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( | 449 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( |
| 401 IOThread::Globals* io_thread_globals) const = 0; | 450 IOThread::Globals* io_thread_globals) const = 0; |
| 402 | 451 |
| 403 // The order *DOES* matter for the majority of these member variables, so | 452 // The order *DOES* matter for the majority of these member variables, so |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 548 |
| 500 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 549 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| 501 bool initialized_on_UI_thread_; | 550 bool initialized_on_UI_thread_; |
| 502 | 551 |
| 503 bool is_incognito_; | 552 bool is_incognito_; |
| 504 | 553 |
| 505 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 554 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 506 }; | 555 }; |
| 507 | 556 |
| 508 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 557 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |