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

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

Issue 10969017: Create a new URLRequestJobFactory for isolated request contexts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fixes. Created 8 years, 3 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; 75 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const;
76 76
77 // These should only be called at most once each. Ownership is reversed when 77 // These should only be called at most once each. Ownership is reversed when
78 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice 78 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice
79 // versa. 79 // versa.
80 ChromeURLRequestContext* GetMainRequestContext() const; 80 ChromeURLRequestContext* GetMainRequestContext() const;
81 ChromeURLRequestContext* GetMediaRequestContext() const; 81 ChromeURLRequestContext* GetMediaRequestContext() const;
82 ChromeURLRequestContext* GetExtensionsRequestContext() const; 82 ChromeURLRequestContext* GetExtensionsRequestContext() const;
83 ChromeURLRequestContext* GetIsolatedAppRequestContext( 83 ChromeURLRequestContext* GetIsolatedAppRequestContext(
84 ChromeURLRequestContext* main_context, 84 ChromeURLRequestContext* main_context,
85 const std::string& app_id) const; 85 const std::string& app_id,
86 scoped_ptr<net::URLRequestJobFactory::Interceptor>
87 protocol_handler_interceptor) const;
86 ChromeURLRequestContext* GetIsolatedMediaRequestContext( 88 ChromeURLRequestContext* GetIsolatedMediaRequestContext(
87 ChromeURLRequestContext* media_context, 89 ChromeURLRequestContext* app_context,
88 const std::string& app_id) const; 90 const std::string& app_id) const;
89 91
90 // These are useful when the Chrome layer is called from the content layer 92 // These are useful when the Chrome layer is called from the content layer
91 // with a content::ResourceContext, and they want access to Chrome data for 93 // with a content::ResourceContext, and they want access to Chrome data for
92 // that profile. 94 // that profile.
93 ExtensionInfoMap* GetExtensionInfoMap() const; 95 ExtensionInfoMap* GetExtensionInfoMap() const;
94 CookieSettings* GetCookieSettings() const; 96 CookieSettings* GetCookieSettings() const;
95 97
96 #if defined(ENABLE_NOTIFICATIONS) 98 #if defined(ENABLE_NOTIFICATIONS)
97 DesktopNotificationService* GetNotificationService() const; 99 DesktopNotificationService* GetNotificationService() const;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 bool GetMetricsEnabledStateOnIOThread() const; 141 bool GetMetricsEnabledStateOnIOThread() const;
140 142
141 protected: 143 protected:
142 // A URLRequestContext for media that owns its HTTP factory, to ensure 144 // A URLRequestContext for media that owns its HTTP factory, to ensure
143 // it is deleted. 145 // it is deleted.
144 class MediaRequestContext : public ChromeURLRequestContext { 146 class MediaRequestContext : public ChromeURLRequestContext {
145 public: 147 public:
146 explicit MediaRequestContext( 148 explicit MediaRequestContext(
147 chrome_browser_net::LoadTimeStats* load_time_stats); 149 chrome_browser_net::LoadTimeStats* load_time_stats);
148 150
149 void SetHttpTransactionFactory(net::HttpTransactionFactory* http_factory); 151 void SetHttpTransactionFactory(
152 scoped_ptr<net::HttpTransactionFactory> http_factory);
150 153
151 private: 154 private:
152 virtual ~MediaRequestContext(); 155 virtual ~MediaRequestContext();
153 156
154 scoped_ptr<net::HttpTransactionFactory> http_factory_; 157 scoped_ptr<net::HttpTransactionFactory> http_factory_;
155 }; 158 };
156 159
157 // A URLRequestContext for apps that owns its cookie store and HTTP factory, 160 // A URLRequestContext for apps that owns its cookie store and HTTP factory,
158 // to ensure they are deleted. 161 // to ensure they are deleted.
159 class AppRequestContext : public ChromeURLRequestContext { 162 class AppRequestContext : public ChromeURLRequestContext {
160 public: 163 public:
161 explicit AppRequestContext( 164 explicit AppRequestContext(
162 chrome_browser_net::LoadTimeStats* load_time_stats); 165 chrome_browser_net::LoadTimeStats* load_time_stats);
163 166
164 void SetCookieStore(net::CookieStore* cookie_store); 167 void SetCookieStore(net::CookieStore* cookie_store);
165 void SetHttpTransactionFactory(net::HttpTransactionFactory* http_factory); 168 void SetHttpTransactionFactory(
169 scoped_ptr<net::HttpTransactionFactory> http_factory);
170 void SetJobFactory(scoped_ptr<net::URLRequestJobFactory> job_factory);
166 171
167 private: 172 private:
168 virtual ~AppRequestContext(); 173 virtual ~AppRequestContext();
169 174
170 scoped_refptr<net::CookieStore> cookie_store_; 175 scoped_refptr<net::CookieStore> cookie_store_;
171 scoped_ptr<net::HttpTransactionFactory> http_factory_; 176 scoped_ptr<net::HttpTransactionFactory> http_factory_;
177 scoped_ptr<net::URLRequestJobFactory> job_factory_;
172 }; 178 };
173 179
174 // Created on the UI thread, read on the IO thread during ProfileIOData lazy 180 // Created on the UI thread, read on the IO thread during ProfileIOData lazy
175 // initialization. 181 // initialization.
176 struct ProfileParams { 182 struct ProfileParams {
177 ProfileParams(); 183 ProfileParams();
178 ~ProfileParams(); 184 ~ProfileParams();
179 185
180 FilePath path; 186 FilePath path;
181 std::string accept_language; 187 std::string accept_language;
182 std::string accept_charset; 188 std::string accept_charset;
183 std::string referrer_charset; 189 std::string referrer_charset;
184 IOThread* io_thread; 190 IOThread* io_thread;
185 scoped_refptr<CookieSettings> cookie_settings; 191 scoped_refptr<CookieSettings> cookie_settings;
186 scoped_refptr<net::SSLConfigService> ssl_config_service; 192 scoped_refptr<net::SSLConfigService> ssl_config_service;
187 scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate; 193 scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate;
188 scoped_refptr<ExtensionInfoMap> extension_info_map; 194 scoped_refptr<ExtensionInfoMap> extension_info_map;
189 scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> 195 scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
190 resource_prefetch_predictor_observer_; 196 resource_prefetch_predictor_observer_;
191 197
192 #if defined(ENABLE_NOTIFICATIONS) 198 #if defined(ENABLE_NOTIFICATIONS)
193 DesktopNotificationService* notification_service; 199 DesktopNotificationService* notification_service;
194 #endif 200 #endif
195 201
196 // This pointer exists only as a means of conveying a url interceptor 202 // This pointer exists only as a means of conveying a url interceptor
197 // pointer from the protocol handler registry on the UI thread to the 203 // pointer from the protocol handler registry on the UI thread to the
198 // the URLRequestJobFactory on the IO thread. The consumer MUST take 204 // the URLRequestJobFactory on the IO thread. The consumer MUST take
199 // ownership of the object by calling release() on this pointer. 205 // ownership of the object by calling release() on this pointer.
200 scoped_ptr<net::URLRequestJobFactory::Interceptor> 206 scoped_ptr<net::URLRequestJobFactory::Interceptor>
201 protocol_handler_url_interceptor; 207 protocol_handler_interceptor;
202 208
203 // We need to initialize the ProxyConfigService from the UI thread 209 // We need to initialize the ProxyConfigService from the UI thread
204 // because on linux it relies on initializing things through gconf, 210 // because on linux it relies on initializing things through gconf,
205 // and needs to be on the main thread. 211 // and needs to be on the main thread.
206 scoped_ptr<net::ProxyConfigService> proxy_config_service; 212 scoped_ptr<net::ProxyConfigService> proxy_config_service;
207 // The profile this struct was populated from. It's passed as a void* to 213 // The profile this struct was populated from. It's passed as a void* to
208 // ensure it's not accidently used on the IO thread. Before using it on the 214 // ensure it's not accidently used on the IO thread. Before using it on the
209 // UI thread, call ProfileManager::IsValidProfile to ensure it's alive. 215 // UI thread, call ProfileManager::IsValidProfile to ensure it's alive.
210 void* profile; 216 void* profile;
211 }; 217 };
212 218
213 explicit ProfileIOData(bool is_incognito); 219 explicit ProfileIOData(bool is_incognito);
214 220
215 static std::string GetSSLSessionCacheShard(); 221 static std::string GetSSLSessionCacheShard();
216 222
217 void InitializeOnUIThread(Profile* profile); 223 void InitializeOnUIThread(Profile* profile);
218 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const; 224 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const;
219 225
220 void SetUpJobFactoryDefaults(net::URLRequestJobFactory* job_factory) const; 226 void SetUpJobFactoryDefaults(
227 net::URLRequestJobFactory* job_factory,
228 scoped_ptr<net::URLRequestJobFactory::Interceptor>
229 protocol_handler_interceptor,
230 net::NetworkDelegate* network_delegate,
231 net::FtpTransactionFactory* ftp_transaction_factory,
232 net::FtpAuthCache* ftp_auth_cache) const;
221 233
222 // Lazy initializes the ProfileIOData object the first time a request context 234 // Lazy initializes the ProfileIOData object the first time a request context
223 // is requested. The lazy logic is implemented here. The actual initialization 235 // is requested. The lazy logic is implemented here. The actual initialization
224 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper 236 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper
225 // functions have been provided to assist in common operations. 237 // functions have been provided to assist in common operations.
226 void LazyInitialize() const; 238 void LazyInitialize() const;
227 239
228 // Called when the profile is destroyed. 240 // Called when the profile is destroyed.
229 void ShutdownOnUIThread(); 241 void ShutdownOnUIThread();
230 242
243 ExtensionInfoMap* extension_info_map() const {
244 return extension_info_map_;
245 }
Charlie Reis 2012/09/20 22:57:46 Remove.
awong 2012/09/20 23:16:46 Done.
246
231 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const { 247 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const {
232 return chrome_url_data_manager_backend_.get(); 248 return chrome_url_data_manager_backend_.get();
233 } 249 }
234 250
235 // A ServerBoundCertService object is created by a derived class of 251 // A ServerBoundCertService object is created by a derived class of
236 // ProfileIOData, and the derived class calls this method to set the 252 // ProfileIOData, and the derived class calls this method to set the
237 // server_bound_cert_service_ member and transfers ownership to the base 253 // server_bound_cert_service_ member and transfers ownership to the base
238 // class. 254 // class.
239 void set_server_bound_cert_service( 255 void set_server_bound_cert_service(
240 net::ServerBoundCertService* server_bound_cert_service) const; 256 net::ServerBoundCertService* server_bound_cert_service) const;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // -------------------------------------------- 318 // --------------------------------------------
303 319
304 // Does the actual initialization of the ProfileIOData subtype. Subtypes 320 // Does the actual initialization of the ProfileIOData subtype. Subtypes
305 // should use the static helper functions above to implement this. 321 // should use the static helper functions above to implement this.
306 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; 322 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0;
307 323
308 // Does an on-demand initialization of a RequestContext for the given 324 // Does an on-demand initialization of a RequestContext for the given
309 // isolated app. 325 // isolated app.
310 virtual ChromeURLRequestContext* InitializeAppRequestContext( 326 virtual ChromeURLRequestContext* InitializeAppRequestContext(
311 ChromeURLRequestContext* main_context, 327 ChromeURLRequestContext* main_context,
312 const std::string& app_id) const = 0; 328 const std::string& app_id,
329 scoped_ptr<net::URLRequestJobFactory::Interceptor>
330 protocol_handler_interceptor) const = 0;
313 331
314 // Does an on-demand initialization of a media RequestContext for the given 332 // Does an on-demand initialization of a media RequestContext for the given
315 // isolated app. 333 // isolated app.
316 virtual ChromeURLRequestContext* InitializeMediaRequestContext( 334 virtual ChromeURLRequestContext* InitializeMediaRequestContext(
317 ChromeURLRequestContext* original_context, 335 ChromeURLRequestContext* original_context,
318 const std::string& app_id) const = 0; 336 const std::string& app_id) const = 0;
319 337
320 // These functions are used to transfer ownership of the lazily initialized 338 // These functions are used to transfer ownership of the lazily initialized
321 // context from ProfileIOData to the URLRequestContextGetter. 339 // context from ProfileIOData to the URLRequestContextGetter.
322 virtual ChromeURLRequestContext* 340 virtual ChromeURLRequestContext*
323 AcquireMediaRequestContext() const = 0; 341 AcquireMediaRequestContext() const = 0;
324 virtual ChromeURLRequestContext* 342 virtual ChromeURLRequestContext*
325 AcquireIsolatedAppRequestContext( 343 AcquireIsolatedAppRequestContext(
326 ChromeURLRequestContext* main_context, 344 ChromeURLRequestContext* main_context,
327 const std::string& app_id) const = 0; 345 const std::string& app_id,
346 scoped_ptr<net::URLRequestJobFactory::Interceptor>
347 protocol_handler_interceptor) const = 0;
328 virtual ChromeURLRequestContext* 348 virtual ChromeURLRequestContext*
329 AcquireIsolatedMediaRequestContext( 349 AcquireIsolatedMediaRequestContext(
330 ChromeURLRequestContext* app_context, 350 ChromeURLRequestContext* app_context,
331 const std::string& app_id) const = 0; 351 const std::string& app_id) const = 0;
332 352
333 // Returns the LoadTimeStats object to be used for this profile. 353 // Returns the LoadTimeStats object to be used for this profile.
334 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( 354 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats(
335 IOThread::Globals* io_thread_globals) const = 0; 355 IOThread::Globals* io_thread_globals) const = 0;
336 356
337 // The order *DOES* matter for the majority of these member variables, so 357 // The order *DOES* matter for the majority of these member variables, so
(...skipping 30 matching lines...) Expand all
368 #if defined(OS_CHROMEOS) 388 #if defined(OS_CHROMEOS)
369 bool enable_metrics_; 389 bool enable_metrics_;
370 #else 390 #else
371 BooleanPrefMember enable_metrics_; 391 BooleanPrefMember enable_metrics_;
372 #endif 392 #endif
373 393
374 // Pointed to by NetworkDelegate. 394 // Pointed to by NetworkDelegate.
375 mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_; 395 mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_;
376 396
377 // Pointed to by URLRequestContext. 397 // Pointed to by URLRequestContext.
398 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_;
378 mutable scoped_ptr<ChromeURLDataManagerBackend> 399 mutable scoped_ptr<ChromeURLDataManagerBackend>
379 chrome_url_data_manager_backend_; 400 chrome_url_data_manager_backend_;
380 mutable scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_; 401 mutable scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_;
381 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; 402 mutable scoped_ptr<net::NetworkDelegate> network_delegate_;
382 mutable scoped_ptr<net::FraudulentCertificateReporter> 403 mutable scoped_ptr<net::FraudulentCertificateReporter>
383 fraudulent_certificate_reporter_; 404 fraudulent_certificate_reporter_;
384 mutable scoped_ptr<net::ProxyService> proxy_service_; 405 mutable scoped_ptr<net::ProxyService> proxy_service_;
385 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_; 406 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_;
386 mutable scoped_ptr<chrome_browser_net::HttpServerPropertiesManager> 407 mutable scoped_ptr<chrome_browser_net::HttpServerPropertiesManager>
387 http_server_properties_manager_; 408 http_server_properties_manager_;
388 409
389 #if defined(ENABLE_NOTIFICATIONS) 410 #if defined(ENABLE_NOTIFICATIONS)
390 mutable DesktopNotificationService* notification_service_; 411 mutable DesktopNotificationService* notification_service_;
391 #endif 412 #endif
392 413
393 mutable scoped_ptr<TransportSecurityPersister> 414 mutable scoped_ptr<TransportSecurityPersister>
394 transport_security_persister_; 415 transport_security_persister_;
395 416
396 // These are only valid in between LazyInitialize() and their accessor being 417 // These are only valid in between LazyInitialize() and their accessor being
397 // called. 418 // called.
398 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; 419 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_;
399 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; 420 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_;
400 // One URLRequestContext per isolated app for main and media requests. 421 // One URLRequestContext per isolated app for main and media requests.
401 mutable URLRequestContextMap app_request_context_map_; 422 mutable URLRequestContextMap app_request_context_map_;
402 mutable URLRequestContextMap isolated_media_request_context_map_; 423 mutable URLRequestContextMap isolated_media_request_context_map_;
403 424
404 mutable scoped_ptr<ResourceContext> resource_context_; 425 mutable scoped_ptr<ResourceContext> resource_context_;
405 426
406 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_;
407 mutable scoped_refptr<CookieSettings> cookie_settings_; 427 mutable scoped_refptr<CookieSettings> cookie_settings_;
408 428
409 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> 429 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
410 resource_prefetch_predictor_observer_; 430 resource_prefetch_predictor_observer_;
411 431
412 mutable chrome_browser_net::LoadTimeStats* load_time_stats_; 432 mutable chrome_browser_net::LoadTimeStats* load_time_stats_;
413 433
414 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 434 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
415 bool initialized_on_UI_thread_; 435 bool initialized_on_UI_thread_;
416 436
417 bool is_incognito_; 437 bool is_incognito_;
418 438
419 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 439 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
420 }; 440 };
421 441
422 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 442 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698