Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 } | 569 } |
| 570 | 570 |
| 571 void ProfileImpl::InitRegisteredProtocolHandlers() { | 571 void ProfileImpl::InitRegisteredProtocolHandlers() { |
| 572 if (protocol_handler_registry_) | 572 if (protocol_handler_registry_) |
| 573 return; | 573 return; |
| 574 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, | 574 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, |
| 575 new ProtocolHandlerRegistry::Delegate()); | 575 new ProtocolHandlerRegistry::Delegate()); |
| 576 protocol_handler_registry_->Load(); | 576 protocol_handler_registry_->Load(); |
| 577 } | 577 } |
| 578 | 578 |
| 579 NTPResourceCache* ProfileImpl::GetNTPResourceCache() { | |
| 580 if (!ntp_resource_cache_.get()) | |
| 581 ntp_resource_cache_.reset(new NTPResourceCache(this)); | |
| 582 return ntp_resource_cache_.get(); | |
| 583 } | |
| 584 | |
| 585 FilePath ProfileImpl::last_selected_directory() { | 579 FilePath ProfileImpl::last_selected_directory() { |
| 586 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 580 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
| 587 } | 581 } |
| 588 | 582 |
| 589 void ProfileImpl::set_last_selected_directory(const FilePath& path) { | 583 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
| 590 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 584 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
| 591 } | 585 } |
| 592 | 586 |
| 593 ProfileImpl::~ProfileImpl() { | 587 ProfileImpl::~ProfileImpl() { |
| 594 NotificationService::current()->Notify( | 588 NotificationService::current()->Notify( |
| 595 NotificationType::PROFILE_DESTROYED, | 589 NotificationType::PROFILE_DESTROYED, |
| 596 Source<Profile>(this), | 590 Source<Profile>(this), |
| 597 NotificationService::NoDetails()); | 591 NotificationService::NoDetails()); |
| 598 | 592 |
| 599 StopCreateSessionServiceTimer(); | 593 StopCreateSessionServiceTimer(); |
| 600 | 594 |
| 595 // Remove pref observers | |
| 596 pref_change_registrar_.RemoveAll(); | |
| 597 | |
| 601 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 598 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
| 602 | 599 |
| 603 if (clear_local_state_on_exit_) { | 600 if (clear_local_state_on_exit_) { |
| 604 BrowserThread::PostTask( | 601 BrowserThread::PostTask( |
| 605 BrowserThread::FILE, FROM_HERE, | 602 BrowserThread::FILE, FROM_HERE, |
| 606 NewRunnableFunction(&BrowsingDataRemover::ClearGearsData, path_)); | 603 NewRunnableFunction(&BrowsingDataRemover::ClearGearsData, path_)); |
| 607 } | 604 } |
| 608 | 605 |
| 609 // DownloadManager is lazily created, so check before accessing it. | 606 // DownloadManager is lazily created, so check before accessing it. |
| 610 if (download_manager_.get()) { | 607 if (download_manager_.get()) { |
| 611 // The download manager queries the history system and should be shut down | 608 // The download manager queries the history system and should be shut down |
| 612 // before the history is shut down so it can properly cancel all requests. | 609 // before the history is shut down so it can properly cancel all requests. |
| 613 download_manager_->Shutdown(); | 610 download_manager_->Shutdown(); |
| 614 download_manager_ = NULL; | 611 download_manager_ = NULL; |
| 615 } | 612 } |
| 616 | 613 |
| 617 // Remove pref observers | |
| 618 pref_change_registrar_.RemoveAll(); | |
| 619 | |
| 620 // Delete the NTP resource cache so we can unregister pref observers. | |
|
Elliot Glaysher
2011/06/29 19:12:00
This comment is seriously wrong. Pref observers ar
Miranda Callahan
2011/06/29 19:31:57
Ha! Nice catch.
| |
| 621 ntp_resource_cache_.reset(); | |
| 622 | |
| 623 // The sync service needs to be deleted before the services it calls. | 614 // The sync service needs to be deleted before the services it calls. |
| 624 sync_service_.reset(); | 615 sync_service_.reset(); |
| 625 | 616 |
| 626 // Password store uses WebDB, shut it down before the WebDB has been shutdown. | 617 // Password store uses WebDB, shut it down before the WebDB has been shutdown. |
| 627 if (password_store_.get()) | 618 if (password_store_.get()) |
| 628 password_store_->Shutdown(); | 619 password_store_->Shutdown(); |
| 629 | 620 |
| 630 // Both HistoryService and WebDataService maintain threads for background | 621 // Both HistoryService and WebDataService maintain threads for background |
| 631 // processing. Its possible each thread still has tasks on it that have | 622 // processing. Its possible each thread still has tasks on it that have |
| 632 // increased the ref count of the service. In such a situation, when we | 623 // increased the ref count of the service. In such a situation, when we |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1642 if (!prerender::PrerenderManager::IsPrerenderingPossible()) | 1633 if (!prerender::PrerenderManager::IsPrerenderingPossible()) |
| 1643 return NULL; | 1634 return NULL; |
| 1644 if (!prerender_manager_.get()) { | 1635 if (!prerender_manager_.get()) { |
| 1645 CHECK(g_browser_process->prerender_tracker()); | 1636 CHECK(g_browser_process->prerender_tracker()); |
| 1646 prerender_manager_.reset( | 1637 prerender_manager_.reset( |
| 1647 new prerender::PrerenderManager( | 1638 new prerender::PrerenderManager( |
| 1648 this, g_browser_process->prerender_tracker())); | 1639 this, g_browser_process->prerender_tracker())); |
| 1649 } | 1640 } |
| 1650 return prerender_manager_.get(); | 1641 return prerender_manager_.get(); |
| 1651 } | 1642 } |
| OLD | NEW |