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

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

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL Created 8 years, 7 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // net::URLRequest. 67 // net::URLRequest.
68 static bool IsHandledURL(const GURL& url); 68 static bool IsHandledURL(const GURL& url);
69 69
70 // Called by Profile. 70 // Called by Profile.
71 content::ResourceContext* GetResourceContext() const; 71 content::ResourceContext* GetResourceContext() const;
72 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const; 72 ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend() const;
73 73
74 // These should only be called at most once each. Ownership is reversed when 74 // These should only be called at most once each. Ownership is reversed when
75 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice 75 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice
76 // versa. 76 // versa.
77 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; 77 ChromeURLRequestContext* GetMainRequestContext() const;
78 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; 78 ChromeURLRequestContext* GetMediaRequestContext() const;
79 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; 79 ChromeURLRequestContext* GetExtensionsRequestContext() const;
80 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( 80 ChromeURLRequestContext* GetIsolatedAppRequestContext(
81 scoped_refptr<ChromeURLRequestContext> main_context, 81 ChromeURLRequestContext* main_context,
82 const std::string& app_id) const; 82 const std::string& app_id) const;
83 83
84 // These are useful when the Chrome layer is called from the content layer 84 // These are useful when the Chrome layer is called from the content layer
85 // with a content::ResourceContext, and they want access to Chrome data for 85 // with a content::ResourceContext, and they want access to Chrome data for
86 // that profile. 86 // that profile.
87 ExtensionInfoMap* GetExtensionInfoMap() const; 87 ExtensionInfoMap* GetExtensionInfoMap() const;
88 CookieSettings* GetCookieSettings() const; 88 CookieSettings* GetCookieSettings() const;
89 89
90 #if defined(ENABLE_NOTIFICATIONS) 90 #if defined(ENABLE_NOTIFICATIONS)
91 DesktopNotificationService* GetNotificationService() const; 91 DesktopNotificationService* GetNotificationService() const;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 219
220 net::URLRequestJobFactory* job_factory() const { 220 net::URLRequestJobFactory* job_factory() const {
221 return job_factory_.get(); 221 return job_factory_.get();
222 } 222 }
223 223
224 void set_http_server_properties_manager( 224 void set_http_server_properties_manager(
225 chrome_browser_net::HttpServerPropertiesManager* manager) const; 225 chrome_browser_net::HttpServerPropertiesManager* manager) const;
226 226
227 ChromeURLRequestContext* main_request_context() const { 227 ChromeURLRequestContext* main_request_context() const {
228 return main_request_context_; 228 return main_request_context_.get();
229 } 229 }
230 230
231 // Destroys the ResourceContext first, to cancel any URLRequests that are 231 // Destroys the ResourceContext first, to cancel any URLRequests that are
232 // using it still, before we destroy the member variables that those 232 // using it still, before we destroy the member variables that those
233 // URLRequests may be accessing. 233 // URLRequests may be accessing.
234 void DestroyResourceContext(); 234 void DestroyResourceContext();
235 235
236 private: 236 private:
237 class ResourceContext : public content::ResourceContext { 237 class ResourceContext : public content::ResourceContext {
238 public: 238 public:
239 explicit ResourceContext(ProfileIOData* io_data); 239 explicit ResourceContext(ProfileIOData* io_data);
240 virtual ~ResourceContext(); 240 virtual ~ResourceContext();
241 241
242 // ResourceContext implementation: 242 // ResourceContext implementation:
243 virtual net::HostResolver* GetHostResolver() OVERRIDE; 243 virtual net::HostResolver* GetHostResolver() OVERRIDE;
244 virtual net::URLRequestContext* GetRequestContext() OVERRIDE; 244 virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
245 245
246 private: 246 private:
247 friend class ProfileIOData; 247 friend class ProfileIOData;
248 248
249 void EnsureInitialized(); 249 void EnsureInitialized();
250 250
251 ProfileIOData* const io_data_; 251 ProfileIOData* const io_data_;
252 252
253 net::HostResolver* host_resolver_; 253 net::HostResolver* host_resolver_;
254 net::URLRequestContext* request_context_; 254 net::URLRequestContext* request_context_;
255 }; 255 };
256 256
257 typedef base::hash_map<std::string, scoped_refptr<ChromeURLRequestContext> > 257 typedef base::hash_map<std::string, ChromeURLRequestContext*>
258 AppRequestContextMap; 258 AppRequestContextMap;
259 259
260 // -------------------------------------------- 260 // --------------------------------------------
261 // Virtual interface for subtypes to implement: 261 // Virtual interface for subtypes to implement:
262 // -------------------------------------------- 262 // --------------------------------------------
263 263
264 // Does the actual initialization of the ProfileIOData subtype. Subtypes 264 // Does the actual initialization of the ProfileIOData subtype. Subtypes
265 // should use the static helper functions above to implement this. 265 // should use the static helper functions above to implement this.
266 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0; 266 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0;
267 267
268 // Does an on-demand initialization of a RequestContext for the given 268 // Does an on-demand initialization of a RequestContext for the given
269 // isolated app. 269 // isolated app.
270 virtual scoped_refptr<ChromeURLRequestContext> InitializeAppRequestContext( 270 virtual ChromeURLRequestContext* InitializeAppRequestContext(
271 scoped_refptr<ChromeURLRequestContext> main_context, 271 ChromeURLRequestContext* main_context,
272 const std::string& app_id) const = 0; 272 const std::string& app_id) const = 0;
273 273
274 // These functions are used to transfer ownership of the lazily initialized 274 // These functions are used to transfer ownership of the lazily initialized
275 // context from ProfileIOData to the URLRequestContextGetter. 275 // context from ProfileIOData to the URLRequestContextGetter.
276 virtual scoped_refptr<ChromeURLRequestContext> 276 virtual ChromeURLRequestContext*
277 AcquireMediaRequestContext() const = 0; 277 AcquireMediaRequestContext() const = 0;
278 virtual scoped_refptr<ChromeURLRequestContext> 278 virtual ChromeURLRequestContext*
279 AcquireIsolatedAppRequestContext( 279 AcquireIsolatedAppRequestContext(
280 scoped_refptr<ChromeURLRequestContext> main_context, 280 ChromeURLRequestContext* main_context,
281 const std::string& app_id) const = 0; 281 const std::string& app_id) const = 0;
282 282
283 // The order *DOES* matter for the majority of these member variables, so 283 // The order *DOES* matter for the majority of these member variables, so
284 // don't move them around unless you know what you're doing! 284 // don't move them around unless you know what you're doing!
285 // General rules: 285 // General rules:
286 // * ResourceContext references the URLRequestContexts, so 286 // * ResourceContext references the URLRequestContexts, so
287 // URLRequestContexts must outlive ResourceContext, hence ResourceContext 287 // URLRequestContexts must outlive ResourceContext, hence ResourceContext
288 // should be destroyed first. 288 // should be destroyed first.
289 // * URLRequestContexts reference a whole bunch of members, so 289 // * URLRequestContexts reference a whole bunch of members, so
290 // URLRequestContext needs to be destroyed before them. 290 // URLRequestContext needs to be destroyed before them.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 #if defined(ENABLE_NOTIFICATIONS) 335 #if defined(ENABLE_NOTIFICATIONS)
336 mutable DesktopNotificationService* notification_service_; 336 mutable DesktopNotificationService* notification_service_;
337 #endif 337 #endif
338 338
339 mutable scoped_ptr<TransportSecurityPersister> 339 mutable scoped_ptr<TransportSecurityPersister>
340 transport_security_persister_; 340 transport_security_persister_;
341 341
342 // These are only valid in between LazyInitialize() and their accessor being 342 // These are only valid in between LazyInitialize() and their accessor being
343 // called. 343 // called.
344 mutable scoped_refptr<ChromeURLRequestContext> main_request_context_; 344 mutable scoped_ptr<ChromeURLRequestContext> main_request_context_;
345 mutable scoped_refptr<ChromeURLRequestContext> extensions_request_context_; 345 mutable scoped_ptr<ChromeURLRequestContext> extensions_request_context_;
346 // One AppRequestContext per isolated app. 346 // One AppRequestContext per isolated app.
347 mutable AppRequestContextMap app_request_context_map_; 347 mutable AppRequestContextMap app_request_context_map_;
348 348
349 mutable scoped_ptr<ResourceContext> resource_context_; 349 mutable scoped_ptr<ResourceContext> resource_context_;
350 350
351 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_; 351 mutable scoped_refptr<ExtensionInfoMap> extension_info_map_;
352 mutable scoped_refptr<CookieSettings> cookie_settings_; 352 mutable scoped_refptr<CookieSettings> cookie_settings_;
353 353
354 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 354 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
355 bool initialized_on_UI_thread_; 355 bool initialized_on_UI_thread_;
356 356
357 bool is_incognito_; 357 bool is_incognito_;
358 358
359 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 359 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
360 }; 360 };
361 361
362 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 362 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698