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

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

Issue 10836305: Ensure that isolated apps use the right cookies for media requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments Created 8 years, 4 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 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
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
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
309 // Does an on-demand initialization of a media RequestContext for the given
310 // isolated app.
311 virtual ChromeURLRequestContext* InitializeMediaRequestContext(
312 ChromeURLRequestContext* original_context,
313 const std::string& app_id) const = 0;
314
290 // These functions are used to transfer ownership of the lazily initialized 315 // These functions are used to transfer ownership of the lazily initialized
291 // context from ProfileIOData to the URLRequestContextGetter. 316 // context from ProfileIOData to the URLRequestContextGetter.
292 virtual ChromeURLRequestContext* 317 virtual ChromeURLRequestContext*
293 AcquireMediaRequestContext() const = 0; 318 AcquireMediaRequestContext() const = 0;
294 virtual ChromeURLRequestContext* 319 virtual ChromeURLRequestContext*
295 AcquireIsolatedAppRequestContext( 320 AcquireIsolatedAppRequestContext(
296 ChromeURLRequestContext* main_context, 321 ChromeURLRequestContext* main_context,
297 const std::string& app_id) const = 0; 322 const std::string& app_id) const = 0;
323 virtual ChromeURLRequestContext*
324 AcquireIsolatedMediaRequestContext(
325 ChromeURLRequestContext* app_context,
326 const std::string& app_id) const = 0;
298 327
299 // Returns the CacheStats object to be used for this profile. 328 // Returns the CacheStats object to be used for this profile.
300 virtual chrome_browser_net::CacheStats* GetCacheStats( 329 virtual chrome_browser_net::CacheStats* GetCacheStats(
301 IOThread::Globals* io_thread_globals) const = 0; 330 IOThread::Globals* io_thread_globals) const = 0;
302 331
303 // The order *DOES* matter for the majority of these member variables, so 332 // 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! 333 // don't move them around unless you know what you're doing!
305 // General rules: 334 // General rules:
306 // * ResourceContext references the URLRequestContexts, so 335 // * ResourceContext references the URLRequestContexts, so
307 // URLRequestContexts must outlive ResourceContext, hence ResourceContext 336 // URLRequestContexts must outlive ResourceContext, hence ResourceContext
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 mutable DesktopNotificationService* notification_service_; 384 mutable DesktopNotificationService* notification_service_;
356 #endif 385 #endif
357 386
358 mutable scoped_ptr<TransportSecurityPersister> 387 mutable scoped_ptr<TransportSecurityPersister>
359 transport_security_persister_; 388 transport_security_persister_;
360 389
361 // These are only valid in between LazyInitialize() and their accessor being 390 // These are only valid in between LazyInitialize() and their accessor being
362 // called. 391 // called.
363 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_; 392 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_;
364 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_; 393 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_;
365 // One AppRequestContext per isolated app. 394 // One URLRequestContext per isolated app for main and media requests.
366 mutable AppRequestContextMap app_request_context_map_; 395 mutable URLRequestContextMap app_request_context_map_;
396 mutable URLRequestContextMap isolated_media_request_context_map_;
367 397
368 mutable scoped_ptr<ResourceContext> resource_context_; 398 mutable scoped_ptr<ResourceContext> resource_context_;
369 399
370 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_; 400 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_;
371 mutable scoped_refptr<CookieSettings> cookie_settings_; 401 mutable scoped_refptr<CookieSettings> cookie_settings_;
372 402
373 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver> 403 mutable scoped_ptr<chrome_browser_net::ResourcePrefetchPredictorObserver>
374 resource_prefetch_predictor_observer_; 404 resource_prefetch_predictor_observer_;
375 405
376 mutable chrome_browser_net::CacheStats* cache_stats_; 406 mutable chrome_browser_net::CacheStats* cache_stats_;
377 407
378 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 408 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
379 bool initialized_on_UI_thread_; 409 bool initialized_on_UI_thread_;
380 410
381 bool is_incognito_; 411 bool is_incognito_;
382 412
383 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 413 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
384 }; 414 };
385 415
386 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 416 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698