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 #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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 resource_context_(new ResourceContext(this))), | 264 resource_context_(new ResourceContext(this))), |
265 initialized_on_UI_thread_(false), | 265 initialized_on_UI_thread_(false), |
266 is_incognito_(is_incognito) { | 266 is_incognito_(is_incognito) { |
267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
268 } | 268 } |
269 | 269 |
270 ProfileIOData::~ProfileIOData() { | 270 ProfileIOData::~ProfileIOData() { |
271 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 271 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
273 | 273 |
274 if (main_request_context_) | 274 if (main_request_context_.get()) |
275 main_request_context_->AssertNoURLRequests(); | 275 main_request_context_->AssertNoURLRequests(); |
276 if (extensions_request_context_) | 276 if (extensions_request_context_.get()) |
277 extensions_request_context_->AssertNoURLRequests(); | 277 extensions_request_context_->AssertNoURLRequests(); |
278 for (AppRequestContextMap::iterator it = app_request_context_map_.begin(); | 278 for (AppRequestContextMap::iterator it = app_request_context_map_.begin(); |
279 it != app_request_context_map_.end(); ++it) { | 279 it != app_request_context_map_.end(); ++it) { |
280 it->second->AssertNoURLRequests(); | 280 it->second->AssertNoURLRequests(); |
| 281 delete it->second; |
281 } | 282 } |
282 } | 283 } |
283 | 284 |
284 // static | 285 // static |
285 ProfileIOData* ProfileIOData::FromResourceContext( | 286 ProfileIOData* ProfileIOData::FromResourceContext( |
286 content::ResourceContext* rc) { | 287 content::ResourceContext* rc) { |
287 return (static_cast<ResourceContext*>(rc))->io_data_; | 288 return (static_cast<ResourceContext*>(rc))->io_data_; |
288 } | 289 } |
289 | 290 |
290 // static | 291 // static |
(...skipping 28 matching lines...) Expand all Loading... |
319 content::ResourceContext* ProfileIOData::GetResourceContext() const { | 320 content::ResourceContext* ProfileIOData::GetResourceContext() const { |
320 return resource_context_.get(); | 321 return resource_context_.get(); |
321 } | 322 } |
322 | 323 |
323 ChromeURLDataManagerBackend* | 324 ChromeURLDataManagerBackend* |
324 ProfileIOData::GetChromeURLDataManagerBackend() const { | 325 ProfileIOData::GetChromeURLDataManagerBackend() const { |
325 LazyInitialize(); | 326 LazyInitialize(); |
326 return chrome_url_data_manager_backend_.get(); | 327 return chrome_url_data_manager_backend_.get(); |
327 } | 328 } |
328 | 329 |
329 scoped_refptr<ChromeURLRequestContext> | 330 ChromeURLRequestContext* |
330 ProfileIOData::GetMainRequestContext() const { | 331 ProfileIOData::GetMainRequestContext() const { |
331 LazyInitialize(); | 332 LazyInitialize(); |
332 return main_request_context_; | 333 return main_request_context_.get(); |
333 } | 334 } |
334 | 335 |
335 scoped_refptr<ChromeURLRequestContext> | 336 ChromeURLRequestContext* |
336 ProfileIOData::GetMediaRequestContext() const { | 337 ProfileIOData::GetMediaRequestContext() const { |
337 LazyInitialize(); | 338 LazyInitialize(); |
338 scoped_refptr<ChromeURLRequestContext> context = | 339 ChromeURLRequestContext* context = |
339 AcquireMediaRequestContext(); | 340 AcquireMediaRequestContext(); |
340 DCHECK(context); | 341 DCHECK(context); |
341 return context; | 342 return context; |
342 } | 343 } |
343 | 344 |
344 scoped_refptr<ChromeURLRequestContext> | 345 ChromeURLRequestContext* |
345 ProfileIOData::GetExtensionsRequestContext() const { | 346 ProfileIOData::GetExtensionsRequestContext() const { |
346 LazyInitialize(); | 347 LazyInitialize(); |
347 return extensions_request_context_; | 348 return extensions_request_context_.get(); |
348 } | 349 } |
349 | 350 |
350 scoped_refptr<ChromeURLRequestContext> | 351 ChromeURLRequestContext* |
351 ProfileIOData::GetIsolatedAppRequestContext( | 352 ProfileIOData::GetIsolatedAppRequestContext( |
352 scoped_refptr<ChromeURLRequestContext> main_context, | 353 ChromeURLRequestContext* main_context, |
353 const std::string& app_id) const { | 354 const std::string& app_id) const { |
354 LazyInitialize(); | 355 LazyInitialize(); |
355 scoped_refptr<ChromeURLRequestContext> context; | 356 ChromeURLRequestContext* context; |
356 if (ContainsKey(app_request_context_map_, app_id)) { | 357 if (ContainsKey(app_request_context_map_, app_id)) { |
357 context = app_request_context_map_[app_id]; | 358 context = app_request_context_map_[app_id]; |
358 } else { | 359 } else { |
359 context = AcquireIsolatedAppRequestContext(main_context, app_id); | 360 context = AcquireIsolatedAppRequestContext(main_context, app_id); |
360 app_request_context_map_[app_id] = context; | 361 app_request_context_map_[app_id] = context; |
361 } | 362 } |
362 DCHECK(context); | 363 DCHECK(context); |
363 return context; | 364 return context; |
364 } | 365 } |
365 | 366 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 CHECK(initialized_on_UI_thread_); | 459 CHECK(initialized_on_UI_thread_); |
459 | 460 |
460 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. | 461 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. |
461 CHECK(profile_params_.get()); | 462 CHECK(profile_params_.get()); |
462 | 463 |
463 IOThread* const io_thread = profile_params_->io_thread; | 464 IOThread* const io_thread = profile_params_->io_thread; |
464 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 465 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
465 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 466 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
466 | 467 |
467 // Create the common request contexts. | 468 // Create the common request contexts. |
468 main_request_context_ = new ChromeURLRequestContext; | 469 main_request_context_.reset(new ChromeURLRequestContext); |
469 extensions_request_context_ = new ChromeURLRequestContext; | 470 extensions_request_context_.reset(new ChromeURLRequestContext); |
470 | 471 |
471 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); | 472 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend); |
472 | 473 |
473 network_delegate_.reset(new ChromeNetworkDelegate( | 474 network_delegate_.reset(new ChromeNetworkDelegate( |
474 io_thread_globals->extension_event_router_forwarder.get(), | 475 io_thread_globals->extension_event_router_forwarder.get(), |
475 profile_params_->extension_info_map, | 476 profile_params_->extension_info_map, |
476 url_blacklist_manager_.get(), | 477 url_blacklist_manager_.get(), |
477 profile_params_->profile, | 478 profile_params_->profile, |
478 profile_params_->cookie_settings, | 479 profile_params_->cookie_settings, |
479 &enable_referrers_)); | 480 &enable_referrers_)); |
480 | 481 |
481 fraudulent_certificate_reporter_.reset( | 482 fraudulent_certificate_reporter_.reset( |
482 new chrome_browser_net::ChromeFraudulentCertificateReporter( | 483 new chrome_browser_net::ChromeFraudulentCertificateReporter( |
483 main_request_context_)); | 484 main_request_context_.get())); |
484 | 485 |
485 proxy_service_.reset( | 486 proxy_service_.reset( |
486 ProxyServiceFactory::CreateProxyService( | 487 ProxyServiceFactory::CreateProxyService( |
487 io_thread->net_log(), | 488 io_thread->net_log(), |
488 io_thread_globals->proxy_script_fetcher_context.get(), | 489 io_thread_globals->proxy_script_fetcher_context.get(), |
489 profile_params_->proxy_config_service.release(), | 490 profile_params_->proxy_config_service.release(), |
490 command_line)); | 491 command_line)); |
491 | 492 |
492 transport_security_state_.reset(new net::TransportSecurityState()); | 493 transport_security_state_.reset(new net::TransportSecurityState()); |
493 transport_security_persister_.reset( | 494 transport_security_persister_.reset( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 #endif // defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) | 530 #endif // defined(OS_CHROMEOS) && !defined(GOOGLE_CHROME_BUILD) |
530 | 531 |
531 // Take ownership over these parameters. | 532 // Take ownership over these parameters. |
532 cookie_settings_ = profile_params_->cookie_settings; | 533 cookie_settings_ = profile_params_->cookie_settings; |
533 #if defined(ENABLE_NOTIFICATIONS) | 534 #if defined(ENABLE_NOTIFICATIONS) |
534 notification_service_ = profile_params_->notification_service; | 535 notification_service_ = profile_params_->notification_service; |
535 #endif | 536 #endif |
536 extension_info_map_ = profile_params_->extension_info_map; | 537 extension_info_map_ = profile_params_->extension_info_map; |
537 | 538 |
538 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); | 539 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
539 resource_context_->request_context_ = main_request_context_; | 540 resource_context_->request_context_ = main_request_context_.get(); |
540 | 541 |
541 LazyInitializeInternal(profile_params_.get()); | 542 LazyInitializeInternal(profile_params_.get()); |
542 | 543 |
543 profile_params_.reset(); | 544 profile_params_.reset(); |
544 initialized_ = true; | 545 initialized_ = true; |
545 } | 546 } |
546 | 547 |
547 void ProfileIOData::ApplyProfileParamsToContext( | 548 void ProfileIOData::ApplyProfileParamsToContext( |
548 ChromeURLRequestContext* context) const { | 549 ChromeURLRequestContext* context) const { |
549 context->set_is_incognito(is_incognito()); | 550 context->set_is_incognito(is_incognito()); |
(...skipping 22 matching lines...) Expand all Loading... |
572 } | 573 } |
573 | 574 |
574 void ProfileIOData::set_server_bound_cert_service( | 575 void ProfileIOData::set_server_bound_cert_service( |
575 net::ServerBoundCertService* server_bound_cert_service) const { | 576 net::ServerBoundCertService* server_bound_cert_service) const { |
576 server_bound_cert_service_.reset(server_bound_cert_service); | 577 server_bound_cert_service_.reset(server_bound_cert_service); |
577 } | 578 } |
578 | 579 |
579 void ProfileIOData::DestroyResourceContext() { | 580 void ProfileIOData::DestroyResourceContext() { |
580 resource_context_.reset(); | 581 resource_context_.reset(); |
581 } | 582 } |
OLD | NEW |