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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 // -------------------------------------------- | 314 // -------------------------------------------- |
303 | 315 |
304 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 316 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
305 // should use the static helper functions above to implement this. | 317 // should use the static helper functions above to implement this. |
306 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; | 318 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; |
307 | 319 |
308 // Does an on-demand initialization of a RequestContext for the given | 320 // Does an on-demand initialization of a RequestContext for the given |
309 // isolated app. | 321 // isolated app. |
310 virtual ChromeURLRequestContext* InitializeAppRequestContext( | 322 virtual ChromeURLRequestContext* InitializeAppRequestContext( |
311 ChromeURLRequestContext* main_context, | 323 ChromeURLRequestContext* main_context, |
312 const std::string& app_id) const = 0; | 324 const std::string& app_id, |
325 scoped_ptr<net::URLRequestJobFactory::Interceptor> | |
326 protocol_handler_interceptor) const = 0; | |
313 | 327 |
314 // Does an on-demand initialization of a media RequestContext for the given | 328 // Does an on-demand initialization of a media RequestContext for the given |
315 // isolated app. | 329 // isolated app. |
316 virtual ChromeURLRequestContext* InitializeMediaRequestContext( | 330 virtual ChromeURLRequestContext* InitializeMediaRequestContext( |
317 ChromeURLRequestContext* original_context, | 331 ChromeURLRequestContext* original_context, |
318 const std::string& app_id) const = 0; | 332 const std::string& app_id) const = 0; |
319 | 333 |
320 // These functions are used to transfer ownership of the lazily initialized | 334 // These functions are used to transfer ownership of the lazily initialized |
321 // context from ProfileIOData to the URLRequestContextGetter. | 335 // context from ProfileIOData to the URLRequestContextGetter. |
322 virtual ChromeURLRequestContext* | 336 virtual ChromeURLRequestContext* |
323 AcquireMediaRequestContext() const = 0; | 337 AcquireMediaRequestContext() const = 0; |
324 virtual ChromeURLRequestContext* | 338 virtual ChromeURLRequestContext* |
325 AcquireIsolatedAppRequestContext( | 339 AcquireIsolatedAppRequestContext( |
326 ChromeURLRequestContext* main_context, | 340 ChromeURLRequestContext* main_context, |
327 const std::string& app_id) const = 0; | 341 const std::string& app_id, |
342 scoped_ptr<net::URLRequestJobFactory::Interceptor> | |
343 protocol_handler_interceptor) const = 0; | |
328 virtual ChromeURLRequestContext* | 344 virtual ChromeURLRequestContext* |
329 AcquireIsolatedMediaRequestContext( | 345 AcquireIsolatedMediaRequestContext( |
330 ChromeURLRequestContext* app_context, | 346 ChromeURLRequestContext* app_context, |
331 const std::string& app_id) const = 0; | 347 const std::string& app_id) const = 0; |
332 | 348 |
333 // Returns the LoadTimeStats object to be used for this profile. | 349 // Returns the LoadTimeStats object to be used for this profile. |
334 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( | 350 virtual chrome_browser_net::LoadTimeStats* GetLoadTimeStats( |
335 IOThread::Globals* io_thread_globals) const = 0; | 351 IOThread::Globals* io_thread_globals) const = 0; |
336 | 352 |
337 // The order *DOES* matter for the majority of these member variables, so | 353 // The order *DOES* matter for the majority of these member variables, so |
(...skipping 30 matching lines...) Expand all Loading... | |
368 #if defined(OS_CHROMEOS) | 384 #if defined(OS_CHROMEOS) |
369 bool enable_metrics_; | 385 bool enable_metrics_; |
370 #else | 386 #else |
371 BooleanPrefMember enable_metrics_; | 387 BooleanPrefMember enable_metrics_; |
372 #endif | 388 #endif |
373 | 389 |
374 // Pointed to by NetworkDelegate. | 390 // Pointed to by NetworkDelegate. |
375 mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_; | 391 mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_; |
376 | 392 |
377 // Pointed to by URLRequestContext. | 393 // Pointed to by URLRequestContext. |
394 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_; | |
willchan no longer on Chromium
2012/09/20 23:48:37
Why did this move?
awong
2012/09/20 23:49:57
Cause it's pointed to URLRequestContext.
I can mo
| |
378 mutable scoped_ptr<ChromeURLDataManagerBackend> | 395 mutable scoped_ptr<ChromeURLDataManagerBackend> |
379 chrome_url_data_manager_backend_; | 396 chrome_url_data_manager_backend_; |
380 mutable scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_; | 397 mutable scoped_ptr<net::ServerBoundCertService> server_bound_cert_service_; |
381 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; | 398 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; |
382 mutable scoped_ptr<net::FraudulentCertificateReporter> | 399 mutable scoped_ptr<net::FraudulentCertificateReporter> |
383 fraudulent_certificate_reporter_; | 400 fraudulent_certificate_reporter_; |
384 mutable scoped_ptr<net::ProxyService> proxy_service_; | 401 mutable scoped_ptr<net::ProxyService> proxy_service_; |
385 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_; | 402 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_; |
386 mutable scoped_ptr<chrome_browser_net::HttpServerPropertiesManager> | 403 mutable scoped_ptr<chrome_browser_net::HttpServerPropertiesManager> |
387 http_server_properties_manager_; | 404 http_server_properties_manager_; |
388 | 405 |
389 #if defined(ENABLE_NOTIFICATIONS) | 406 #if defined(ENABLE_NOTIFICATIONS) |
390 mutable DesktopNotificationService* notification_service_; | 407 mutable DesktopNotificationService* notification_service_; |
391 #endif | 408 #endif |
392 | 409 |
393 mutable scoped_ptr<TransportSecurityPersister> | 410 mutable scoped_ptr<TransportSecurityPersister> |
394 transport_security_persister_; | 411 transport_security_persister_; |
395 | 412 |
396 // These are only valid in between LazyInitialize() and their accessor being | 413 // These are only valid in between LazyInitialize() and their accessor being |
397 // called. | 414 // called. |
398 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; | 415 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; |
399 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; | 416 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; |
400 // One URLRequestContext per isolated app for main and media requests. | 417 // One URLRequestContext per isolated app for main and media requests. |
401 mutable URLRequestContextMap app_request_context_map_; | 418 mutable URLRequestContextMap app_request_context_map_; |
402 mutable URLRequestContextMap isolated_media_request_context_map_; | 419 mutable URLRequestContextMap isolated_media_request_context_map_; |
403 | 420 |
404 mutable scoped_ptr<ResourceContext> resource_context_; | 421 mutable scoped_ptr<ResourceContext> resource_context_; |
405 | 422 |
406 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_; | |
407 mutable scoped_refptr<CookieSettings> cookie_settings_; | 423 mutable scoped_refptr<CookieSettings> cookie_settings_; |
408 | 424 |
409 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> | 425 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> |
410 resource_prefetch_predictor_observer_; | 426 resource_prefetch_predictor_observer_; |
411 | 427 |
412 mutable chrome_browser_net::LoadTimeStats* load_time_stats_; | 428 mutable chrome_browser_net::LoadTimeStats* load_time_stats_; |
413 | 429 |
414 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 430 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
415 bool initialized_on_UI_thread_; | 431 bool initialized_on_UI_thread_; |
416 | 432 |
417 bool is_incognito_; | 433 bool is_incognito_; |
418 | 434 |
419 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 435 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
420 }; | 436 }; |
421 | 437 |
422 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 438 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
OLD | NEW |