summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-28 20:31:58 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-28 20:31:58 +0000
commitfae20799882ef797ae9cb5a169c3a60680fa66c2 (patch)
treeaa54776c6e6b1b95fb1ad7737440c82c022eff01 /chrome/browser/dom_ui
parent419834aa659b728039d8dd398f7156b823f572d8 (diff)
downloadchromium_src-fae20799882ef797ae9cb5a169c3a60680fa66c2.zip
chromium_src-fae20799882ef797ae9cb5a169c3a60680fa66c2.tar.gz
chromium_src-fae20799882ef797ae9cb5a169c3a60680fa66c2.tar.bz2
First of several patches to get rid of MessageLoop caching now that we have ChromeThread::PostTask.
BUG=25354 Review URL: http://codereview.chromium.org/342020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/downloads_dom_handler.cc4
-rw-r--r--chrome/browser/dom_ui/downloads_ui.cc5
-rw-r--r--chrome/browser/dom_ui/filebrowse_ui.cc18
-rw-r--r--chrome/browser/dom_ui/history_ui.cc18
-rw-r--r--chrome/browser/dom_ui/most_visited_handler.cc26
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc39
-rw-r--r--chrome/browser/dom_ui/print_ui.cc8
7 files changed, 64 insertions, 54 deletions
diff --git a/chrome/browser/dom_ui/downloads_dom_handler.cc b/chrome/browser/dom_ui/downloads_dom_handler.cc
index bdaddd7..7b77915 100644
--- a/chrome/browser/dom_ui/downloads_dom_handler.cc
+++ b/chrome/browser/dom_ui/downloads_dom_handler.cc
@@ -11,6 +11,7 @@
#include "base/thread.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/dom_ui/fileicon_source.h"
#include "chrome/browser/metrics/user_metrics.h"
@@ -51,7 +52,8 @@ DownloadsDOMHandler::DownloadsDOMHandler(DownloadManager* dlm)
: search_text_(),
download_manager_(dlm) {
// Create our fileicon data source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableMethod(&chrome_url_data_manager,
&ChromeURLDataManager::AddDataSource,
new FileIconSource()));
diff --git a/chrome/browser/dom_ui/downloads_ui.cc b/chrome/browser/dom_ui/downloads_ui.cc
index 3de6f5a..ee17102 100644
--- a/chrome/browser/dom_ui/downloads_ui.cc
+++ b/chrome/browser/dom_ui/downloads_ui.cc
@@ -9,7 +9,7 @@
#include "base/string_piece.h"
#include "base/thread.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/dom_ui/downloads_dom_handler.h"
#include "chrome/browser/download/download_manager.h"
@@ -132,7 +132,8 @@ DownloadsUI::DownloadsUI(TabContents* contents) : DOMUI(contents) {
DownloadsUIHTMLSource* html_source = new DownloadsUIHTMLSource();
// Set up the chrome://downloads/ source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
NewRunnableMethod(&chrome_url_data_manager,
&ChromeURLDataManager::AddDataSource,
html_source));
diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc
index eacf872..bcd0aff 100644
--- a/chrome/browser/dom_ui/filebrowse_ui.cc
+++ b/chrome/browser/dom_ui/filebrowse_ui.cc
@@ -14,7 +14,7 @@
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/dom_ui_favicon_source.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/history/history_types.h"
@@ -133,10 +133,12 @@ FileBrowseHandler::~FileBrowseHandler() {
DOMMessageHandler* FileBrowseHandler::Attach(DOMUI* dom_ui) {
// Create our favicon data source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- new DOMUIFavIconSource(dom_ui->GetProfile())));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new DOMUIFavIconSource(dom_ui->GetProfile())));
return DOMMessageHandler::Attach(dom_ui);
}
@@ -248,8 +250,10 @@ FileBrowseUI::FileBrowseUI(TabContents* contents) : DOMUI(contents) {
FileBrowseUIHTMLSource* html_source = new FileBrowseUIHTMLSource();
// Set up the chrome://filebrowse/ source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
&ChromeURLDataManager::AddDataSource,
html_source));
}
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index 7c2b916..5e78bbe 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -14,7 +14,7 @@
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/dom_ui_favicon_source.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/history/history_types.h"
@@ -110,10 +110,12 @@ BrowsingHistoryHandler::~BrowsingHistoryHandler() {
DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) {
// Create our favicon data source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- new DOMUIFavIconSource(dom_ui->GetProfile())));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new DOMUIFavIconSource(dom_ui->GetProfile())));
// Get notifications when history is cleared.
registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
@@ -368,8 +370,10 @@ HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) {
HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource();
// Set up the chrome://history/ source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
&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 4c3c3f3..0142c18 100644
--- a/chrome/browser/dom_ui/most_visited_handler.cc
+++ b/chrome/browser/dom_ui/most_visited_handler.cc
@@ -9,11 +9,11 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "base/values.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/dom_ui/dom_ui_favicon_source.h"
#include "chrome/browser/dom_ui/dom_ui_thumbnail_source.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/page_usage_data.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/profile.h"
@@ -55,19 +55,17 @@ DOMMessageHandler* MostVisitedHandler::Attach(DOMUI* dom_ui) {
GetMutableDictionary(prefs::kNTPMostVisitedURLsBlacklist);
pinned_urls_ = dom_ui->GetProfile()->GetPrefs()->
GetMutableDictionary(prefs::kNTPMostVisitedPinnedURLs);
- // Set up our sources for thumbnail and favicon data. Since we may be in
- // testing mode with no I/O thread, only add our handler when an I/O thread
- // exists. Ownership is passed to the ChromeURLDataManager.
- if (g_browser_process->io_thread()) {
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- new DOMUIThumbnailSource(dom_ui->GetProfile())));
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- new DOMUIFavIconSource(dom_ui->GetProfile())));
- }
+ // Set up our sources for thumbnail and favicon data.
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(&chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new DOMUIThumbnailSource(dom_ui->GetProfile())));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(&chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new DOMUIFavIconSource(dom_ui->GetProfile())));
// Get notifications when history is cleared.
registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 76c44ae..6d34031 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -18,7 +18,7 @@
#include "base/string_piece.h"
#include "base/thread.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/dom_ui_theme_source.h"
#include "chrome/browser/dom_ui/most_visited_handler.h"
#include "chrome/browser/dom_ui/new_tab_page_sync_handler.h"
@@ -548,9 +548,10 @@ NewTabUI::NewTabUI(TabContents* contents)
IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource(
GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar));
-
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
&ChromeURLDataManager::AddDataSource,
html_source));
} else {
@@ -569,15 +570,14 @@ NewTabUI::NewTabUI(TabContents* contents)
AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this));
- // In testing mode there may not be an I/O thread.
- if (g_browser_process->io_thread()) {
- InitializeCSSCaches();
- NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile());
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- html_source));
- }
+ InitializeCSSCaches();
+ NewTabHTMLSource* html_source = new NewTabHTMLSource(GetProfile());
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ html_source));
}
// Listen for theme installation.
@@ -614,13 +614,12 @@ void NewTabUI::Observe(NotificationType type,
}
void NewTabUI::InitializeCSSCaches() {
- // In testing mode there may not be an I/O thread.
- if (g_browser_process->io_thread()) {
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- new DOMUIThemeSource(GetProfile())));
- }
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new DOMUIThemeSource(GetProfile())));
}
// static
diff --git a/chrome/browser/dom_ui/print_ui.cc b/chrome/browser/dom_ui/print_ui.cc
index 56514f9a..3821b98 100644
--- a/chrome/browser/dom_ui/print_ui.cc
+++ b/chrome/browser/dom_ui/print_ui.cc
@@ -9,7 +9,7 @@
#include "base/message_loop.h"
#include "base/thread.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/url_constants.h"
@@ -26,8 +26,10 @@ PrintUI::PrintUI(TabContents* contents) : DOMUI(contents) {
PrintUIHTMLSource* html_source = new PrintUIHTMLSource();
// Set up the print:url source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ &chrome_url_data_manager,
&ChromeURLDataManager::AddDataSource,
html_source));
}