From 0d3dc8e2804b0adc4f572944db027929e2b5af5a Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Tue, 3 Nov 2009 02:27:01 +0000 Subject: Fifth patch in getting rid of caching MessageLoop pointers. BUG=25354 Review URL: http://codereview.chromium.org/345037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30790 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/shell_dialogs_win.cc | 58 +++++++++++++++++++------------ 1 file changed, 35 insertions(+), 23 deletions(-) (limited to 'chrome/browser/views') 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 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)); } } -- cgit v1.1