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

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

Issue 7248038: Profiles: Make NTPResourceCache a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test compile Created 9 years, 5 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "chrome/browser/spellcheck_host.h" 63 #include "chrome/browser/spellcheck_host.h"
64 #include "chrome/browser/spellcheck_host_metrics.h" 64 #include "chrome/browser/spellcheck_host_metrics.h"
65 #include "chrome/browser/sync/profile_sync_factory_impl.h" 65 #include "chrome/browser/sync/profile_sync_factory_impl.h"
66 #include "chrome/browser/sync/profile_sync_service.h" 66 #include "chrome/browser/sync/profile_sync_service.h"
67 #include "chrome/browser/tabs/pinned_tab_service_factory.h" 67 #include "chrome/browser/tabs/pinned_tab_service_factory.h"
68 #include "chrome/browser/transport_security_persister.h" 68 #include "chrome/browser/transport_security_persister.h"
69 #include "chrome/browser/ui/browser_list.h" 69 #include "chrome/browser/ui/browser_list.h"
70 #include "chrome/browser/ui/find_bar/find_bar_state.h" 70 #include "chrome/browser/ui/find_bar/find_bar_state.h"
71 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 71 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
72 #include "chrome/browser/ui/webui/extension_icon_source.h" 72 #include "chrome/browser/ui/webui/extension_icon_source.h"
73 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 73 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
Miranda Callahan 2011/06/29 19:31:57 can be zapped
74 #include "chrome/browser/user_style_sheet_watcher.h" 74 #include "chrome/browser/user_style_sheet_watcher.h"
75 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" 75 #include "chrome/browser/visitedlink/visitedlink_event_listener.h"
76 #include "chrome/browser/visitedlink/visitedlink_master.h" 76 #include "chrome/browser/visitedlink/visitedlink_master.h"
77 #include "chrome/browser/web_resource/promo_resource_service.h" 77 #include "chrome/browser/web_resource/promo_resource_service.h"
78 #include "chrome/browser/webdata/web_data_service.h" 78 #include "chrome/browser/webdata/web_data_service.h"
79 #include "chrome/common/chrome_constants.h" 79 #include "chrome/common/chrome_constants.h"
80 #include "chrome/common/chrome_paths.h" 80 #include "chrome/common/chrome_paths.h"
81 #include "chrome/common/chrome_paths_internal.h" 81 #include "chrome/common/chrome_paths_internal.h"
82 #include "chrome/common/chrome_switches.h" 82 #include "chrome/common/chrome_switches.h"
83 #include "chrome/common/extensions/extension_permission_set.h" 83 #include "chrome/common/extensions/extension_permission_set.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698