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

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: Add files 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"
74 #include "chrome/browser/user_style_sheet_watcher.h" 73 #include "chrome/browser/user_style_sheet_watcher.h"
75 #include "chrome/browser/visitedlink/visitedlink_event_listener.h" 74 #include "chrome/browser/visitedlink/visitedlink_event_listener.h"
76 #include "chrome/browser/visitedlink/visitedlink_master.h" 75 #include "chrome/browser/visitedlink/visitedlink_master.h"
77 #include "chrome/browser/web_resource/promo_resource_service.h" 76 #include "chrome/browser/web_resource/promo_resource_service.h"
78 #include "chrome/browser/webdata/web_data_service.h" 77 #include "chrome/browser/webdata/web_data_service.h"
79 #include "chrome/common/chrome_constants.h" 78 #include "chrome/common/chrome_constants.h"
80 #include "chrome/common/chrome_paths.h" 79 #include "chrome/common/chrome_paths.h"
81 #include "chrome/common/chrome_paths_internal.h" 80 #include "chrome/common/chrome_paths_internal.h"
82 #include "chrome/common/chrome_switches.h" 81 #include "chrome/common/chrome_switches.h"
83 #include "chrome/common/extensions/extension_permission_set.h" 82 #include "chrome/common/extensions/extension_permission_set.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 568 }
570 569
571 void ProfileImpl::InitRegisteredProtocolHandlers() { 570 void ProfileImpl::InitRegisteredProtocolHandlers() {
572 if (protocol_handler_registry_) 571 if (protocol_handler_registry_)
573 return; 572 return;
574 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, 573 protocol_handler_registry_ = new ProtocolHandlerRegistry(this,
575 new ProtocolHandlerRegistry::Delegate()); 574 new ProtocolHandlerRegistry::Delegate());
576 protocol_handler_registry_->Load(); 575 protocol_handler_registry_->Load();
577 } 576 }
578 577
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() { 578 FilePath ProfileImpl::last_selected_directory() {
586 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); 579 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
587 } 580 }
588 581
589 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 582 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
590 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 583 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
591 } 584 }
592 585
593 ProfileImpl::~ProfileImpl() { 586 ProfileImpl::~ProfileImpl() {
594 NotificationService::current()->Notify( 587 NotificationService::current()->Notify(
595 NotificationType::PROFILE_DESTROYED, 588 NotificationType::PROFILE_DESTROYED,
596 Source<Profile>(this), 589 Source<Profile>(this),
597 NotificationService::NoDetails()); 590 NotificationService::NoDetails());
598 591
599 StopCreateSessionServiceTimer(); 592 StopCreateSessionServiceTimer();
600 593
594 // Remove pref observers
595 pref_change_registrar_.RemoveAll();
596
601 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); 597 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
602 598
603 if (clear_local_state_on_exit_) { 599 if (clear_local_state_on_exit_) {
604 BrowserThread::PostTask( 600 BrowserThread::PostTask(
605 BrowserThread::FILE, FROM_HERE, 601 BrowserThread::FILE, FROM_HERE,
606 NewRunnableFunction(&BrowsingDataRemover::ClearGearsData, path_)); 602 NewRunnableFunction(&BrowsingDataRemover::ClearGearsData, path_));
607 } 603 }
608 604
609 // DownloadManager is lazily created, so check before accessing it. 605 // DownloadManager is lazily created, so check before accessing it.
610 if (download_manager_.get()) { 606 if (download_manager_.get()) {
611 // The download manager queries the history system and should be shut down 607 // 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. 608 // before the history is shut down so it can properly cancel all requests.
613 download_manager_->Shutdown(); 609 download_manager_->Shutdown();
614 download_manager_ = NULL; 610 download_manager_ = NULL;
615 } 611 }
616 612
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. 613 // The sync service needs to be deleted before the services it calls.
624 sync_service_.reset(); 614 sync_service_.reset();
625 615
626 // Password store uses WebDB, shut it down before the WebDB has been shutdown. 616 // Password store uses WebDB, shut it down before the WebDB has been shutdown.
627 if (password_store_.get()) 617 if (password_store_.get())
628 password_store_->Shutdown(); 618 password_store_->Shutdown();
629 619
630 // Both HistoryService and WebDataService maintain threads for background 620 // Both HistoryService and WebDataService maintain threads for background
631 // processing. Its possible each thread still has tasks on it that have 621 // 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 622 // 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()) 1632 if (!prerender::PrerenderManager::IsPrerenderingPossible())
1643 return NULL; 1633 return NULL;
1644 if (!prerender_manager_.get()) { 1634 if (!prerender_manager_.get()) {
1645 CHECK(g_browser_process->prerender_tracker()); 1635 CHECK(g_browser_process->prerender_tracker());
1646 prerender_manager_.reset( 1636 prerender_manager_.reset(
1647 new prerender::PrerenderManager( 1637 new prerender::PrerenderManager(
1648 this, g_browser_process->prerender_tracker())); 1638 this, g_browser_process->prerender_tracker()));
1649 } 1639 }
1650 return prerender_manager_.get(); 1640 return prerender_manager_.get();
1651 } 1641 }
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