Chromium Code Reviews| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 static bool IsHandledProtocol(const std::string& scheme); | 71 static bool IsHandledProtocol(const std::string& scheme); |
| 72 | 72 |
| 73 // Returns true if |url| is handled in Chrome, or by default handlers in | 73 // Returns true if |url| is handled in Chrome, or by default handlers in |
| 74 // net::URLRequest. | 74 // net::URLRequest. |
| 75 static bool IsHandledURL(const GURL& url); | 75 static bool IsHandledURL(const GURL& url); |
| 76 | 76 |
| 77 // Called by Profile. | 77 // Called by Profile. |
| 78 content::ResourceContext* GetResourceContext() const; | 78 content::ResourceContext* GetResourceContext() const; |
| 79 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; | 79 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; |
| 80 | 80 |
| 81 // These should only be called at most once each. Ownership is reversed when | 81 // Initializes the ProfileIOData object and primes the RequestContext |
| 82 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice | 82 // generation. Must be called prior to any Get*RequestContext() methods. |
| 83 // versa. | 83 // The basic logic is implemented here. The specific initialization |
|
awong
2012/12/13 01:06:15
Comments on lines 83 to 85 should be moved into th
pauljensen
2012/12/13 17:58:44
Done.
| |
| 84 // is done in InitializeInternal(), implemented by subtypes. Static helper | |
| 85 // functions have been provided to assist in common operations. | |
| 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::Interceptor> | |
| 92 developer_protocol_handler) const; | |
| 93 | |
| 84 ChromeURLRequestContext* GetMainRequestContext() const; | 94 ChromeURLRequestContext* GetMainRequestContext() const; |
| 85 ChromeURLRequestContext* GetMediaRequestContext() const; | 95 ChromeURLRequestContext* GetMediaRequestContext() const; |
| 86 ChromeURLRequestContext* GetExtensionsRequestContext() const; | 96 ChromeURLRequestContext* GetExtensionsRequestContext() const; |
| 87 ChromeURLRequestContext* GetIsolatedAppRequestContext( | 97 ChromeURLRequestContext* GetIsolatedAppRequestContext( |
| 88 ChromeURLRequestContext* main_context, | 98 ChromeURLRequestContext* main_context, |
| 89 const StoragePartitionDescriptor& partition_descriptor, | 99 const StoragePartitionDescriptor& partition_descriptor, |
| 90 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 100 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 91 protocol_handler_interceptor) const; | 101 protocol_handler_interceptor, |
| 102 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 103 blob_protocol_handler, | |
| 104 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 105 file_system_protocol_handler, | |
| 106 scoped_ptr<net::URLRequestJobFactory::Interceptor> | |
| 107 developer_protocol_handler) const; | |
| 92 ChromeURLRequestContext* GetIsolatedMediaRequestContext( | 108 ChromeURLRequestContext* GetIsolatedMediaRequestContext( |
| 93 ChromeURLRequestContext* app_context, | 109 ChromeURLRequestContext* app_context, |
| 94 const StoragePartitionDescriptor& partition_descriptor) const; | 110 const StoragePartitionDescriptor& partition_descriptor) const; |
| 95 | 111 |
| 96 // These are useful when the Chrome layer is called from the content layer | 112 // These are useful when the Chrome layer is called from the content layer |
| 97 // with a content::ResourceContext, and they want access to Chrome data for | 113 // with a content::ResourceContext, and they want access to Chrome data for |
| 98 // that profile. | 114 // that profile. |
| 99 ExtensionInfoMap* GetExtensionInfoMap() const; | 115 ExtensionInfoMap* GetExtensionInfoMap() const; |
| 100 CookieSettings* GetCookieSettings() const; | 116 CookieSettings* GetCookieSettings() const; |
| 101 | 117 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; | 258 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; |
| 243 | 259 |
| 244 void SetUpJobFactoryDefaults( | 260 void SetUpJobFactoryDefaults( |
| 245 net::URLRequestJobFactoryImpl* job_factory, | 261 net::URLRequestJobFactoryImpl* job_factory, |
| 246 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 262 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 247 protocol_handler_interceptor, | 263 protocol_handler_interceptor, |
| 248 net::NetworkDelegate* network_delegate, | 264 net::NetworkDelegate* network_delegate, |
| 249 net::FtpTransactionFactory* ftp_transaction_factory, | 265 net::FtpTransactionFactory* ftp_transaction_factory, |
| 250 net::FtpAuthCache* ftp_auth_cache) const; | 266 net::FtpAuthCache* ftp_auth_cache) const; |
| 251 | 267 |
| 252 // Lazy initializes the ProfileIOData object the first time a request context | |
| 253 // is requested. The lazy logic is implemented here. The actual initialization | |
| 254 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper | |
| 255 // functions have been provided to assist in common operations. | |
| 256 void LazyInitialize() const; | |
| 257 | |
| 258 // Called when the profile is destroyed. | 268 // Called when the profile is destroyed. |
| 259 void ShutdownOnUIThread(); | 269 void ShutdownOnUIThread(); |
| 260 | 270 |
| 261 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const { | 271 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const { |
| 262 return chrome_url_data_manager_backend_.get(); | 272 return chrome_url_data_manager_backend_.get(); |
| 263 } | 273 } |
| 264 | 274 |
| 265 // A ServerBoundCertService object is created by a derived class of | 275 // A ServerBoundCertService object is created by a derived class of |
| 266 // ProfileIOData, and the derived class calls this method to set the | 276 // ProfileIOData, and the derived class calls this method to set the |
| 267 // server_bound_cert_service_ member and transfers ownership to the base | 277 // server_bound_cert_service_ member and transfers ownership to the base |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 287 net::HttpServerProperties* http_server_properties) const; | 297 net::HttpServerProperties* http_server_properties) const; |
| 288 | 298 |
| 289 ChromeURLRequestContext* main_request_context() const { | 299 ChromeURLRequestContext* main_request_context() const { |
| 290 return main_request_context_.get(); | 300 return main_request_context_.get(); |
| 291 } | 301 } |
| 292 | 302 |
| 293 chrome_browser_net::LoadTimeStats* load_time_stats() const { | 303 chrome_browser_net::LoadTimeStats* load_time_stats() const { |
| 294 return load_time_stats_; | 304 return load_time_stats_; |
| 295 } | 305 } |
| 296 | 306 |
| 307 bool initialized() const { | |
| 308 return initialized_; | |
| 309 } | |
| 310 | |
| 297 // Destroys the ResourceContext first, to cancel any URLRequests that are | 311 // Destroys the ResourceContext first, to cancel any URLRequests that are |
| 298 // using it still, before we destroy the member variables that those | 312 // using it still, before we destroy the member variables that those |
| 299 // URLRequests may be accessing. | 313 // URLRequests may be accessing. |
| 300 void DestroyResourceContext(); | 314 void DestroyResourceContext(); |
| 301 | 315 |
| 302 // Fills in fields of params using values from main_request_context_ and the | 316 // Fills in fields of params using values from main_request_context_ and the |
| 303 // IOThread associated with profile_params. | 317 // IOThread associated with profile_params. |
| 304 void PopulateNetworkSessionParams( | 318 void PopulateNetworkSessionParams( |
| 305 const ProfileParams* profile_params, | 319 const ProfileParams* profile_params, |
| 306 net::HttpNetworkSession::Params* params) const; | 320 net::HttpNetworkSession::Params* params) const; |
| 307 | 321 |
| 308 void SetCookieSettingsForTesting(CookieSettings* cookie_settings); | 322 void SetCookieSettingsForTesting(CookieSettings* cookie_settings); |
| 309 | 323 |
| 310 void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names); | 324 void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names); |
| 311 | 325 |
| 312 private: | 326 private: |
| 313 class ResourceContext : public content::ResourceContext { | 327 class ResourceContext : public content::ResourceContext { |
| 314 public: | 328 public: |
| 315 explicit ResourceContext(ProfileIOData* io_data); | 329 explicit ResourceContext(ProfileIOData* io_data); |
| 316 virtual ~ResourceContext(); | 330 virtual ~ResourceContext(); |
| 317 | 331 |
| 318 // ResourceContext implementation: | 332 // ResourceContext implementation: |
| 319 virtual net::HostResolver* GetHostResolver() OVERRIDE; | 333 virtual net::HostResolver* GetHostResolver() OVERRIDE; |
| 320 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; | 334 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; |
| 321 | 335 |
| 322 private: | 336 private: |
| 323 friend class ProfileIOData; | 337 friend class ProfileIOData; |
| 324 | 338 |
| 325 void EnsureInitialized(); | |
| 326 | |
| 327 ProfileIOData* const io_data_; | 339 ProfileIOData* const io_data_; |
| 328 | 340 |
| 329 net::HostResolver* host_resolver_; | 341 net::HostResolver* host_resolver_; |
| 330 net::URLRequestContext* request_context_; | 342 net::URLRequestContext* request_context_; |
| 331 }; | 343 }; |
| 332 | 344 |
| 333 typedef std::map<StoragePartitionDescriptor, | 345 typedef std::map<StoragePartitionDescriptor, |
| 334 ChromeURLRequestContext*, | 346 ChromeURLRequestContext*, |
| 335 StoragePartitionDescriptorLess> | 347 StoragePartitionDescriptorLess> |
| 336 URLRequestContextMap; | 348 URLRequestContextMap; |
| 337 | 349 |
| 338 // -------------------------------------------- | 350 // -------------------------------------------- |
| 339 // Virtual interface for subtypes to implement: | 351 // Virtual interface for subtypes to implement: |
| 340 // -------------------------------------------- | 352 // -------------------------------------------- |
| 341 | 353 |
| 342 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 354 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
| 343 // should use the static helper functions above to implement this. | 355 // should use the static helper functions above to implement this. |
| 344 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; | 356 virtual void InitializeInternal( |
| 357 ProfileParams* profile_params, | |
| 358 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 359 blob_protocol_handler, | |
| 360 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 361 file_system_protocol_handler, | |
| 362 scoped_ptr<net::URLRequestJobFactory::Interceptor> | |
| 363 developer_protocol_handler) const = 0; | |
| 345 | 364 |
| 346 // Initializes the RequestContext for extensions. | 365 // Initializes the RequestContext for extensions. |
| 347 virtual void InitializeExtensionsRequestContext( | 366 virtual void InitializeExtensionsRequestContext( |
| 348 ProfileParams* profile_params) const = 0; | 367 ProfileParams* profile_params) const = 0; |
| 349 // Does an on-demand initialization of a RequestContext for the given | 368 // Does an on-demand initialization of a RequestContext for the given |
| 350 // isolated app. | 369 // isolated app. |
| 351 virtual ChromeURLRequestContext* InitializeAppRequestContext( | 370 virtual ChromeURLRequestContext* InitializeAppRequestContext( |
| 352 ChromeURLRequestContext* main_context, | 371 ChromeURLRequestContext* main_context, |
| 353 const StoragePartitionDescriptor& details, | 372 const StoragePartitionDescriptor& details, |
| 354 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 373 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 355 protocol_handler_interceptor) const = 0; | 374 protocol_handler_interceptor, |
| 375 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 376 blob_protocol_handler, | |
| 377 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 378 file_system_protocol_handler, | |
| 379 scoped_ptr<net::URLRequestJobFactory::Interceptor> | |
| 380 developer_protocol_handler) const = 0; | |
| 356 | 381 |
| 357 // Does an on-demand initialization of a media RequestContext for the given | 382 // Does an on-demand initialization of a media RequestContext for the given |
| 358 // isolated app. | 383 // isolated app. |
| 359 virtual ChromeURLRequestContext* InitializeMediaRequestContext( | 384 virtual ChromeURLRequestContext* InitializeMediaRequestContext( |
| 360 ChromeURLRequestContext* original_context, | 385 ChromeURLRequestContext* original_context, |
| 361 const StoragePartitionDescriptor& details) const = 0; | 386 const StoragePartitionDescriptor& details) const = 0; |
| 362 | 387 |
| 363 // These functions are used to transfer ownership of the lazily initialized | 388 // These functions are used to transfer ownership of the lazily initialized |
| 364 // context from ProfileIOData to the URLRequestContextGetter. | 389 // context from ProfileIOData to the URLRequestContextGetter. |
| 365 virtual ChromeURLRequestContext* | 390 virtual ChromeURLRequestContext* |
| 366 AcquireMediaRequestContext() const = 0; | 391 AcquireMediaRequestContext() const = 0; |
| 367 virtual ChromeURLRequestContext* | 392 virtual ChromeURLRequestContext* |
| 368 AcquireIsolatedAppRequestContext( | 393 AcquireIsolatedAppRequestContext( |
| 369 ChromeURLRequestContext* main_context, | 394 ChromeURLRequestContext* main_context, |
| 370 const StoragePartitionDescriptor& partition_descriptor, | 395 const StoragePartitionDescriptor& partition_descriptor, |
| 371 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 396 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 372 protocol_handler_interceptor) const = 0; | 397 protocol_handler_interceptor, |
| 398 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 399 blob_protocol_handler, | |
| 400 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | |
| 401 file_system_protocol_handler, | |
| 402 scoped_ptr<net::URLRequestJobFactory::Interceptor> | |
| 403 developer_protocol_handler) const = 0; | |
| 373 virtual ChromeURLRequestContext* | 404 virtual ChromeURLRequestContext* |
| 374 AcquireIsolatedMediaRequestContext( | 405 AcquireIsolatedMediaRequestContext( |
| 375 ChromeURLRequestContext* app_context, | 406 ChromeURLRequestContext* app_context, |
| 376 const StoragePartitionDescriptor& partition_descriptor) const = 0; | 407 const StoragePartitionDescriptor& partition_descriptor) const = 0; |
| 377 | 408 |
| 378 // Returns the LoadTimeStats object to be used for this profile. | 409 // Returns the LoadTimeStats object to be used for this profile. |
| 379 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( | 410 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( |
| 380 IOThread::Globals* io_thread_globals) const = 0; | 411 IOThread::Globals* io_thread_globals) const = 0; |
| 381 | 412 |
| 382 // The order *DOES* matter for the majority of these member variables, so | 413 // The order *DOES* matter for the majority of these member variables, so |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 | 501 |
| 471 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 502 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
| 472 bool initialized_on_UI_thread_; | 503 bool initialized_on_UI_thread_; |
| 473 | 504 |
| 474 bool is_incognito_; | 505 bool is_incognito_; |
| 475 | 506 |
| 476 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 507 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
| 477 }; | 508 }; |
| 478 | 509 |
| 479 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 510 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
| OLD | NEW |