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

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

Powered by Google App Engine
This is Rietveld 408576698