diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 19:58:06 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 19:58:06 +0000 |
commit | 5c4c7402c5264a38aa3a25e0e17caaf3222e5a61 (patch) | |
tree | 667cdde7c423e2956d2163ab31639d82c60f54b6 /chrome/browser | |
parent | b56e068deff08469f2f36c30a808de60fa07a31a (diff) | |
download | chromium_src-5c4c7402c5264a38aa3a25e0e17caaf3222e5a61.zip chromium_src-5c4c7402c5264a38aa3a25e0e17caaf3222e5a61.tar.gz chromium_src-5c4c7402c5264a38aa3a25e0e17caaf3222e5a61.tar.bz2 |
Convert chrome_url_data_manager (previously a global) into a Singleton. This
is just cleanup.
Take 2 with a fix in sync code.
TBR=evanm
Review URL: http://codereview.chromium.org/350007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30622 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 2 | ||||
-rw-r--r-- | chrome/browser/dom_ui/chrome_url_data_manager.cc | 28 | ||||
-rw-r--r-- | chrome/browser/dom_ui/chrome_url_data_manager.h | 3 | ||||
-rw-r--r-- | chrome/browser/dom_ui/downloads_dom_handler.cc | 3 | ||||
-rw-r--r-- | chrome/browser/dom_ui/downloads_ui.cc | 3 | ||||
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.cc | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/history_ui.cc | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/most_visited_handler.cc | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 7 | ||||
-rw-r--r-- | chrome/browser/dom_ui/print_ui.cc | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_wizard.cc | 3 |
12 files changed, 38 insertions, 32 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 428a9d2..370cfa0 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -568,7 +568,7 @@ AboutSource::AboutSource() // Add us to the global URL handler on the IO thread. g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, this)); } diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc index 2f2959a..3da06c1 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.cc +++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc @@ -8,6 +8,7 @@ #include "base/file_util.h" #include "base/message_loop.h" #include "base/path_service.h" +#include "base/singleton.h" #include "base/string_util.h" #include "base/thread.h" #include "base/values.h" @@ -30,9 +31,6 @@ // TODO(glen): Choose a better location for this. static const char kChromeURLScheme[] = "chrome"; -// The single global instance of ChromeURLDataManager. -ChromeURLDataManager chrome_url_data_manager; - // URLRequestChromeJob is a URLRequestJob that manages running chrome-internal // resource requests asynchronously. // It hands off URL requests to ChromeURLDataManager, which asynchronously @@ -105,9 +103,10 @@ void RegisterURLRequestChromeJob() { // all features of in-process Web Inspector and Console Debugger. For the // time being we need to serve the same content from chrome://inspector // for the Console Debugger and in-process Web Inspector. - chrome_url_data_manager.AddFileSource("inspector", inspector_dir); - chrome_url_data_manager.AddFileSource(chrome::kChromeUIDevToolsHost, - inspector_dir); + Singleton<ChromeURLDataManager>()->AddFileSource("inspector", + inspector_dir); + Singleton<ChromeURLDataManager>()->AddFileSource( + chrome::kChromeUIDevToolsHost, inspector_dir); } URLRequest::RegisterProtocolFactory(kChromeURLScheme, @@ -119,8 +118,9 @@ void RegisterURLRequestChromeJob() { void UnregisterURLRequestChromeJob() { FilePath inspector_dir; if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) { - chrome_url_data_manager.RemoveFileSource("inspector"); - chrome_url_data_manager.RemoveFileSource(chrome::kChromeUIDevToolsHost); + Singleton<ChromeURLDataManager>()->RemoveFileSource("inspector"); + Singleton<ChromeURLDataManager>()->RemoveFileSource( + chrome::kChromeUIDevToolsHost); } } @@ -164,8 +164,8 @@ bool ChromeURLDataManager::URLToFilePath(const GURL& url, URLToRequest(url, &source_name, &relative_path); FileSourceMap::const_iterator i( - chrome_url_data_manager.file_sources_.find(source_name)); - if (i == chrome_url_data_manager.file_sources_.end()) + Singleton<ChromeURLDataManager>()->file_sources_.find(source_name)); + if (i == Singleton<ChromeURLDataManager>()->file_sources_.end()) return false; *file_path = i->second.AppendASCII(relative_path); @@ -275,7 +275,7 @@ void ChromeURLDataManager::DataSource::SendResponse( RefCountedMemory* bytes) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::DataAvailable, request_id, scoped_refptr<RefCountedMemory>(bytes))); } @@ -350,7 +350,7 @@ URLRequestChromeJob::URLRequestChromeJob(URLRequest* request) } URLRequestChromeJob::~URLRequestChromeJob() { - CHECK(!chrome_url_data_manager.HasPendingJob(this)); + CHECK(!Singleton<ChromeURLDataManager>()->HasPendingJob(this)); } void URLRequestChromeJob::Start() { @@ -361,7 +361,7 @@ void URLRequestChromeJob::Start() { } void URLRequestChromeJob::Kill() { - chrome_url_data_manager.RemoveRequest(this); + Singleton<ChromeURLDataManager>()->RemoveRequest(this); } bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { @@ -421,7 +421,7 @@ void URLRequestChromeJob::StartAsync() { if (!request_) return; - if (chrome_url_data_manager.StartRequest(request_->url(), this)) { + if (Singleton<ChromeURLDataManager>()->StartRequest(request_->url(), this)) { NotifyHeadersComplete(); } else { NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.h b/chrome/browser/dom_ui/chrome_url_data_manager.h index bb1a82c..c159190 100644 --- a/chrome/browser/dom_ui/chrome_url_data_manager.h +++ b/chrome/browser/dom_ui/chrome_url_data_manager.h @@ -158,9 +158,6 @@ template <> struct RunnableMethodTraits<ChromeURLDataManager> { void ReleaseCallee(ChromeURLDataManager* manager) {} }; -// The single global instance of ChromeURLDataManager. -extern ChromeURLDataManager chrome_url_data_manager; - // Register our special URL handler under our special URL scheme. // Must be done once at startup. void RegisterURLRequestChromeJob(); diff --git a/chrome/browser/dom_ui/downloads_dom_handler.cc b/chrome/browser/dom_ui/downloads_dom_handler.cc index 7b77915..6799475 100644 --- a/chrome/browser/dom_ui/downloads_dom_handler.cc +++ b/chrome/browser/dom_ui/downloads_dom_handler.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "base/basictypes.h" #include "base/i18n/time_formatting.h" +#include "base/singleton.h" #include "base/string_piece.h" #include "base/thread.h" #include "base/values.h" @@ -54,7 +55,7 @@ DownloadsDOMHandler::DownloadsDOMHandler(DownloadManager* dlm) // Create our fileicon data source. ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, new FileIconSource())); } diff --git a/chrome/browser/dom_ui/downloads_ui.cc b/chrome/browser/dom_ui/downloads_ui.cc index ee17102..5df2ac6 100644 --- a/chrome/browser/dom_ui/downloads_ui.cc +++ b/chrome/browser/dom_ui/downloads_ui.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/singleton.h" #include "base/string_piece.h" #include "base/thread.h" #include "base/values.h" @@ -134,7 +135,7 @@ DownloadsUI::DownloadsUI(TabContents* contents) : DOMUI(contents) { // Set up the chrome://downloads/ source. ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, html_source)); } diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index bcd0aff..a399aa5 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/logging.h" #include "base/message_loop.h" +#include "base/singleton.h" #include "base/string_piece.h" #include "base/string_util.h" #include "base/thread.h" @@ -136,7 +137,7 @@ DOMMessageHandler* FileBrowseHandler::Attach(DOMUI* dom_ui) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, new DOMUIFavIconSource(dom_ui->GetProfile()))); @@ -253,7 +254,7 @@ FileBrowseUI::FileBrowseUI(TabContents* contents) : DOMUI(contents) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, html_source)); } diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc index 5e78bbe..e852ee9 100644 --- a/chrome/browser/dom_ui/history_ui.cc +++ b/chrome/browser/dom_ui/history_ui.cc @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/i18n/time_formatting.h" #include "base/message_loop.h" +#include "base/singleton.h" #include "base/string_piece.h" #include "base/string_util.h" #include "base/thread.h" @@ -113,7 +114,7 @@ DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, new DOMUIFavIconSource(dom_ui->GetProfile()))); @@ -373,7 +374,7 @@ HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, html_source)); } diff --git a/chrome/browser/dom_ui/most_visited_handler.cc b/chrome/browser/dom_ui/most_visited_handler.cc index 7aa82f8..a0e52bc 100644 --- a/chrome/browser/dom_ui/most_visited_handler.cc +++ b/chrome/browser/dom_ui/most_visited_handler.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/md5.h" +#include "base/singleton.h" #include "base/string_util.h" #include "base/thread.h" #include "base/values.h" @@ -60,7 +61,7 @@ DOMMessageHandler* MostVisitedHandler::Attach(DOMUI* dom_ui) { new DOMUIThumbnailSource(dom_ui->GetProfile()); bool posted = ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, thumbnail_src)); if (!posted) { thumbnail_src->AddRef(); @@ -70,7 +71,7 @@ DOMMessageHandler* MostVisitedHandler::Attach(DOMUI* dom_ui) { DOMUIFavIconSource* favicon_src = new DOMUIFavIconSource(dom_ui->GetProfile()); posted = ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, favicon_src)); if (!posted) { favicon_src->AddRef(); diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 02594fe..d6aad59 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -15,6 +15,7 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/histogram.h" +#include "base/singleton.h" #include "base/string_piece.h" #include "base/thread.h" #include "chrome/browser/browser.h" @@ -552,7 +553,7 @@ NewTabUI::NewTabUI(TabContents* contents) ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, html_source)); } else { @@ -575,7 +576,7 @@ NewTabUI::NewTabUI(TabContents* contents) bool posted = ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, html_source)); if (!posted) { @@ -622,7 +623,7 @@ void NewTabUI::InitializeCSSCaches() { bool posted = ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, theme)); if (!posted) { diff --git a/chrome/browser/dom_ui/print_ui.cc b/chrome/browser/dom_ui/print_ui.cc index 3821b98..4abc592 100644 --- a/chrome/browser/dom_ui/print_ui.cc +++ b/chrome/browser/dom_ui/print_ui.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/message_loop.h" +#include "base/singleton.h" #include "base/thread.h" #include "base/values.h" #include "chrome/browser/chrome_thread.h" @@ -29,7 +30,7 @@ PrintUI::PrintUI(TabContents* contents) : DOMUI(contents) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, + Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, html_source)); } diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 7ca742e..06b9046 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -558,7 +558,8 @@ ExtensionsUI::ExtensionsUI(TabContents* contents) : DOMUI(contents) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod( - &chrome_url_data_manager, &ChromeURLDataManager::AddDataSource, + Singleton<ChromeURLDataManager>().get(), + &ChromeURLDataManager::AddDataSource, html_source)); } diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc index e738b14..35e05f5 100644 --- a/chrome/browser/sync/sync_setup_wizard.cc +++ b/chrome/browser/sync/sync_setup_wizard.cc @@ -6,6 +6,7 @@ #include "app/resource_bundle.h" #include "base/message_loop.h" +#include "base/singleton.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/browser/browser_process.h" @@ -141,7 +142,7 @@ SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service) if (g_browser_process && g_browser_process->io_thread()) { // Add our network layer data source for 'cloudy' URLs. g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(&chrome_url_data_manager, + NewRunnableMethod(Singleton<ChromeURLDataManager>().get(), &ChromeURLDataManager::AddDataSource, new SyncResourcesSource())); } |