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