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