summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/url_request_automation_job.cc3
-rw-r--r--chrome/browser/browser_init.cc17
-rw-r--r--chrome/browser/browsing_data_remover.cc11
-rw-r--r--chrome/browser/browsing_data_remover.h4
-rw-r--r--chrome/browser/chrome_thread.cc3
-rw-r--r--chrome/browser/chrome_thread.h6
-rw-r--r--chrome/browser/google_update.cc11
-rw-r--r--chrome/browser/importer/importer.cc21
-rw-r--r--chrome/browser/importer/importer.h8
-rw-r--r--chrome/browser/importer/importer_bridge.cc67
-rw-r--r--chrome/browser/importer/importer_bridge.h6
-rw-r--r--chrome/browser/importer/importer_unittest.cc12
-rw-r--r--chrome/browser/importer/toolbar_importer.cc15
-rw-r--r--chrome/browser/jumplist.cc12
-rw-r--r--chrome/browser/login_prompt.cc11
-rw-r--r--chrome/browser/login_prompt.h8
-rw-r--r--chrome/browser/login_prompt_gtk.cc89
-rw-r--r--chrome/browser/login_prompt_mac.mm91
-rw-r--r--chrome/browser/login_prompt_win.cc86
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc4
-rw-r--r--chrome/browser/shell_integration.cc40
-rw-r--r--chrome/browser/shell_integration.h4
-rw-r--r--chrome/browser/ssl/ssl_cert_error_handler.cc5
-rw-r--r--chrome/browser/ssl/ssl_cert_error_handler.h3
-rw-r--r--chrome/browser/ssl/ssl_client_auth_handler.cc21
-rw-r--r--chrome/browser/ssl/ssl_client_auth_handler.h8
-rw-r--r--chrome/browser/ssl/ssl_error_handler.cc62
-rw-r--r--chrome/browser/ssl/ssl_error_handler.h9
-rw-r--r--chrome/browser/ssl/ssl_manager.cc11
-rw-r--r--chrome/browser/ssl/ssl_manager.h4
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc3
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h3
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc7
-rw-r--r--chrome/browser/task_manager.cc18
-rw-r--r--chrome/browser/task_manager.h3
-rw-r--r--chrome/browser/task_manager_resource_providers.cc10
-rw-r--r--chrome/browser/task_manager_resource_providers.h2
-rw-r--r--chrome/browser/views/shell_dialogs_win.cc58
39 files changed, 365 insertions, 397 deletions
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc
index 03c0774..7b396f0 100644
--- a/chrome/browser/automation/url_request_automation_job.cc
+++ b/chrome/browser/automation/url_request_automation_job.cc
@@ -331,8 +331,7 @@ void URLRequestAutomationJob::OnRequestEnd(
// certificate, but I'm not sure if all implementations expect it.
// if (status.status() == URLRequestStatus::FAILED &&
// net::IsCertificateError(status.os_error()) && request_->delegate()) {
- // request_->delegate()->OnSSLCertificateError(request_, status.os_error(),
- // NULL);
+ // request_->delegate()->OnSSLCertificateError(request_, status.os_error());
// }
DisconnectFromMessageFilter();
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 45b4ab4..8d74710 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -9,11 +9,11 @@
#include "base/event_recorder.h"
#include "base/path_service.h"
#include "base/sys_info.h"
-#include "base/thread.h"
#include "chrome/browser/automation/automation_provider.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_creator.h"
#include "chrome/browser/first_run.h"
@@ -174,17 +174,18 @@ class NotifyNotDefaultBrowserTask : public Task {
class CheckDefaultBrowserTask : public Task {
public:
- explicit CheckDefaultBrowserTask(MessageLoop* ui_loop) : ui_loop_(ui_loop) {
+ CheckDefaultBrowserTask() {
}
virtual void Run() {
- if (!ShellIntegration::IsDefaultBrowser())
- ui_loop_->PostTask(FROM_HERE, new NotifyNotDefaultBrowserTask());
+ if (ShellIntegration::IsDefaultBrowser())
+ return;
+
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE, new NotifyNotDefaultBrowserTask());
}
private:
- MessageLoop* ui_loop_;
-
DISALLOW_COPY_AND_ASSIGN(CheckDefaultBrowserTask);
};
@@ -674,8 +675,8 @@ void BrowserInit::LaunchWithProfile::CheckDefaultBrowser(Profile* profile) {
FirstRun::IsChromeFirstRun()) {
return;
}
- g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
- new CheckDefaultBrowserTask(MessageLoop::current()));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE, new CheckDefaultBrowserTask());
}
bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index aef400a..6db8543 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -141,8 +141,7 @@ void BrowsingDataRemover::Remove(int remove_mask) {
&BrowsingDataRemover::ClearCacheOnIOThread,
profile_->GetRequestContext(),
delete_begin_,
- delete_end_,
- MessageLoop::current()));
+ delete_end_));
}
NotifyAndDeleteIfDone();
@@ -222,8 +221,7 @@ void BrowsingDataRemover::ClearedCache() {
void BrowsingDataRemover::ClearCacheOnIOThread(
URLRequestContextGetter* context_getter,
base::Time delete_begin,
- base::Time delete_end,
- MessageLoop* ui_loop) {
+ base::Time delete_end) {
// This function should be called on the IO thread.
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
@@ -256,6 +254,7 @@ void BrowsingDataRemover::ClearCacheOnIOThread(
}
// Notify the UI thread that we are done.
- ui_loop->PostTask(FROM_HERE, NewRunnableMethod(
- this, &BrowsingDataRemover::ClearedCache));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &BrowsingDataRemover::ClearedCache));
}
diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h
index 27527b8..73d5e74 100644
--- a/chrome/browser/browsing_data_remover.h
+++ b/chrome/browser/browsing_data_remover.h
@@ -10,7 +10,6 @@
#include "chrome/browser/cancelable_request.h"
#include "chrome/common/notification_registrar.h"
-class MessageLoop;
class Profile;
class URLRequestContextGetter;
@@ -89,8 +88,7 @@ class BrowsingDataRemover : public NotificationObserver {
// Invoked on the IO thread to delete from the cache.
void ClearCacheOnIOThread(URLRequestContextGetter* context_getter,
base::Time delete_begin,
- base::Time delete_end,
- MessageLoop* ui_loop);
+ base::Time delete_end);
// Calculate the begin time for the deletion range specified by |time_period|.
base::Time CalculateBeginDeleteTime(TimePeriod time_period);
diff --git a/chrome/browser/chrome_thread.cc b/chrome/browser/chrome_thread.cc
index 576ac77..f05fb68 100644
--- a/chrome/browser/chrome_thread.cc
+++ b/chrome/browser/chrome_thread.cc
@@ -54,9 +54,6 @@ ChromeThread::~ChromeThread() {
// static
bool ChromeThread::CurrentlyOn(ID identifier) {
- // chrome_threads_[identifier] will be NULL if none is running. This is often
- // true when running under unit tests. This behavior actually works out
- // pretty conveniently but it's worth noting here.
AutoLock lock(lock_);
DCHECK(identifier >= 0 && identifier < ID_COUNT);
return chrome_threads_[identifier] &&
diff --git a/chrome/browser/chrome_thread.h b/chrome/browser/chrome_thread.h
index 8f64dde..0e84b59 100644
--- a/chrome/browser/chrome_thread.h
+++ b/chrome/browser/chrome_thread.h
@@ -113,12 +113,6 @@ class ChromeThread : public base::Thread {
// Callable on any thread. Returns whether you're currently on a particular
// thread.
- //
- // WARNING:
- // When running under unit-tests, this will return true if you're on the
- // main thread and the thread ID you pass in isn't running. This is
- // normally the correct behavior because you want to ignore these asserts
- // unless you've specifically spun up the threads, but be mindful of it.
static bool CurrentlyOn(ID identifier);
// If the current message loop is one of the known threads, returns true and
diff --git a/chrome/browser/google_update.cc b/chrome/browser/google_update.cc
index 83b8c14..b56ea1e 100644
--- a/chrome/browser/google_update.cc
+++ b/chrome/browser/google_update.cc
@@ -15,7 +15,7 @@
#include "base/thread.h"
#include "base/win_util.h"
#include "chrome/app/client_util.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
@@ -212,10 +212,11 @@ GoogleUpdate::~GoogleUpdate() {
void GoogleUpdate::CheckForUpdate(bool install_if_newer, Window* window) {
// We need to shunt this request over to InitiateGoogleUpdateCheck and have
// it run in the file thread.
- MessageLoop* file_loop = g_browser_process->file_thread()->message_loop();
- file_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
- &GoogleUpdate::InitiateGoogleUpdateCheck,
- install_if_newer, window, MessageLoop::current()));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &GoogleUpdate::InitiateGoogleUpdateCheck, install_if_newer,
+ window, MessageLoop::current()));
}
// Adds/removes a listener. Only one listener is maintained at the moment.
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index e2d30f1..892d2aa 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -11,8 +11,8 @@
#include "base/thread.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_instance.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/importer/firefox_profile_lock.h"
#include "chrome/browser/importer/importer_bridge.h"
#include "chrome/browser/renderer_host/site_instance.h"
@@ -394,21 +394,6 @@ ImporterHost::ImporterHost()
observer_(NULL),
task_(NULL),
importer_(NULL),
- file_loop_(g_browser_process->file_thread()->message_loop()),
- waiting_for_bookmarkbar_model_(false),
- installed_bookmark_observer_(false),
- is_source_readable_(true),
- headless_(false),
- parent_window_(NULL) {
- importer_list_.DetectSourceProfiles();
-}
-
-ImporterHost::ImporterHost(MessageLoop* file_loop)
- : profile_(NULL),
- observer_(NULL),
- task_(NULL),
- importer_(NULL),
- file_loop_(file_loop),
waiting_for_bookmarkbar_model_(false),
installed_bookmark_observer_(false),
is_source_readable_(true),
@@ -517,7 +502,7 @@ void ImporterHost::StartImportSettings(const ProfileInfo& profile_info,
}
importer_->set_import_to_bookmark_bar(import_to_bookmark_bar);
scoped_refptr<ImporterBridge> bridge(
- new InProcessImporterBridge(writer_.get(), file_loop_, this));
+ new InProcessImporterBridge(writer_.get(), this));
task_ = NewRunnableMethod(importer_, &Importer::StartImport,
profile_info, items, bridge);
@@ -605,7 +590,7 @@ void ImporterHost::InvokeTaskIfDone() {
if (waiting_for_bookmarkbar_model_ || !registrar_.IsEmpty() ||
!is_source_readable_)
return;
- file_loop_->PostTask(FROM_HERE, task_);
+ ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, task_);
}
void ImporterHost::ImportItemStarted(ImportItem item) {
diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h
index 6daafbb..35e2959 100644
--- a/chrome/browser/importer/importer.h
+++ b/chrome/browser/importer/importer.h
@@ -21,7 +21,6 @@
#include "googleurl/src/gurl.h"
class ImporterBridge;
-class MessageLoop;
class TemplateURL;
struct IE7PasswordInfo;
@@ -158,10 +157,6 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
ImporterHost();
~ImporterHost();
- // This constructor only be used by unit-tests, where file thread does not
- // exist.
- explicit ImporterHost(MessageLoop* file_loop);
-
// BookmarkModelObserver methods.
virtual void Loaded(BookmarkModel* model);
virtual void BookmarkNodeMoved(BookmarkModel* model,
@@ -293,9 +288,6 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
// The importer used in the task;
Importer* importer_;
- // The message loop for reading the source profiles.
- MessageLoop* file_loop_;
-
// True if we're waiting for the model to finish loading.
bool waiting_for_bookmarkbar_model_;
diff --git a/chrome/browser/importer/importer_bridge.cc b/chrome/browser/importer/importer_bridge.cc
index dfe98fd..eddb026 100644
--- a/chrome/browser/importer/importer_bridge.cc
+++ b/chrome/browser/importer/importer_bridge.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/importer/importer_bridge.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/importer/importer.h"
#if defined(OS_WIN)
#include "chrome/browser/password_manager/ie7_password.h"
@@ -12,78 +12,89 @@
#include "webkit/glue/password_form.h"
InProcessImporterBridge::InProcessImporterBridge(ProfileWriter* writer,
- MessageLoop* delegate_loop,
ImporterHost* host)
- : ImporterBridge(writer, delegate_loop, host),
- main_loop_(MessageLoop::current()),
- delegate_loop_(NULL) {
+ : ImporterBridge(writer, host) {
}
void InProcessImporterBridge::AddBookmarkEntries(
const std::vector<ProfileWriter::BookmarkEntry>& bookmarks,
const std::wstring& first_folder_name,
int options) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddBookmarkEntry, bookmarks, first_folder_name,
- options));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ writer_, &ProfileWriter::AddBookmarkEntry, bookmarks,
+ first_folder_name, options));
}
void InProcessImporterBridge::AddHomePage(const GURL &home_page) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddHomepage, home_page));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(writer_, &ProfileWriter::AddHomepage, home_page));
}
#if defined(OS_WIN)
void InProcessImporterBridge::AddIE7PasswordInfo(
const IE7PasswordInfo password_info) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddIE7PasswordInfo, password_info));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(writer_, &ProfileWriter::AddIE7PasswordInfo,
+ password_info));
}
#endif // OS_WIN
void InProcessImporterBridge::SetFavIcons(
const std::vector<history::ImportedFavIconUsage>& fav_icons) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddFavicons, fav_icons));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(writer_, &ProfileWriter::AddFavicons, fav_icons));
}
void InProcessImporterBridge::SetHistoryItems(
const std::vector<history::URLRow> &rows) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddHistoryPage, rows));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(writer_, &ProfileWriter::AddHistoryPage, rows));
}
void InProcessImporterBridge::SetKeywords(
const std::vector<TemplateURL*>& template_urls,
int default_keyword_index,
bool unique_on_host_and_path) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddKeywords, template_urls, default_keyword_index,
- unique_on_host_and_path));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ writer_, &ProfileWriter::AddKeywords, template_urls,
+ default_keyword_index, unique_on_host_and_path));
}
void InProcessImporterBridge::SetPasswordForm(
const webkit_glue::PasswordForm& form) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_,
- &ProfileWriter::AddPasswordForm, form));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(writer_, &ProfileWriter::AddPasswordForm, form));
}
void InProcessImporterBridge::NotifyItemStarted(ImportItem item) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_,
- &ImporterHost::ImportItemStarted, item));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(host_, &ImporterHost::ImportItemStarted, item));
}
void InProcessImporterBridge::NotifyItemEnded(ImportItem item) {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_,
- &ImporterHost::ImportItemEnded, item));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(host_, &ImporterHost::ImportItemEnded, item));
}
void InProcessImporterBridge::NotifyStarted() {
- main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_,
- &ImporterHost::ImportStarted));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(host_, &ImporterHost::ImportStarted));
}
void InProcessImporterBridge::NotifyEnded() {
- main_loop_->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
NewRunnableMethod(host_, &ImporterHost::ImportEnded));
}
diff --git a/chrome/browser/importer/importer_bridge.h b/chrome/browser/importer/importer_bridge.h
index 02a8d9a..d3660d7 100644
--- a/chrome/browser/importer/importer_bridge.h
+++ b/chrome/browser/importer/importer_bridge.h
@@ -19,10 +19,8 @@
class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> {
public:
ImporterBridge(ProfileWriter* writer,
- MessageLoop* delegate_loop,
ImporterHost* host)
: writer_(writer),
- delegate_loop_(delegate_loop),
host_(host) {
}
virtual ~ImporterBridge() {}
@@ -67,7 +65,6 @@ class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> {
friend class Toolbar5Importer;
ProfileWriter* writer_;
- MessageLoop* delegate_loop_;
ImporterHost* host_;
DISALLOW_COPY_AND_ASSIGN(ImporterBridge);
@@ -76,7 +73,6 @@ class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> {
class InProcessImporterBridge : public ImporterBridge {
public:
InProcessImporterBridge(ProfileWriter* writer,
- MessageLoop* delegate_loop,
ImporterHost* host);
// Methods inherited from ImporterBridge.
@@ -104,8 +100,6 @@ class InProcessImporterBridge : public ImporterBridge {
virtual void NotifyEnded();
private:
- MessageLoop* main_loop_;
- MessageLoop* delegate_loop_;
DISALLOW_COPY_AND_ASSIGN(InProcessImporterBridge);
};
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index e6d09af6..23b7220 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -18,6 +18,7 @@
#include "base/path_service.h"
#include "base/scoped_comptr_win.h"
#include "base/stl_util-inl.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/importer/ie_importer.h"
#include "chrome/browser/importer/importer.h"
#include "chrome/browser/importer/importer_bridge.h"
@@ -31,6 +32,9 @@ using webkit_glue::PasswordForm;
class ImporterTest : public testing::Test {
public:
+ ImporterTest()
+ : ui_thread_(ChromeThread::UI, &message_loop_),
+ file_thread_(ChromeThread::FILE, &message_loop_) {}
protected:
virtual void SetUp() {
// Creates a new profile in a new subdirectory in the temp directory.
@@ -84,7 +88,7 @@ class ImporterTest : public testing::Test {
profile_info.browser_type = FIREFOX3;
profile_info.app_path = app_path_;
profile_info.source_path = profile_path_;
- scoped_refptr<ImporterHost> host = new ImporterHost(loop);
+ scoped_refptr<ImporterHost> host = new ImporterHost();
host->SetObserver(observer);
int items = HISTORY | PASSWORDS | FAVORITES;
if (import_search_plugins)
@@ -96,6 +100,8 @@ class ImporterTest : public testing::Test {
}
MessageLoopForUI message_loop_;
+ ChromeThread ui_thread_;
+ ChromeThread file_thread_;
std::wstring test_path_;
std::wstring profile_path_;
std::wstring app_path_;
@@ -378,7 +384,7 @@ TEST_F(ImporterTest, IEImporter) {
// Starts to import the above settings.
MessageLoop* loop = MessageLoop::current();
- scoped_refptr<ImporterHost> host = new ImporterHost(loop);
+ scoped_refptr<ImporterHost> host = new ImporterHost();
TestObserver* observer = new TestObserver();
host->SetObserver(observer);
@@ -654,7 +660,7 @@ TEST_F(ImporterTest, Firefox2Importer) {
ASSERT_TRUE(file_util::CopyDirectory(data_path, search_engine_path, false));
MessageLoop* loop = MessageLoop::current();
- scoped_refptr<ImporterHost> host = new ImporterHost(loop);
+ scoped_refptr<ImporterHost> host = new ImporterHost();
FirefoxObserver* observer = new FirefoxObserver();
host->SetObserver(observer);
ProfileInfo profile_info;
diff --git a/chrome/browser/importer/toolbar_importer.cc b/chrome/browser/importer/toolbar_importer.cc
index 47a1cfd..50c6ae9 100644
--- a/chrome/browser/importer/toolbar_importer.cc
+++ b/chrome/browser/importer/toolbar_importer.cc
@@ -9,6 +9,7 @@
#include "app/l10n_util.h"
#include "base/string_util.h"
#include "base/rand_util.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/first_run.h"
#include "chrome/browser/importer/importer_bridge.h"
#include "chrome/browser/net/url_request_context_getter.h"
@@ -113,14 +114,12 @@ void Toolbar5Importer::Cancel() {
// If we are conducting network operations, post a message to the importer
// thread for synchronization.
- if (NULL != bridge_->delegate_loop_) {
- if (bridge_->delegate_loop_ != MessageLoop::current()) {
- bridge_->delegate_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &Toolbar5Importer::Cancel));
- } else {
- EndImport();
- }
+ if (ChromeThread::CurrentlyOn(ChromeThread::UI)) {
+ EndImport();
+ } else {
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &Toolbar5Importer::Cancel));
}
}
diff --git a/chrome/browser/jumplist.cc b/chrome/browser/jumplist.cc
index 4c55224..6a45201 100644
--- a/chrome/browser/jumplist.cc
+++ b/chrome/browser/jumplist.cc
@@ -22,7 +22,7 @@
#include "base/string_util.h"
#include "base/thread.h"
#include "base/win_util.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/favicon_service.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/page_usage_data.h"
@@ -731,12 +731,10 @@ void JumpList::OnFavIconDataAvailable(
// Finished Loading all fav icons needed by the application JumpList.
// We create a JumpListUpdateTask that creates icon files, and we post it to
// the file thread.
- Task* icon_task = new JumpListUpdateTask(icon_dir_,
- most_visited_pages_,
- recently_closed_pages_);
- MessageLoop* file_loop = g_browser_process->file_thread()->message_loop();
- if (file_loop)
- file_loop->PostTask(FROM_HERE, icon_task);
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ new JumpListUpdateTask(
+ icon_dir_, most_visited_pages_, recently_closed_pages_));
// Delete all items in these lists since we don't need these lists any longer.
most_visited_pages_.clear();
diff --git a/chrome/browser/login_prompt.cc b/chrome/browser/login_prompt.cc
index 7ef4e93..9641808 100644
--- a/chrome/browser/login_prompt.cc
+++ b/chrome/browser/login_prompt.cc
@@ -7,8 +7,7 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/lock.h"
-#include "base/message_loop.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
@@ -141,9 +140,9 @@ class LoginDialogTask : public Task {
// Public API
LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
- URLRequest* request,
- MessageLoop* ui_loop) {
- LoginHandler* handler = LoginHandler::Create(request, ui_loop);
- ui_loop->PostTask(FROM_HERE, new LoginDialogTask(auth_info, handler));
+ URLRequest* request) {
+ LoginHandler* handler = LoginHandler::Create(request);
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE, new LoginDialogTask(auth_info, handler));
return handler;
}
diff --git a/chrome/browser/login_prompt.h b/chrome/browser/login_prompt.h
index bcb63d8..da67c07 100644
--- a/chrome/browser/login_prompt.h
+++ b/chrome/browser/login_prompt.h
@@ -19,7 +19,6 @@ struct PasswordForm;
class ConstrainedWindow;
class GURL;
-class MessageLoop;
class PasswordManager;
class TabContents;
class URLRequest;
@@ -38,7 +37,7 @@ class LoginHandler {
public:
// Builds the platform specific LoginHandler. Used from within
// CreateLoginPrompt() which creates tasks.
- static LoginHandler* Create(URLRequest* request, MessageLoop* ui_loop);
+ static LoginHandler* Create(URLRequest* request);
// Initializes the underlying platform specific view.
virtual void BuildViewForPasswordManager(PasswordManager* manager,
@@ -84,15 +83,14 @@ class LoginNotificationDetails {
// Prompts the user for their username and password. This is designed to
// be called on the background (I/O) thread, in response to
// URLRequest::Delegate::OnAuthRequired. The prompt will be created
-// on the main UI thread via a call to ui_loop's InvokeLater, and will send the
+// on the main UI thread via a call to UI loop's InvokeLater, and will send the
// credentials back to the URLRequest on the calling thread.
// A LoginHandler object (which lives on the calling thread) is returned,
// which can be used to set or cancel authentication programmatically. The
// caller must invoke OnRequestCancelled() on this LoginHandler before
// destroying the URLRequest.
LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
- URLRequest* request,
- MessageLoop* ui_loop);
+ URLRequest* request);
// Helper to remove the ref from an URLRequest to the LoginHandler.
// Should only be called from the IO thread, since it accesses an URLRequest.
diff --git a/chrome/browser/login_prompt_gtk.cc b/chrome/browser/login_prompt_gtk.cc
index adb3f1a..ec67bab 100644
--- a/chrome/browser/login_prompt_gtk.cc
+++ b/chrome/browser/login_prompt_gtk.cc
@@ -7,7 +7,7 @@
#include <gtk/gtk.h>
#include "app/l10n_util.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/gtk/constrained_window_gtk.h"
#include "chrome/browser/login_model.h"
#include "chrome/browser/password_manager/password_manager.h"
@@ -34,12 +34,10 @@ class LoginHandlerGtk : public LoginHandler,
public ConstrainedWindowGtkDelegate,
public LoginModelObserver {
public:
- LoginHandlerGtk(URLRequest* request, MessageLoop* ui_loop)
+ LoginHandlerGtk(URLRequest* request)
: handled_auth_(false),
dialog_(NULL),
- ui_loop_(ui_loop),
request_(request),
- request_loop_(MessageLoop::current()),
password_manager_(NULL),
login_model_(NULL) {
DCHECK(request_) << "LoginHandlerGtk constructed with NULL request";
@@ -83,7 +81,7 @@ class LoginHandlerGtk : public LoginHandler,
// LoginHandler:
virtual void BuildViewForPasswordManager(PasswordManager* manager,
std::wstring explanation) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
root_.Own(gtk_vbox_new(NULL, gtk_util::kContentAreaBorder));
GtkWidget* label = gtk_label_new(WideToUTF8(explanation).c_str());
@@ -146,7 +144,7 @@ class LoginHandlerGtk : public LoginHandler,
}
virtual TabContents* GetTabContentsForLogin() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
return tab_util::GetTabContentsByID(render_process_host_id_,
tab_contents_id_);
@@ -164,28 +162,35 @@ class LoginHandlerGtk : public LoginHandler,
password_manager_->ProvisionallySavePassword(password_form_);
}
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::CloseContentsDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::SendNotifications));
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::SetAuthDeferred, username, password));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::CloseContentsDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::SetAuthDeferred, username,
+ password));
}
virtual void CancelAuth() {
if (WasAuthHandled(true))
return;
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::CloseContentsDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::SendNotifications));
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::CancelAuthDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::CloseContentsDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::CancelAuthDeferred));
}
virtual void OnRequestCancelled() {
- DCHECK(MessageLoop::current() == request_loop_) <<
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
"Why is OnRequestCancelled called from the UI thread?";
// Reference is no longer valid.
@@ -202,25 +207,27 @@ class LoginHandlerGtk : public LoginHandler,
virtual void DeleteDelegate() {
if (!WasAuthHandled(true)) {
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::CancelAuthDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerGtk::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::CancelAuthDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerGtk::SendNotifications));
}
SetModel(NULL);
// Delete this object once all InvokeLaters have been called.
- request_loop_->ReleaseSoon(FROM_HERE, this);
+ ChromeThread::ReleaseSoon(ChromeThread::IO, FROM_HERE, this);
}
private:
friend class LoginPrompt;
- // Calls SetAuth from the request_loop.
+ // Calls SetAuth from the IO loop.
void SetAuthDeferred(const std::wstring& username,
const std::wstring& password) {
- DCHECK(MessageLoop::current() == request_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (request_) {
request_->SetAuth(username, password);
@@ -228,9 +235,9 @@ class LoginHandlerGtk : public LoginHandler,
}
}
- // Calls CancelAuth from the request_loop.
+ // Calls CancelAuth from the IO loop.
void CancelAuthDeferred() {
- DCHECK(MessageLoop::current() == request_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (request_) {
request_->CancelAuth();
@@ -242,7 +249,7 @@ class LoginHandlerGtk : public LoginHandler,
// Closes the view_contents from the UI loop.
void CloseContentsDeferred() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// The hosting ConstrainedWindow may have been freed.
if (dialog_)
@@ -262,7 +269,7 @@ class LoginHandlerGtk : public LoginHandler,
// Notify observers that authentication is needed or received. The automation
// proxy uses this for testing.
void SendNotifications() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
NotificationService* service = NotificationService::current();
TabContents* requesting_contents = GetTabContentsForLogin();
@@ -284,7 +291,7 @@ class LoginHandlerGtk : public LoginHandler,
}
static void OnOKClicked(GtkButton *button, LoginHandlerGtk* handler) {
- DCHECK(MessageLoop::current() == handler->ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
handler->SetAuth(
UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(handler->username_entry_))),
@@ -292,7 +299,7 @@ class LoginHandlerGtk : public LoginHandler,
}
static void OnCancelClicked(GtkButton *button, LoginHandlerGtk* handler) {
- DCHECK(MessageLoop::current() == handler->ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
handler->CancelAuth();
}
@@ -301,28 +308,22 @@ class LoginHandlerGtk : public LoginHandler,
Lock handled_auth_lock_;
// The ConstrainedWindow that is hosting our LoginView.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
ConstrainedWindow* dialog_;
- // The MessageLoop of the thread that the ChromeViewContents lives in.
- MessageLoop* ui_loop_;
-
// The request that wants login data.
- // This should only be accessed on the request_loop_.
+ // This should only be accessed on the IO loop.
URLRequest* request_;
- // The MessageLoop of the thread that the URLRequest lives in.
- MessageLoop* request_loop_;
-
// The PasswordForm sent to the PasswordManager. This is so we can refer to it
// when later notifying the password manager if the credentials were accepted
// or rejected.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
PasswordForm password_form_;
// Points to the password manager owned by the TabContents requesting auth.
// Can be null if the TabContents is not a TabContents.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
PasswordManager* password_manager_;
// Cached from the URLRequest, in case it goes NULL on us.
@@ -345,6 +346,6 @@ class LoginHandlerGtk : public LoginHandler,
};
// static
-LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) {
- return new LoginHandlerGtk(request, ui_loop);
+LoginHandler* LoginHandler::Create(URLRequest* request) {
+ return new LoginHandlerGtk(request);
}
diff --git a/chrome/browser/login_prompt_mac.mm b/chrome/browser/login_prompt_mac.mm
index 4c3809a..7446aa2 100644
--- a/chrome/browser/login_prompt_mac.mm
+++ b/chrome/browser/login_prompt_mac.mm
@@ -7,8 +7,8 @@
#include "app/l10n_util.h"
#include "base/mac_util.h"
-#include "base/message_loop.h"
#include "base/sys_string_conversions.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/cocoa/constrained_window_mac.h"
#include "chrome/browser/login_model.h"
#include "chrome/browser/password_manager/password_manager.h"
@@ -35,12 +35,10 @@ class LoginHandlerMac : public LoginHandler,
public ConstrainedWindowMacDelegateCustomSheet,
public LoginModelObserver {
public:
- LoginHandlerMac(URLRequest* request, MessageLoop* ui_loop)
+ LoginHandlerMac(URLRequest* request)
: handled_auth_(false),
dialog_(NULL),
- ui_loop_(ui_loop),
request_(request),
- request_loop_(MessageLoop::current()),
password_manager_(NULL),
sheet_controller_(nil),
login_model_(NULL) {
@@ -80,7 +78,7 @@ class LoginHandlerMac : public LoginHandler,
// LoginHandler:
virtual void BuildViewForPasswordManager(PasswordManager* manager,
std::wstring explanation) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// Load nib here instead of in constructor.
sheet_controller_ = [[[LoginHandlerSheet alloc]
@@ -111,7 +109,7 @@ class LoginHandlerMac : public LoginHandler,
}
virtual TabContents* GetTabContentsForLogin() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
return tab_util::GetTabContentsByID(render_process_host_id_,
tab_contents_id_);
@@ -129,28 +127,35 @@ class LoginHandlerMac : public LoginHandler,
password_manager_->ProvisionallySavePassword(password_form_);
}
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::CloseContentsDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::SendNotifications));
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::SetAuthDeferred, username, password));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::CloseContentsDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &LoginHandlerMac::SetAuthDeferred, username, password));
}
virtual void CancelAuth() {
if (WasAuthHandled(true))
return;
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::CloseContentsDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::SendNotifications));
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::CancelAuthDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::CloseContentsDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::CancelAuthDeferred));
}
virtual void OnRequestCancelled() {
- DCHECK(MessageLoop::current() == request_loop_) <<
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
"Why is OnRequestCancelled called from the UI thread?";
// Reference is no longer valid.
@@ -163,42 +168,44 @@ class LoginHandlerMac : public LoginHandler,
// Overridden from ConstrainedWindowMacDelegate:
virtual void DeleteDelegate() {
if (!WasAuthHandled(true)) {
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::CancelAuthDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerMac::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::CancelAuthDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerMac::SendNotifications));
}
// Close sheet if it's still open, as required by
// ConstrainedWindowMacDelegate.
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
if (is_sheet_open())
[NSApp endSheet:sheet()];
SetModel(NULL);
// Delete this object once all InvokeLaters have been called.
- request_loop_->ReleaseSoon(FROM_HERE, this);
+ ChromeThread::ReleaseSoon(ChromeThread::IO, FROM_HERE, this);
}
void OnLoginPressed(const std::wstring& username,
const std::wstring& password) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
SetAuth(username, password);
}
void OnCancelPressed() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
CancelAuth();
}
private:
friend class LoginPrompt;
- // Calls SetAuth from the request_loop.
+ // Calls SetAuth from the IO loop.
void SetAuthDeferred(const std::wstring& username,
const std::wstring& password) {
- DCHECK(MessageLoop::current() == request_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (request_) {
request_->SetAuth(username, password);
@@ -206,9 +213,9 @@ class LoginHandlerMac : public LoginHandler,
}
}
- // Calls CancelAuth from the request_loop.
+ // Calls CancelAuth from the IO loop.
void CancelAuthDeferred() {
- DCHECK(MessageLoop::current() == request_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (request_) {
request_->CancelAuth();
@@ -220,7 +227,7 @@ class LoginHandlerMac : public LoginHandler,
// Closes the view_contents from the UI loop.
void CloseContentsDeferred() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// The hosting ConstrainedWindow may have been freed.
if (dialog_)
@@ -240,7 +247,7 @@ class LoginHandlerMac : public LoginHandler,
// Notify observers that authentication is needed or received. The automation
// proxy uses this for testing.
void SendNotifications() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
NotificationService* service = NotificationService::current();
TabContents* requesting_contents = GetTabContentsForLogin();
@@ -266,28 +273,22 @@ class LoginHandlerMac : public LoginHandler,
Lock handled_auth_lock_;
// The ConstrainedWindow that is hosting our LoginView.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
ConstrainedWindow* dialog_;
- // The MessageLoop of the thread that the ChromeViewContents lives in.
- MessageLoop* ui_loop_;
-
// The request that wants login data.
- // This should only be accessed on the request_loop_.
+ // This should only be accessed on the IO loop.
URLRequest* request_;
- // The MessageLoop of the thread that the URLRequest lives in.
- MessageLoop* request_loop_;
-
// The PasswordForm sent to the PasswordManager. This is so we can refer to it
// when later notifying the password manager if the credentials were accepted
// or rejected.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
PasswordForm password_form_;
// Points to the password manager owned by the TabContents requesting auth.
// Can be null if the TabContents is not a TabContents.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
PasswordManager* password_manager_;
// Cached from the URLRequest, in case it goes NULL on us.
@@ -305,8 +306,8 @@ class LoginHandlerMac : public LoginHandler,
};
// static
-LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) {
- return new LoginHandlerMac(request, ui_loop);
+LoginHandler* LoginHandler::Create(URLRequest* request) {
+ return new LoginHandlerMac(request);
}
// ----------------------------------------------------------------------------
diff --git a/chrome/browser/login_prompt_win.cc b/chrome/browser/login_prompt_win.cc
index b3da33a..f95a0d2 100644
--- a/chrome/browser/login_prompt_win.cc
+++ b/chrome/browser/login_prompt_win.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/login_prompt.h"
#include "app/l10n_util.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
@@ -30,12 +30,10 @@ class LoginHandlerWin : public LoginHandler,
public base::RefCountedThreadSafe<LoginHandlerWin>,
public views::DialogDelegate {
public:
- LoginHandlerWin(URLRequest* request, MessageLoop* ui_loop)
+ LoginHandlerWin(URLRequest* request)
: dialog_(NULL),
handled_auth_(false),
request_(request),
- request_loop_(MessageLoop::current()),
- ui_loop_(ui_loop),
password_manager_(NULL) {
DCHECK(request_) << "LoginHandler constructed with NULL request";
@@ -65,29 +63,30 @@ class LoginHandlerWin : public LoginHandler,
return l10n_util::GetString(IDS_LOGIN_DIALOG_TITLE);
}
virtual void WindowClosing() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// Reference is no longer valid.
dialog_ = NULL;
if (!WasAuthHandled(true)) {
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::CancelAuthDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerWin::CancelAuthDeferred));
SendNotifications();
}
}
virtual void DeleteDelegate() {
// Delete this object once all InvokeLaters have been called.
- request_loop_->ReleaseSoon(FROM_HERE, this);
+ ChromeThread::ReleaseSoon(ChromeThread::IO, FROM_HERE, this);
}
virtual bool Cancel() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(dialog_) << "LoginHandler invoked without being attached";
CancelAuth();
return true;
}
virtual bool Accept() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(dialog_) << "LoginHandler invoked without being attached";
SetAuth(login_view_->GetUsername(), login_view_->GetPassword());
return true;
@@ -100,7 +99,7 @@ class LoginHandlerWin : public LoginHandler,
virtual void BuildViewForPasswordManager(PasswordManager* manager,
std::wstring explanation) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
LoginView* view = new LoginView(explanation);
@@ -130,7 +129,7 @@ class LoginHandlerWin : public LoginHandler,
}
virtual TabContents* GetTabContentsForLogin() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
return tab_util::GetTabContentsByID(render_process_host_id_,
tab_contents_id_);
@@ -148,28 +147,35 @@ class LoginHandlerWin : public LoginHandler,
password_manager_->ProvisionallySavePassword(password_form_);
}
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::CloseContentsDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::SendNotifications));
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::SetAuthDeferred, username, password));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerWin::CloseContentsDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerWin::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &LoginHandlerWin::SetAuthDeferred, username, password));
}
virtual void CancelAuth() {
if (WasAuthHandled(true))
return;
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::CloseContentsDeferred));
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::SendNotifications));
- request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &LoginHandlerWin::CancelAuthDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerWin::CloseContentsDeferred));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerWin::SendNotifications));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &LoginHandlerWin::CancelAuthDeferred));
}
virtual void OnRequestCancelled() {
- DCHECK(MessageLoop::current() == request_loop_) <<
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)) <<
"Why is OnRequestCancelled called from the UI thread?";
// Reference is no longer valid.
@@ -182,10 +188,10 @@ class LoginHandlerWin : public LoginHandler,
private:
friend class LoginPrompt;
- // Calls SetAuth from the request_loop.
+ // Calls SetAuth from the IO loop.
void SetAuthDeferred(const std::wstring& username,
const std::wstring& password) {
- DCHECK(MessageLoop::current() == request_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (request_) {
request_->SetAuth(username, password);
@@ -193,9 +199,9 @@ class LoginHandlerWin : public LoginHandler,
}
}
- // Calls CancelAuth from the request_loop.
+ // Calls CancelAuth from the IO loop.
void CancelAuthDeferred() {
- DCHECK(MessageLoop::current() == request_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (request_) {
request_->CancelAuth();
@@ -207,7 +213,7 @@ class LoginHandlerWin : public LoginHandler,
// Closes the view_contents from the UI loop.
void CloseContentsDeferred() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// The hosting ConstrainedWindow may have been freed.
if (dialog_)
@@ -227,7 +233,7 @@ class LoginHandlerWin : public LoginHandler,
// Notify observers that authentication is needed or received. The automation
// proxy uses this for testing.
void SendNotifications() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
NotificationService* service = NotificationService::current();
TabContents* requesting_contents = GetTabContentsForLogin();
@@ -253,31 +259,25 @@ class LoginHandlerWin : public LoginHandler,
Lock handled_auth_lock_;
// The ConstrainedWindow that is hosting our LoginView.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
ConstrainedWindow* dialog_;
- // The MessageLoop of the thread that the ChromeViewContents lives in.
- MessageLoop* ui_loop_;
-
// The request that wants login data.
- // This should only be accessed on the request_loop_.
+ // This should only be accessed on the IO loop.
URLRequest* request_;
- // The MessageLoop of the thread that the URLRequest lives in.
- MessageLoop* request_loop_;
-
// The LoginView that contains the user's login information
LoginView* login_view_;
// The PasswordForm sent to the PasswordManager. This is so we can refer to it
// when later notifying the password manager if the credentials were accepted
// or rejected.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
PasswordForm password_form_;
// Points to the password manager owned by the TabContents requesting auth.
// Can be null if the TabContents is not a TabContents.
- // This should only be accessed on the ui_loop_.
+ // This should only be accessed on the UI loop.
PasswordManager* password_manager_;
// Cached from the URLRequest, in case it goes NULL on us.
@@ -288,6 +288,6 @@ class LoginHandlerWin : public LoginHandler,
};
// static
-LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) {
- return new LoginHandlerWin(request, ui_loop);
+LoginHandler* LoginHandler::Create(URLRequest* request) {
+ return new LoginHandlerWin(request);
}
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 77d71c4..13ca1721 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -1048,7 +1048,7 @@ void ResourceDispatcherHost::OnAuthRequired(
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request);
DCHECK(!info->login_handler()) <<
"OnAuthRequired called with login_handler pending";
- info->set_login_handler(CreateLoginPrompt(auth_info, request, ui_loop_));
+ info->set_login_handler(CreateLoginPrompt(auth_info, request));
}
void ResourceDispatcherHost::OnCertificateRequested(
@@ -1074,7 +1074,7 @@ void ResourceDispatcherHost::OnCertificateRequested(
DCHECK(!info->ssl_client_auth_handler()) <<
"OnCertificateRequested called with ssl_client_auth_handler pending";
info->set_ssl_client_auth_handler(
- new SSLClientAuthHandler(request, cert_request_info, io_loop_, ui_loop_));
+ new SSLClientAuthHandler(request, cert_request_info));
info->ssl_client_auth_handler()->SelectCertificate();
#endif
}
@@ -1084,7 +1084,7 @@ void ResourceDispatcherHost::OnSSLCertificateError(
int cert_error,
net::X509Certificate* cert) {
DCHECK(request);
- SSLManager::OnSSLCertificateError(this, request, cert_error, cert, ui_loop_);
+ SSLManager::OnSSLCertificateError(this, request, cert_error, cert);
}
void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) {
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
index b3463e3..988dd25 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -75,7 +75,8 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
};
SafeBrowsingBlockingPageTest()
- : io_thread_(ChromeThread::IO, MessageLoop::current()) {
+ : ui_thread_(ChromeThread::UI, MessageLoop::current()),
+ io_thread_(ChromeThread::IO, MessageLoop::current()) {
ResetUserResponse();
service_ = new SafeBrowsingService();
}
@@ -159,6 +160,7 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
UserResponse user_response_;
scoped_refptr<SafeBrowsingService> service_;
TestSafeBrowsingBlockingPageFactory factory_;
+ ChromeThread ui_thread_;
ChromeThread io_thread_;
};
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index 66833854..4ec9096 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -4,11 +4,9 @@
#include "chrome/browser/shell_integration.h"
-#include "base/message_loop.h"
#include "base/path_service.h"
-#include "base/thread.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/browser/chrome_thread.h"
///////////////////////////////////////////////////////////////////////////////
// ShellIntegration::DefaultBrowserWorker
@@ -16,21 +14,23 @@
ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
DefaultBrowserObserver* observer)
- : observer_(observer),
- ui_loop_(MessageLoop::current()),
- file_loop_(g_browser_process->file_thread()->message_loop()) {
+ : observer_(observer) {
}
void ShellIntegration::DefaultBrowserWorker::StartCheckDefaultBrowser() {
observer_->SetDefaultBrowserUIState(STATE_PROCESSING);
- file_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &DefaultBrowserWorker::ExecuteCheckDefaultBrowser));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultBrowserWorker::ExecuteCheckDefaultBrowser));
}
void ShellIntegration::DefaultBrowserWorker::StartSetAsDefaultBrowser() {
observer_->SetDefaultBrowserUIState(STATE_PROCESSING);
- file_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &DefaultBrowserWorker::ExecuteSetAsDefaultBrowser));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultBrowserWorker::ExecuteSetAsDefaultBrowser));
}
void ShellIntegration::DefaultBrowserWorker::ObserverDestroyed() {
@@ -43,27 +43,31 @@ void ShellIntegration::DefaultBrowserWorker::ObserverDestroyed() {
// DefaultBrowserWorker, private:
void ShellIntegration::DefaultBrowserWorker::ExecuteCheckDefaultBrowser() {
- DCHECK(MessageLoop::current() == file_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
DefaultBrowserState state = ShellIntegration::IsDefaultBrowser();
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &DefaultBrowserWorker::CompleteCheckDefaultBrowser, state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultBrowserWorker::CompleteCheckDefaultBrowser, state));
}
void ShellIntegration::DefaultBrowserWorker::CompleteCheckDefaultBrowser(
DefaultBrowserState state) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
UpdateUI(state);
}
void ShellIntegration::DefaultBrowserWorker::ExecuteSetAsDefaultBrowser() {
- DCHECK(MessageLoop::current() == file_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
ShellIntegration::SetAsDefaultBrowser();
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &DefaultBrowserWorker::CompleteSetAsDefaultBrowser));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &DefaultBrowserWorker::CompleteSetAsDefaultBrowser));
}
void ShellIntegration::DefaultBrowserWorker::CompleteSetAsDefaultBrowser() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
if (observer_) {
// Set as default completed, check again to make sure it stuck...
StartCheckDefaultBrowser();
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index 74e45af..8b90d6a 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -17,7 +17,6 @@
#endif
class FilePath;
-class MessageLoop;
class ShellIntegration {
public:
@@ -126,9 +125,6 @@ class ShellIntegration {
DefaultBrowserObserver* observer_;
- MessageLoop* ui_loop_;
- MessageLoop* file_loop_;
-
DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
};
};
diff --git a/chrome/browser/ssl/ssl_cert_error_handler.cc b/chrome/browser/ssl/ssl_cert_error_handler.cc
index d050a64..1bb0c4d 100644
--- a/chrome/browser/ssl/ssl_cert_error_handler.cc
+++ b/chrome/browser/ssl/ssl_cert_error_handler.cc
@@ -14,10 +14,9 @@ SSLCertErrorHandler::SSLCertErrorHandler(
const std::string& frame_origin,
const std::string& main_frame_origin,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop)
+ net::X509Certificate* cert)
: SSLErrorHandler(rdh, request, resource_type, frame_origin,
- main_frame_origin, ui_loop),
+ main_frame_origin),
cert_error_(cert_error) {
DCHECK(request == resource_dispatcher_host_->GetURLRequest(request_id_));
diff --git a/chrome/browser/ssl/ssl_cert_error_handler.h b/chrome/browser/ssl/ssl_cert_error_handler.h
index c58b2cf..7956317 100644
--- a/chrome/browser/ssl/ssl_cert_error_handler.h
+++ b/chrome/browser/ssl/ssl_cert_error_handler.h
@@ -23,8 +23,7 @@ class SSLCertErrorHandler : public SSLErrorHandler {
const std::string& frame_origin,
const std::string& main_frame_origin,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop);
+ net::X509Certificate* cert);
virtual SSLCertErrorHandler* AsSSLCertErrorHandler() { return this; }
diff --git a/chrome/browser/ssl/ssl_client_auth_handler.cc b/chrome/browser/ssl/ssl_client_auth_handler.cc
index c986885..7acb1b5 100644
--- a/chrome/browser/ssl/ssl_client_auth_handler.cc
+++ b/chrome/browser/ssl/ssl_client_auth_handler.cc
@@ -10,23 +10,19 @@
#endif
#include "app/l10n_util.h"
-#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/chrome_thread.h"
#include "grit/generated_resources.h"
#include "net/url_request/url_request.h"
SSLClientAuthHandler::SSLClientAuthHandler(
URLRequest* request,
- net::SSLCertRequestInfo* cert_request_info,
- MessageLoop* io_loop,
- MessageLoop* ui_loop)
+ net::SSLCertRequestInfo* cert_request_info)
: request_(request),
- cert_request_info_(cert_request_info),
- io_loop_(io_loop),
- ui_loop_(ui_loop) {
+ cert_request_info_(cert_request_info) {
// Keep us alive until a cert is selected.
AddRef();
}
@@ -40,8 +36,9 @@ void SSLClientAuthHandler::OnRequestCancelled() {
void SSLClientAuthHandler::SelectCertificate() {
// Let's move the request to the UI thread.
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SSLClientAuthHandler::DoSelectCertificate));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &SSLClientAuthHandler::DoSelectCertificate));
}
void SSLClientAuthHandler::DoSelectCertificate() {
@@ -85,8 +82,10 @@ void SSLClientAuthHandler::DoSelectCertificate() {
#endif
// Notify the IO thread that we have selected a cert.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SSLClientAuthHandler::CertificateSelected, cert));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLClientAuthHandler::CertificateSelected, cert));
}
void SSLClientAuthHandler::CertificateSelected(net::X509Certificate* cert) {
diff --git a/chrome/browser/ssl/ssl_client_auth_handler.h b/chrome/browser/ssl/ssl_client_auth_handler.h
index 9c3b6db..b3146b2 100644
--- a/chrome/browser/ssl/ssl_client_auth_handler.h
+++ b/chrome/browser/ssl/ssl_client_auth_handler.h
@@ -12,7 +12,6 @@
namespace net {
class X509Certificate;
}
-class MessageLoop;
class URLRequest;
// This class handles the approval and selection of a certificate for SSL client
@@ -23,9 +22,7 @@ class SSLClientAuthHandler :
public base::RefCountedThreadSafe<SSLClientAuthHandler> {
public:
SSLClientAuthHandler(URLRequest* request,
- net::SSLCertRequestInfo* cert_request_info,
- MessageLoop* io_loop,
- MessageLoop* ui_loop);
+ net::SSLCertRequestInfo* cert_request_info);
~SSLClientAuthHandler();
// Asks the user to select a certificate and resumes the URL request with that
@@ -52,9 +49,6 @@ class SSLClientAuthHandler :
// The certs to choose from.
scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
- MessageLoop* io_loop_;
- MessageLoop* ui_loop_;
-
DISALLOW_COPY_AND_ASSIGN(SSLClientAuthHandler);
};
diff --git a/chrome/browser/ssl/ssl_error_handler.cc b/chrome/browser/ssl/ssl_error_handler.cc
index 13fce6c..09594ac 100644
--- a/chrome/browser/ssl/ssl_error_handler.cc
+++ b/chrome/browser/ssl/ssl_error_handler.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ssl/ssl_error_handler.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "chrome/browser/ssl/ssl_cert_error_handler.h"
@@ -17,11 +17,8 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
URLRequest* request,
ResourceType::Type resource_type,
const std::string& frame_origin,
- const std::string& main_frame_origin,
- MessageLoop* ui_loop)
- : ui_loop_(ui_loop),
- io_loop_(MessageLoop::current()),
- manager_(NULL),
+ const std::string& main_frame_origin)
+ : manager_(NULL),
request_id_(0, 0),
resource_dispatcher_host_(rdh),
request_url_(request->url()),
@@ -29,7 +26,7 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
frame_origin_(frame_origin),
main_frame_origin_(main_frame_origin),
request_has_been_notified_(false) {
- DCHECK(MessageLoop::current() != ui_loop);
+ DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::UI));
ResourceDispatcherHostRequestInfo* info =
ResourceDispatcherHost::InfoForRequest(request);
@@ -50,7 +47,7 @@ SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
}
void SSLErrorHandler::Dispatch() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
TabContents* tab_contents = GetTabContents();
if (!tab_contents) {
@@ -71,49 +68,56 @@ TabContents* SSLErrorHandler::GetTabContents() {
}
void SSLErrorHandler::CancelRequest() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteCancelRequest,
- net::ERR_ABORTED));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLErrorHandler::CompleteCancelRequest, net::ERR_ABORTED));
}
void SSLErrorHandler::DenyRequest() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteCancelRequest,
- net::ERR_INSECURE_RESPONSE));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLErrorHandler::CompleteCancelRequest,
+ net::ERR_INSECURE_RESPONSE));
}
void SSLErrorHandler::ContinueRequest() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteContinueRequest));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &SSLErrorHandler::CompleteContinueRequest));
}
void SSLErrorHandler::StartRequest(FilterPolicy::Type filter_policy) {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteStartRequest, filter_policy));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &SSLErrorHandler::CompleteStartRequest, filter_policy));
}
void SSLErrorHandler::TakeNoAction() {
- DCHECK(MessageLoop::current() == ui_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
// We need to complete this task on the IO thread.
- io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &SSLErrorHandler::CompleteTakeNoAction));
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &SSLErrorHandler::CompleteTakeNoAction));
}
void SSLErrorHandler::CompleteCancelRequest(int error) {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
@@ -140,7 +144,7 @@ void SSLErrorHandler::CompleteCancelRequest(int error) {
}
void SSLErrorHandler::CompleteContinueRequest() {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
@@ -163,7 +167,7 @@ void SSLErrorHandler::CompleteContinueRequest() {
}
void SSLErrorHandler::CompleteStartRequest(FilterPolicy::Type filter_policy) {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
@@ -191,7 +195,7 @@ void SSLErrorHandler::CompleteStartRequest(FilterPolicy::Type filter_policy) {
}
void SSLErrorHandler::CompleteTakeNoAction() {
- DCHECK(MessageLoop::current() == io_loop_);
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
// It is important that we notify the URLRequest only once. If we try to
// notify the request twice, it may no longer exist and |this| might have
diff --git a/chrome/browser/ssl/ssl_error_handler.h b/chrome/browser/ssl/ssl_error_handler.h
index 06b524a..d31f4cc 100644
--- a/chrome/browser/ssl/ssl_error_handler.h
+++ b/chrome/browser/ssl/ssl_error_handler.h
@@ -15,7 +15,6 @@
#include "googleurl/src/gurl.h"
#include "webkit/glue/resource_type.h"
-class MessageLoop;
class SSLCertErrorHandler;
class TabContents;
class URLRequest;
@@ -99,8 +98,7 @@ class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
URLRequest* request,
ResourceType::Type resource_type,
const std::string& frame_origin,
- const std::string& main_frame_origin,
- MessageLoop* ui_loop);
+ const std::string& main_frame_origin);
// The following 2 methods are the methods subclasses should implement.
virtual void OnDispatchFailed() { TakeNoAction(); }
@@ -108,11 +106,6 @@ class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
// Can use the manager_ member.
virtual void OnDispatched() { TakeNoAction(); }
- // We cache the message loops to be able to proxy events across the thread
- // boundaries.
- MessageLoop* ui_loop_;
- MessageLoop* io_loop_;
-
// Should only be accessed on the UI thread.
SSLManager* manager_; // Our manager.
diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc
index bb17023..f19b9ea 100644
--- a/chrome/browser/ssl/ssl_manager.cc
+++ b/chrome/browser/ssl/ssl_manager.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ssl/ssl_manager.h"
#include "app/l10n_util.h"
-#include "base/message_loop.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/load_from_memory_cache_details.h"
#include "chrome/browser/net/url_request_tracking.h"
#include "chrome/browser/renderer_host/resource_request_details.h"
@@ -63,8 +63,7 @@ bool SSLManager::ProcessedSSLErrorFromRequest() const {
void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
URLRequest* request,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop) {
+ net::X509Certificate* cert) {
DLOG(INFO) << "OnSSLCertificateError() cert_error: " << cert_error <<
" url: " << request->url().spec();
@@ -74,15 +73,15 @@ void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
// A certificate error occurred. Construct a SSLCertErrorHandler object and
// hand it over to the UI thread for processing.
- ui_loop->PostTask(FROM_HERE,
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
NewRunnableMethod(new SSLCertErrorHandler(rdh,
request,
info->resource_type(),
info->frame_origin(),
info->main_frame_origin(),
cert_error,
- cert,
- ui_loop),
+ cert),
&SSLCertErrorHandler::Dispatch));
}
diff --git a/chrome/browser/ssl/ssl_manager.h b/chrome/browser/ssl/ssl_manager.h
index 371248f..7298e93 100644
--- a/chrome/browser/ssl/ssl_manager.h
+++ b/chrome/browser/ssl/ssl_manager.h
@@ -16,7 +16,6 @@
#include "net/base/net_errors.h"
class LoadFromMemoryCacheDetails;
-class MessageLoop;
class NavigationController;
class NavigationEntry;
class PrefService;
@@ -62,8 +61,7 @@ class SSLManager : public NotificationObserver {
static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher,
URLRequest* request,
int cert_error,
- net::X509Certificate* cert,
- MessageLoop* ui_loop);
+ net::X509Certificate* cert);
// Mixed content entry points.
void DidDisplayInsecureContent();
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 075c809..b2dec89 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -132,7 +132,6 @@ InterstitialPage::InterstitialPage(TabContents* tab,
original_rvh_id_(tab->render_view_host()->routing_id()),
should_revert_tab_title_(false),
resource_dispatcher_host_notified_(false),
- ui_loop_(MessageLoop::current()),
ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_(
new InterstitialPageRVHViewDelegate(this))) {
InitInterstitialPageMap();
@@ -484,7 +483,7 @@ void InterstitialPage::Disable() {
void InterstitialPage::TakeActionOnResourceDispatcher(
ResourceRequestAction action) {
- DCHECK(MessageLoop::current() == ui_loop_) <<
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)) <<
"TakeActionOnResourceDispatcher should be called on the main thread.";
if (action == CANCEL || action == RESUME) {
diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h
index b6d30c4..aff6a74 100644
--- a/chrome/browser/tab_contents/interstitial_page.h
+++ b/chrome/browser/tab_contents/interstitial_page.h
@@ -15,7 +15,6 @@
#include "chrome/common/renderer_preferences.h"
#include "googleurl/src/gurl.h"
-class MessageLoop;
class NavigationEntry;
class TabContents;
class TabContentsView;
@@ -199,8 +198,6 @@ class InterstitialPage : public NotificationObserver,
// interstitial is hidden.
std::wstring original_tab_title_;
- MessageLoop* ui_loop_;
-
// Our RenderViewHostViewDelegate, necessary for accelerators to work.
scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_;
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 509e295..0021691 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
@@ -191,7 +192,9 @@ class TestInterstitialPageStateGuard : public TestInterstitialPage::Delegate {
class TabContentsTest : public RenderViewHostTestHarness {
public:
- TabContentsTest() : RenderViewHostTestHarness() {
+ TabContentsTest()
+ : RenderViewHostTestHarness(),
+ ui_thread_(ChromeThread::UI, &message_loop_) {
}
private:
@@ -201,6 +204,8 @@ class TabContentsTest : public RenderViewHostTestHarness {
profile_.reset(new TabContentsTestingProfile());
RenderViewHostTestHarness::SetUp();
}
+
+ ChromeThread ui_thread_;
};
// Test to make sure that title updates get stripped of whitespace.
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 3085964..43e2657 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -58,8 +58,7 @@ std::wstring FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) {
int TaskManagerModel::goats_teleported_ = 0;
TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
- : ui_loop_(MessageLoop::current()),
- update_state_(IDLE) {
+ : update_state_(IDLE) {
TaskManagerBrowserProcessResourceProvider* browser_provider =
new TaskManagerBrowserProcessResourceProvider(task_manager);
@@ -762,13 +761,14 @@ void TaskManagerModel::OnBytesRead(URLRequestJob* job, int byte_count) {
// This happens in the IO thread, post it to the UI thread.
int origin_child_id =
chrome_browser_net::GetOriginProcessUniqueIDForRequest(job->request());
- ui_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(
- this,
- &TaskManagerModel::BytesRead,
- BytesReadParam(origin_child_id,
- render_process_host_child_id,
- routing_id, byte_count)));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this,
+ &TaskManagerModel::BytesRead,
+ BytesReadParam(origin_child_id,
+ render_process_host_child_id,
+ routing_id, byte_count)));
}
bool TaskManagerModel::GetProcessMetricsForRow(
diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h
index b00d190..5501234 100644
--- a/chrome/browser/task_manager.h
+++ b/chrome/browser/task_manager.h
@@ -24,7 +24,6 @@
#include "webkit/api/public/WebCache.h"
class Extension;
-class MessageLoop;
class SkBitmap;
class TaskManager;
class TaskManagerModel;
@@ -368,8 +367,6 @@ class TaskManagerModel : public URLRequestJobTracker::JobObserver,
ObserverList<TaskManagerModelObserver> observer_list_;
- MessageLoop* ui_loop_;
-
// Whether we are currently in the process of updating.
UpdateState update_state_;
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index 7606672..5aba2db 100644
--- a/chrome/browser/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager_resource_providers.cc
@@ -17,7 +17,6 @@
#include "app/resource_bundle.h"
#include "base/basictypes.h"
#include "base/file_version_info.h"
-#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
@@ -332,8 +331,7 @@ base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const {
TaskManagerChildProcessResourceProvider::
TaskManagerChildProcessResourceProvider(TaskManager* task_manager)
: updating_(false),
- task_manager_(task_manager),
- ui_loop_(MessageLoop::current()) {
+ task_manager_(task_manager) {
}
TaskManagerChildProcessResourceProvider::
@@ -466,8 +464,10 @@ void TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo() {
}
// Now notify the UI thread that we have retrieved information about child
// processes.
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this,
+ &TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived));
}
// This is called on the UI thread.
diff --git a/chrome/browser/task_manager_resource_providers.h b/chrome/browser/task_manager_resource_providers.h
index fe96c9d..23efcca 100644
--- a/chrome/browser/task_manager_resource_providers.h
+++ b/chrome/browser/task_manager_resource_providers.h
@@ -173,8 +173,6 @@ class TaskManagerChildProcessResourceProvider
TaskManager* task_manager_;
- MessageLoop* ui_loop_;
-
// Maps the actual resources (the ChildProcessInfo) to the Task Manager
// resources.
std::map<ChildProcessInfo, TaskManagerChildProcessResource*> resources_;
diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc
index 5c5b1f9..e3a0ab0 100644
--- a/chrome/browser/views/shell_dialogs_win.cc
+++ b/chrome/browser/views/shell_dialogs_win.cc
@@ -19,7 +19,7 @@
#include "base/scoped_comptr_win.h"
#include "base/string_util.h"
#include "base/thread.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "grit/generated_resources.h"
// Helpers to show certain types of Windows shell dialogs in a way that doesn't
@@ -90,9 +90,6 @@ class BaseShellDialogImpl {
// returns.
void DisableOwner(HWND owner);
- // The UI thread's message loop.
- MessageLoop* ui_loop_;
-
private:
// Creates a thread to run a shell dialog on. Each dialog requires its own
// thread otherwise in some situations where a singleton owns a single
@@ -126,8 +123,7 @@ class BaseShellDialogImpl {
BaseShellDialogImpl::Owners BaseShellDialogImpl::owners_;
int BaseShellDialogImpl::instance_count_ = 0;
-BaseShellDialogImpl::BaseShellDialogImpl()
- : ui_loop_(MessageLoop::current()) {
+BaseShellDialogImpl::BaseShellDialogImpl() {
++instance_count_;
}
@@ -372,21 +368,27 @@ void SelectFileDialogImpl::ExecuteSelectFile(
std::vector<FilePath> paths;
if (RunOpenMultiFileDialog(params.title, filter,
params.run_state.owner, &paths)) {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFileDialogImpl::MultiFilesSelected,
- paths, params.params, params.run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SelectFileDialogImpl::MultiFilesSelected, paths,
+ params.params, params.run_state));
return;
}
}
if (success) {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFileDialogImpl::FileSelected, path, filter_index,
- params.params, params.run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SelectFileDialogImpl::FileSelected, path, filter_index,
+ params.params, params.run_state));
} else {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFileDialogImpl::FileNotSelected, params.params,
- params.run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SelectFileDialogImpl::FileNotSelected, params.params,
+ params.run_state));
}
}
@@ -657,11 +659,16 @@ void SelectFontDialogImpl::ExecuteSelectFont(RunState run_state, void* params) {
bool success = !!ChooseFont(&cf);
DisableOwner(run_state.owner);
if (success) {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFontDialogImpl::FontSelected, logfont, params, run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SelectFontDialogImpl::FontSelected, logfont, params,
+ run_state));
} else {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFontDialogImpl::FontNotSelected, params, run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SelectFontDialogImpl::FontNotSelected, params, run_state));
}
}
@@ -715,11 +722,16 @@ void SelectFontDialogImpl::ExecuteSelectFontWithNameSize(
bool success = !!ChooseFont(&cf);
DisableOwner(run_state.owner);
if (success) {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFontDialogImpl::FontSelected, logfont, params, run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &SelectFontDialogImpl::FontSelected, logfont, params,
+ run_state));
} else {
- ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
- &SelectFontDialogImpl::FontNotSelected, params, run_state));
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &SelectFontDialogImpl::FontNotSelected, params,
+ run_state));
}
}