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

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

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 #include "chrome/browser/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 resource_context_(new ResourceContext(this))), 265 resource_context_(new ResourceContext(this))),
266 initialized_on_UI_thread_(false), 266 initialized_on_UI_thread_(false),
267 is_incognito_(is_incognito) { 267 is_incognito_(is_incognito) {
268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
269 } 269 }
270 270
271 ProfileIOData::~ProfileIOData() { 271 ProfileIOData::~ProfileIOData() {
272 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) 272 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO))
273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
274 274
275 if (main_request_context_) 275 if (main_request_context_.get())
276 main_request_context_->AssertNoURLRequests(); 276 main_request_context_->AssertNoURLRequests();
277 if (extensions_request_context_) 277 if (extensions_request_context_.get())
278 extensions_request_context_->AssertNoURLRequests(); 278 extensions_request_context_->AssertNoURLRequests();
279 for (AppRequestContextMap::iterator it = app_request_context_map_.begin(); 279 for (AppRequestContextMap::iterator it = app_request_context_map_.begin();
280 it != app_request_context_map_.end(); ++it) { 280 it != app_request_context_map_.end(); ++it) {
281 it->second->AssertNoURLRequests(); 281 it->second->AssertNoURLRequests();
282 delete it->second;
282 } 283 }
283 } 284 }
284 285
285 // static 286 // static
286 ProfileIOData* ProfileIOData::FromResourceContext( 287 ProfileIOData* ProfileIOData::FromResourceContext(
287 content::ResourceContext* rc) { 288 content::ResourceContext* rc) {
288 return (static_cast<ResourceContext*>(rc))->io_data_; 289 return (static_cast<ResourceContext*>(rc))->io_data_;
289 } 290 }
290 291
291 // static 292 // static
(...skipping 29 matching lines...) Expand all
321 content::ResourceContext* ProfileIOData::GetResourceContext() const { 322 content::ResourceContext* ProfileIOData::GetResourceContext() const {
322 return resource_context_.get(); 323 return resource_context_.get();
323 } 324 }
324 325
325 ChromeURLDataManagerBackend* 326 ChromeURLDataManagerBackend*
326 ProfileIOData::GetChromeURLDataManagerBackend() const { 327 ProfileIOData::GetChromeURLDataManagerBackend() const {
327 LazyInitialize(); 328 LazyInitialize();
328 return chrome_url_data_manager_backend_.get(); 329 return chrome_url_data_manager_backend_.get();
329 } 330 }
330 331
331 scoped_refptr<ChromeURLRequestContext> 332 ChromeURLRequestContext*
332 ProfileIOData::GetMainRequestContext() const { 333 ProfileIOData::GetMainRequestContext() const {
333 LazyInitialize(); 334 LazyInitialize();
334 return main_request_context_; 335 return main_request_context_.get();
335 } 336 }
336 337
337 scoped_refptr<ChromeURLRequestContext> 338 ChromeURLRequestContext*
338 ProfileIOData::GetMediaRequestContext() const { 339 ProfileIOData::GetMediaRequestContext() const {
339 LazyInitialize(); 340 LazyInitialize();
340 scoped_refptr<ChromeURLRequestContext> context = 341 ChromeURLRequestContext* context =
341 AcquireMediaRequestContext(); 342 AcquireMediaRequestContext();
342 DCHECK(context); 343 DCHECK(context);
343 return context; 344 return context;
344 } 345 }
345 346
346 scoped_refptr<ChromeURLRequestContext> 347 ChromeURLRequestContext*
347 ProfileIOData::GetExtensionsRequestContext() const { 348 ProfileIOData::GetExtensionsRequestContext() const {
348 LazyInitialize(); 349 LazyInitialize();
349 return extensions_request_context_; 350 return extensions_request_context_.get();
350 } 351 }
351 352
352 scoped_refptr<ChromeURLRequestContext> 353 ChromeURLRequestContext*
353 ProfileIOData::GetIsolatedAppRequestContext( 354 ProfileIOData::GetIsolatedAppRequestContext(
354 scoped_refptr<ChromeURLRequestContext> main_context, 355 ChromeURLRequestContext* main_context,
355 const std::string& app_id) const { 356 const std::string& app_id) const {
356 LazyInitialize(); 357 LazyInitialize();
357 scoped_refptr<ChromeURLRequestContext> context; 358 ChromeURLRequestContext* context;
358 if (ContainsKey(app_request_context_map_, app_id)) { 359 if (ContainsKey(app_request_context_map_, app_id)) {
359 context = app_request_context_map_[app_id]; 360 context = app_request_context_map_[app_id];
360 } else { 361 } else {
361 context = AcquireIsolatedAppRequestContext(main_context, app_id); 362 context = AcquireIsolatedAppRequestContext(main_context, app_id);
362 app_request_context_map_[app_id] = context; 363 app_request_context_map_[app_id] = context;
363 } 364 }
364 DCHECK(context); 365 DCHECK(context);
365 return context; 366 return context;
366 } 367 }
367 368
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 CHECK(initialized_on_UI_thread_); 461 CHECK(initialized_on_UI_thread_);
461 462
462 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. 463 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed.
463 CHECK(profile_params_.get()); 464 CHECK(profile_params_.get());
464 465
465 IOThread* const io_thread = profile_params_->io_thread; 466 IOThread* const io_thread = profile_params_->io_thread;
466 IOThread::Globals* const io_thread_globals = io_thread->globals(); 467 IOThread::Globals* const io_thread_globals = io_thread->globals();
467 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 468 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
468 469
469 // Create the common request contexts. 470 // Create the common request contexts.
470 main_request_context_ = new ChromeURLRequestContext; 471 main_request_context_.reset(new ChromeURLRequestContext);
471 extensions_request_context_ = new ChromeURLRequestContext; 472 extensions_request_context_.reset(new ChromeURLRequestContext);
472 473
473 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); 474 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend);
474 475
475 network_delegate_.reset(new ChromeNetworkDelegate( 476 network_delegate_.reset(new ChromeNetworkDelegate(
476 io_thread_globals->extension_event_router_forwarder.get(), 477 io_thread_globals->extension_event_router_forwarder.get(),
477 profile_params_->extension_info_map, 478 profile_params_->extension_info_map,
478 url_blacklist_manager_.get(), 479 url_blacklist_manager_.get(),
479 profile_params_->profile, 480 profile_params_->profile,
480 profile_params_->cookie_settings, 481 profile_params_->cookie_settings,
481 &enable_referrers_)); 482 &enable_referrers_));
482 483
483 fraudulent_certificate_reporter_.reset( 484 fraudulent_certificate_reporter_.reset(
484 new chrome_browser_net::ChromeFraudulentCertificateReporter( 485 new chrome_browser_net::ChromeFraudulentCertificateReporter(
485 main_request_context_)); 486 main_request_context_.get()));
486 487
487 proxy_service_.reset( 488 proxy_service_.reset(
488 ProxyServiceFactory::CreateProxyService( 489 ProxyServiceFactory::CreateProxyService(
489 io_thread->net_log(), 490 io_thread->net_log(),
490 io_thread_globals->proxy_script_fetcher_context.get(), 491 io_thread_globals->proxy_script_fetcher_context.get(),
491 profile_params_->proxy_config_service.release(), 492 profile_params_->proxy_config_service.release(),
492 command_line)); 493 command_line));
493 494
494 transport_security_state_.reset(new net::TransportSecurityState()); 495 transport_security_state_.reset(new net::TransportSecurityState());
495 transport_security_persister_.reset( 496 transport_security_persister_.reset(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 #endif // defined(OS_CHROMEOS) 539 #endif // defined(OS_CHROMEOS)
539 540
540 // Take ownership over these parameters. 541 // Take ownership over these parameters.
541 cookie_settings_ = profile_params_->cookie_settings; 542 cookie_settings_ = profile_params_->cookie_settings;
542 #if defined(ENABLE_NOTIFICATIONS) 543 #if defined(ENABLE_NOTIFICATIONS)
543 notification_service_ = profile_params_->notification_service; 544 notification_service_ = profile_params_->notification_service;
544 #endif 545 #endif
545 extension_info_map_ = profile_params_->extension_info_map; 546 extension_info_map_ = profile_params_->extension_info_map;
546 547
547 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); 548 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get();
548 resource_context_->request_context_ = main_request_context_; 549 resource_context_->request_context_ = main_request_context_.get();
549 550
550 LazyInitializeInternal(profile_params_.get()); 551 LazyInitializeInternal(profile_params_.get());
551 552
552 profile_params_.reset(); 553 profile_params_.reset();
553 initialized_ = true; 554 initialized_ = true;
554 } 555 }
555 556
556 void ProfileIOData::ApplyProfileParamsToContext( 557 void ProfileIOData::ApplyProfileParamsToContext(
557 ChromeURLRequestContext* context) const { 558 ChromeURLRequestContext* context) const {
558 context->set_is_incognito(is_incognito()); 559 context->set_is_incognito(is_incognito());
(...skipping 22 matching lines...) Expand all
581 } 582 }
582 583
583 void ProfileIOData::set_server_bound_cert_service( 584 void ProfileIOData::set_server_bound_cert_service(
584 net::ServerBoundCertService* server_bound_cert_service) const { 585 net::ServerBoundCertService* server_bound_cert_service) const {
585 server_bound_cert_service_.reset(server_bound_cert_service); 586 server_bound_cert_service_.reset(server_bound_cert_service);
586 } 587 }
587 588
588 void ProfileIOData::DestroyResourceContext() { 589 void ProfileIOData::DestroyResourceContext() {
589 resource_context_.reset(); 590 resource_context_.reset();
590 } 591 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698