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

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

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address mmenke's comments Created 7 years, 11 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 | Annotate | Revision Log
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 <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
73 static bool IsHandledProtocol(const std::string& scheme); 73 static bool IsHandledProtocol(const std::string& scheme);
74 74
75 // Returns true if |url| is handled in Chrome, or by default handlers in 75 // Returns true if |url| is handled in Chrome, or by default handlers in
76 // net::URLRequest. 76 // net::URLRequest.
77 static bool IsHandledURL(const GURL& url); 77 static bool IsHandledURL(const GURL& url);
78 78
79 // Called by Profile. 79 // Called by Profile.
80 content::ResourceContext* GetResourceContext() const; 80 content::ResourceContext* GetResourceContext() const;
81 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; 81 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() 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::Interceptor>
92 developer_protocol_handler) const;
93
86 ChromeURLRequestContext* GetMainRequestContext() const; 94 ChromeURLRequestContext* GetMainRequestContext() const;
87 ChromeURLRequestContext* GetMediaRequestContext() const; 95 ChromeURLRequestContext* GetMediaRequestContext() const;
88 ChromeURLRequestContext* GetExtensionsRequestContext() const; 96 ChromeURLRequestContext* GetExtensionsRequestContext() const;
89 ChromeURLRequestContext* GetIsolatedAppRequestContext( 97 ChromeURLRequestContext* GetIsolatedAppRequestContext(
90 ChromeURLRequestContext* main_context, 98 ChromeURLRequestContext* main_context,
91 const StoragePartitionDescriptor& partition_descriptor, 99 const StoragePartitionDescriptor& partition_descriptor,
92 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 100 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
93 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;
94 ChromeURLRequestContext* GetIsolatedMediaRequestContext( 108 ChromeURLRequestContext* GetIsolatedMediaRequestContext(
95 ChromeURLRequestContext* app_context, 109 ChromeURLRequestContext* app_context,
96 const StoragePartitionDescriptor& partition_descriptor) const; 110 const StoragePartitionDescriptor& partition_descriptor) const;
97 111
98 // 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
99 // 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
100 // that profile. 114 // that profile.
101 ExtensionInfoMap* GetExtensionInfoMap() const; 115 ExtensionInfoMap* GetExtensionInfoMap() const;
102 CookieSettings* GetCookieSettings() const; 116 CookieSettings* GetCookieSettings() const;
103 117
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; 262 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const;
249 263
250 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( 264 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
251 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, 265 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory,
252 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 266 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
253 protocol_handler_interceptor, 267 protocol_handler_interceptor,
254 net::NetworkDelegate* network_delegate, 268 net::NetworkDelegate* network_delegate,
255 net::FtpTransactionFactory* ftp_transaction_factory, 269 net::FtpTransactionFactory* ftp_transaction_factory,
256 net::FtpAuthCache* ftp_auth_cache) const; 270 net::FtpAuthCache* ftp_auth_cache) const;
257 271
258 // Lazy initializes the ProfileIOData object the first time a request context
259 // is requested. The lazy logic is implemented here. The actual initialization
260 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper
261 // functions have been provided to assist in common operations.
262 void LazyInitialize() const;
263
264 // Called when the profile is destroyed. 272 // Called when the profile is destroyed.
265 void ShutdownOnUIThread(); 273 void ShutdownOnUIThread();
266 274
267 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const { 275 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const {
268 return chrome_url_data_manager_backend_.get(); 276 return chrome_url_data_manager_backend_.get();
269 } 277 }
270 278
271 // A ServerBoundCertService object is created by a derived class of 279 // A ServerBoundCertService object is created by a derived class of
272 // ProfileIOData, and the derived class calls this method to set the 280 // ProfileIOData, and the derived class calls this method to set the
273 // server_bound_cert_service_ member and transfers ownership to the base 281 // server_bound_cert_service_ member and transfers ownership to the base
(...skipping 19 matching lines...) Expand all
293 net::HttpServerProperties* http_server_properties) const; 301 net::HttpServerProperties* http_server_properties) const;
294 302
295 ChromeURLRequestContext* main_request_context() const { 303 ChromeURLRequestContext* main_request_context() const {
296 return main_request_context_.get(); 304 return main_request_context_.get();
297 } 305 }
298 306
299 chrome_browser_net::LoadTimeStats* load_time_stats() const { 307 chrome_browser_net::LoadTimeStats* load_time_stats() const {
300 return load_time_stats_; 308 return load_time_stats_;
301 } 309 }
302 310
311 bool initialized() const {
312 return initialized_;
313 }
314
303 // Destroys the ResourceContext first, to cancel any URLRequests that are 315 // Destroys the ResourceContext first, to cancel any URLRequests that are
304 // using it still, before we destroy the member variables that those 316 // using it still, before we destroy the member variables that those
305 // URLRequests may be accessing. 317 // URLRequests may be accessing.
306 void DestroyResourceContext(); 318 void DestroyResourceContext();
307 319
308 // Fills in fields of params using values from main_request_context_ and the 320 // Fills in fields of params using values from main_request_context_ and the
309 // IOThread associated with profile_params. 321 // IOThread associated with profile_params.
310 void PopulateNetworkSessionParams( 322 void PopulateNetworkSessionParams(
311 const ProfileParams* profile_params, 323 const ProfileParams* profile_params,
312 net::HttpNetworkSession::Params* params) const; 324 net::HttpNetworkSession::Params* params) const;
313 325
314 void SetCookieSettingsForTesting(CookieSettings* cookie_settings); 326 void SetCookieSettingsForTesting(CookieSettings* cookie_settings);
315 327
316 void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names); 328 void set_signin_names_for_testing(SigninNamesOnIOThread* signin_names);
317 329
318 private: 330 private:
319 class ResourceContext : public content::ResourceContext { 331 class ResourceContext : public content::ResourceContext {
320 public: 332 public:
321 explicit ResourceContext(ProfileIOData* io_data); 333 explicit ResourceContext(ProfileIOData* io_data);
322 virtual ~ResourceContext(); 334 virtual ~ResourceContext();
323 335
324 // ResourceContext implementation: 336 // ResourceContext implementation:
325 virtual net::HostResolver* GetHostResolver() OVERRIDE; 337 virtual net::HostResolver* GetHostResolver() OVERRIDE;
326 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; 338 virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
327 339
328 private: 340 private:
329 friend class ProfileIOData; 341 friend class ProfileIOData;
330 342
331 void EnsureInitialized();
332
333 ProfileIOData* const io_data_; 343 ProfileIOData* const io_data_;
334 344
335 net::HostResolver* host_resolver_; 345 net::HostResolver* host_resolver_;
336 net::URLRequestContext* request_context_; 346 net::URLRequestContext* request_context_;
337 }; 347 };
338 348
339 typedef std::map<StoragePartitionDescriptor, 349 typedef std::map<StoragePartitionDescriptor,
340 ChromeURLRequestContext*, 350 ChromeURLRequestContext*,
341 StoragePartitionDescriptorLess> 351 StoragePartitionDescriptorLess>
342 URLRequestContextMap; 352 URLRequestContextMap;
343 353
344 // -------------------------------------------- 354 // --------------------------------------------
345 // Virtual interface for subtypes to implement: 355 // Virtual interface for subtypes to implement:
346 // -------------------------------------------- 356 // --------------------------------------------
347 357
348 // Does the actual initialization of the ProfileIOData subtype. Subtypes 358 // Does the actual initialization of the ProfileIOData subtype. Subtypes
349 // should use the static helper functions above to implement this. 359 // should use the static helper functions above to implement this.
350 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; 360 virtual void InitializeInternal(
361 ProfileParams* profile_params,
362 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
363 blob_protocol_handler,
364 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
365 file_system_protocol_handler,
366 scoped_ptr<net::URLRequestJobFactory::Interceptor>
367 developer_protocol_handler) const = 0;
351 368
352 // Initializes the RequestContext for extensions. 369 // Initializes the RequestContext for extensions.
353 virtual void InitializeExtensionsRequestContext( 370 virtual void InitializeExtensionsRequestContext(
354 ProfileParams* profile_params) const = 0; 371 ProfileParams* profile_params) const = 0;
355 // Does an on-demand initialization of a RequestContext for the given 372 // Does an on-demand initialization of a RequestContext for the given
356 // isolated app. 373 // isolated app.
357 virtual ChromeURLRequestContext* InitializeAppRequestContext( 374 virtual ChromeURLRequestContext* InitializeAppRequestContext(
358 ChromeURLRequestContext* main_context, 375 ChromeURLRequestContext* main_context,
359 const StoragePartitionDescriptor& details, 376 const StoragePartitionDescriptor& details,
360 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 377 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
361 protocol_handler_interceptor) const = 0; 378 protocol_handler_interceptor,
379 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
380 blob_protocol_handler,
381 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
382 file_system_protocol_handler,
383 scoped_ptr<net::URLRequestJobFactory::Interceptor>
384 developer_protocol_handler) const = 0;
362 385
363 // Does an on-demand initialization of a media RequestContext for the given 386 // Does an on-demand initialization of a media RequestContext for the given
364 // isolated app. 387 // isolated app.
365 virtual ChromeURLRequestContext* InitializeMediaRequestContext( 388 virtual ChromeURLRequestContext* InitializeMediaRequestContext(
366 ChromeURLRequestContext* original_context, 389 ChromeURLRequestContext* original_context,
367 const StoragePartitionDescriptor& details) const = 0; 390 const StoragePartitionDescriptor& details) const = 0;
368 391
369 // These functions are used to transfer ownership of the lazily initialized 392 // These functions are used to transfer ownership of the lazily initialized
370 // context from ProfileIOData to the URLRequestContextGetter. 393 // context from ProfileIOData to the URLRequestContextGetter.
371 virtual ChromeURLRequestContext* 394 virtual ChromeURLRequestContext*
372 AcquireMediaRequestContext() const = 0; 395 AcquireMediaRequestContext() const = 0;
373 virtual ChromeURLRequestContext* 396 virtual ChromeURLRequestContext*
374 AcquireIsolatedAppRequestContext( 397 AcquireIsolatedAppRequestContext(
375 ChromeURLRequestContext* main_context, 398 ChromeURLRequestContext* main_context,
376 const StoragePartitionDescriptor& partition_descriptor, 399 const StoragePartitionDescriptor& partition_descriptor,
377 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 400 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
378 protocol_handler_interceptor) const = 0; 401 protocol_handler_interceptor,
402 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
403 blob_protocol_handler,
404 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
405 file_system_protocol_handler,
406 scoped_ptr<net::URLRequestJobFactory::Interceptor>
407 developer_protocol_handler) const = 0;
379 virtual ChromeURLRequestContext* 408 virtual ChromeURLRequestContext*
380 AcquireIsolatedMediaRequestContext( 409 AcquireIsolatedMediaRequestContext(
381 ChromeURLRequestContext* app_context, 410 ChromeURLRequestContext* app_context,
382 const StoragePartitionDescriptor& partition_descriptor) const = 0; 411 const StoragePartitionDescriptor& partition_descriptor) const = 0;
383 412
384 // Returns the LoadTimeStats object to be used for this profile. 413 // Returns the LoadTimeStats object to be used for this profile.
385 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( 414 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats(
386 IOThread::Globals* io_thread_globals) const = 0; 415 IOThread::Globals* io_thread_globals) const = 0;
387 416
388 // The order *DOES* matter for the majority of these member variables, so 417 // The order *DOES* matter for the majority of these member variables, so
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 506
478 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 507 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
479 bool initialized_on_UI_thread_; 508 bool initialized_on_UI_thread_;
480 509
481 bool is_incognito_; 510 bool is_incognito_;
482 511
483 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 512 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
484 }; 513 };
485 514
486 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 515 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698