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 | 75 |
76 // These should only be called at most once each. Ownership is reversed when | 76 // These should only be called at most once each. Ownership is reversed when |
77 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice | 77 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice |
78 // versa. | 78 // versa. |
79 ChromeURLRequestContext* GetMainRequestContext() const; | 79 ChromeURLRequestContext* GetMainRequestContext() const; |
80 ChromeURLRequestContext* GetMediaRequestContext() const; | 80 ChromeURLRequestContext* GetMediaRequestContext() const; |
81 ChromeURLRequestContext* GetExtensionsRequestContext() const; | 81 ChromeURLRequestContext* GetExtensionsRequestContext() const; |
82 ChromeURLRequestContext* GetIsolatedAppRequestContext( | 82 ChromeURLRequestContext* GetIsolatedAppRequestContext( |
83 ChromeURLRequestContext* main_context, | 83 ChromeURLRequestContext* main_context, |
84 const std::string& app_id) const; | 84 const std::string& app_id) const; |
| 85 ChromeURLRequestContext* GetIsolatedMediaRequestContext( |
| 86 ChromeURLRequestContext* media_context, |
| 87 const std::string& app_id) const; |
85 | 88 |
86 // These are useful when the Chrome layer is called from the content layer | 89 // These are useful when the Chrome layer is called from the content layer |
87 // with a content::ResourceContext, and they want access to Chrome data for | 90 // with a content::ResourceContext, and they want access to Chrome data for |
88 // that profile. | 91 // that profile. |
89 ExtensionInfoMap* GetExtensionInfoMap() const; | 92 ExtensionInfoMap* GetExtensionInfoMap() const; |
90 CookieSettings* GetCookieSettings() const; | 93 CookieSettings* GetCookieSettings() const; |
91 | 94 |
92 #if defined(ENABLE_NOTIFICATIONS) | 95 #if defined(ENABLE_NOTIFICATIONS) |
93 DesktopNotificationService* GetNotificationService() const; | 96 DesktopNotificationService* GetNotificationService() const; |
94 #endif | 97 #endif |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Initialize the member needed to track the metrics enabled state. This is | 131 // Initialize the member needed to track the metrics enabled state. This is |
129 // only to be called on the UI thread. | 132 // only to be called on the UI thread. |
130 void InitializeMetricsEnabledStateOnUIThread(); | 133 void InitializeMetricsEnabledStateOnUIThread(); |
131 | 134 |
132 // Returns whether or not metrics reporting is enabled in the browser instance | 135 // Returns whether or not metrics reporting is enabled in the browser instance |
133 // on which this profile resides. This is safe for use from the IO thread, and | 136 // on which this profile resides. This is safe for use from the IO thread, and |
134 // should only be called from there. | 137 // should only be called from there. |
135 bool GetMetricsEnabledStateOnIOThread() const; | 138 bool GetMetricsEnabledStateOnIOThread() const; |
136 | 139 |
137 protected: | 140 protected: |
| 141 // A URLRequestContext for media that owns its HTTP factory, to ensure |
| 142 // it is deleted. |
| 143 class MediaRequestContext : public ChromeURLRequestContext { |
| 144 public: |
| 145 explicit MediaRequestContext(chrome_browser_net::CacheStats* cache_stats); |
| 146 |
| 147 void SetHttpTransactionFactory(net::HttpTransactionFactory* http_factory); |
| 148 |
| 149 private: |
| 150 virtual ~MediaRequestContext(); |
| 151 |
| 152 scoped_ptr<net::HttpTransactionFactory> http_factory_; |
| 153 }; |
| 154 |
| 155 // A URLRequestContext for apps that owns its cookie store and HTTP factory, |
| 156 // to ensure they are deleted. |
138 class AppRequestContext : public ChromeURLRequestContext { | 157 class AppRequestContext : public ChromeURLRequestContext { |
139 public: | 158 public: |
140 explicit AppRequestContext(chrome_browser_net::CacheStats* cache_stats); | 159 explicit AppRequestContext(chrome_browser_net::CacheStats* cache_stats); |
141 | 160 |
142 void SetCookieStore(net::CookieStore* cookie_store); | 161 void SetCookieStore(net::CookieStore* cookie_store); |
143 void SetHttpTransactionFactory(net::HttpTransactionFactory* http_factory); | 162 void SetHttpTransactionFactory(net::HttpTransactionFactory* http_factory); |
144 | 163 |
145 private: | 164 private: |
146 virtual ~AppRequestContext(); | 165 virtual ~AppRequestContext(); |
147 | 166 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 283 |
265 void EnsureInitialized(); | 284 void EnsureInitialized(); |
266 | 285 |
267 ProfileIOData* const io_data_; | 286 ProfileIOData* const io_data_; |
268 | 287 |
269 net::HostResolver* host_resolver_; | 288 net::HostResolver* host_resolver_; |
270 net::URLRequestContext* request_context_; | 289 net::URLRequestContext* request_context_; |
271 }; | 290 }; |
272 | 291 |
273 typedef base::hash_map<std::string, ChromeURLRequestContext*> | 292 typedef base::hash_map<std::string, ChromeURLRequestContext*> |
274 AppRequestContextMap; | 293 URLRequestContextMap; |
275 | 294 |
276 // -------------------------------------------- | 295 // -------------------------------------------- |
277 // Virtual interface for subtypes to implement: | 296 // Virtual interface for subtypes to implement: |
278 // -------------------------------------------- | 297 // -------------------------------------------- |
279 | 298 |
280 // Does the actual initialization of the ProfileIOData subtype. Subtypes | 299 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
281 // should use the static helper functions above to implement this. | 300 // should use the static helper functions above to implement this. |
282 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; | 301 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; |
283 | 302 |
284 // Does an on-demand initialization of a RequestContext for the given | 303 // Does an on-demand initialization of a RequestContext for the given |
285 // isolated app. | 304 // isolated app. |
286 virtual ChromeURLRequestContext* InitializeAppRequestContext( | 305 virtual ChromeURLRequestContext* InitializeAppRequestContext( |
287 ChromeURLRequestContext* main_context, | 306 ChromeURLRequestContext* main_context, |
288 const std::string& app_id) const = 0; | 307 const std::string& app_id) const = 0; |
289 | 308 |
290 // These functions are used to transfer ownership of the lazily initialized | 309 // These functions are used to transfer ownership of the lazily initialized |
291 // context from ProfileIOData to the URLRequestContextGetter. | 310 // context from ProfileIOData to the URLRequestContextGetter. |
292 virtual ChromeURLRequestContext* | 311 virtual ChromeURLRequestContext* |
293 AcquireMediaRequestContext() const = 0; | 312 AcquireMediaRequestContext() const = 0; |
294 virtual ChromeURLRequestContext* | 313 virtual ChromeURLRequestContext* |
295 AcquireIsolatedAppRequestContext( | 314 AcquireIsolatedAppRequestContext( |
296 ChromeURLRequestContext* main_context, | 315 ChromeURLRequestContext* main_context, |
297 const std::string& app_id) const = 0; | 316 const std::string& app_id) const = 0; |
| 317 virtual ChromeURLRequestContext* |
| 318 AcquireIsolatedMediaRequestContext( |
| 319 ChromeURLRequestContext* app_context, |
| 320 const std::string& app_id) const = 0; |
298 | 321 |
299 // Returns the CacheStats object to be used for this profile. | 322 // Returns the CacheStats object to be used for this profile. |
300 virtual chrome_browser_net::CacheStats* GetCacheStats( | 323 virtual chrome_browser_net::CacheStats* GetCacheStats( |
301 IOThread::Globals* io_thread_globals) const = 0; | 324 IOThread::Globals* io_thread_globals) const = 0; |
302 | 325 |
303 // The order *DOES* matter for the majority of these member variables, so | 326 // The order *DOES* matter for the majority of these member variables, so |
304 // don't move them around unless you know what you're doing! | 327 // don't move them around unless you know what you're doing! |
305 // General rules: | 328 // General rules: |
306 // * ResourceContext references the URLRequestContexts, so | 329 // * ResourceContext references the URLRequestContexts, so |
307 // URLRequestContexts must outlive ResourceContext, hence ResourceContext | 330 // URLRequestContexts must outlive ResourceContext, hence ResourceContext |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 mutable DesktopNotificationService* notification_service_; | 378 mutable DesktopNotificationService* notification_service_; |
356 #endif | 379 #endif |
357 | 380 |
358 mutable scoped_ptr<TransportSecurityPersister> | 381 mutable scoped_ptr<TransportSecurityPersister> |
359 transport_security_persister_; | 382 transport_security_persister_; |
360 | 383 |
361 // These are only valid in between LazyInitialize() and their accessor being | 384 // These are only valid in between LazyInitialize() and their accessor being |
362 // called. | 385 // called. |
363 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; | 386 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; |
364 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; | 387 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; |
365 // One AppRequestContext per isolated app. | 388 // One URLRequestContext per isolated app for main and media requests. |
366 mutable AppRequestContextMap app_request_context_map_; | 389 mutable URLRequestContextMap app_request_context_map_; |
| 390 mutable URLRequestContextMap isolated_media_request_context_map_; |
367 | 391 |
368 mutable scoped_ptr<ResourceContext> resource_context_; | 392 mutable scoped_ptr<ResourceContext> resource_context_; |
369 | 393 |
370 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_; | 394 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_; |
371 mutable scoped_refptr<CookieSettings> cookie_settings_; | 395 mutable scoped_refptr<CookieSettings> cookie_settings_; |
372 | 396 |
373 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> | 397 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> |
374 resource_prefetch_predictor_observer_; | 398 resource_prefetch_predictor_observer_; |
375 | 399 |
376 mutable chrome_browser_net::CacheStats* cache_stats_; | 400 mutable chrome_browser_net::CacheStats* cache_stats_; |
377 | 401 |
378 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 402 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
379 bool initialized_on_UI_thread_; | 403 bool initialized_on_UI_thread_; |
380 | 404 |
381 bool is_incognito_; | 405 bool is_incognito_; |
382 | 406 |
383 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 407 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
384 }; | 408 }; |
385 | 409 |
386 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 410 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
OLD | NEW |