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

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

Powered by Google App Engine
This is Rietveld 408576698