diff options
author | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-06 19:56:17 +0000 |
---|---|---|
committer | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-06 19:56:17 +0000 |
commit | ef855c25d0f65b9f6ef79493260169ed81e1efbb (patch) | |
tree | 1f9e370407d1cd3d75cd5ff11638f029a49b4cf3 /cloud_print | |
parent | 9fa73739c47280860c0e5a44af62885bee391e12 (diff) | |
download | chromium_src-ef855c25d0f65b9f6ef79493260169ed81e1efbb.zip chromium_src-ef855c25d0f65b9f6ef79493260169ed81e1efbb.tar.gz chromium_src-ef855c25d0f65b9f6ef79493260169ed81e1efbb.tar.bz2 |
cloud_print: Use base::MessageLoop.
BUG=236029
R=abodenha@chromium.org
Review URL: https://chromiumcodereview.appspot.com/14522026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
-rw-r--r-- | cloud_print/service/service_state.cc | 15 | ||||
-rw-r--r-- | cloud_print/service/win/cloud_print_service_config.cc | 48 | ||||
-rw-r--r-- | cloud_print/service/win/service_listener.cc | 8 | ||||
-rw-r--r-- | cloud_print/service/win/setup_listener.cc | 10 |
4 files changed, 44 insertions, 37 deletions
diff --git a/cloud_print/service/service_state.cc b/cloud_print/service/service_state.cc index 2bd4715..0c30be6 100644 --- a/cloud_print/service/service_state.cc +++ b/cloud_print/service/service_state.cc @@ -45,14 +45,14 @@ class ServiceStateURLRequestDelegate : public net::URLRequest::Delegate { return; } request->Cancel(); - }; + } virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) OVERRIDE { Read(request); if (!request->status().is_io_pending()) - MessageLoop::current()->Quit(); - }; + base::MessageLoop::current()->Quit(); + } const std::string& data() const { return data_; @@ -160,7 +160,7 @@ std::string ServiceState::ToString() { std::string ServiceState::LoginToGoogle(const std::string& service, const std::string& email, const std::string& password) { - MessageLoop loop(MessageLoop::TYPE_IO); + base::MessageLoop loop(base::MessageLoop::TYPE_IO); net::URLRequestContextBuilder builder; scoped_ptr<net::URLRequestContext> context(builder.Build()); @@ -190,11 +190,12 @@ std::string ServiceState::LoginToGoogle(const std::string& service, request.set_method("POST"); request.Start(); - MessageLoop::current()->PostDelayedTask(FROM_HERE, - MessageLoop::QuitClosure(), + base::MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::MessageLoop::QuitClosure(), base::TimeDelta::FromMilliseconds(kRequestTimeoutMs)); - MessageLoop::current()->Run(); + base::MessageLoop::current()->Run(); const char kAuthStart[] = "Auth="; std::vector<std::string> lines; diff --git a/cloud_print/service/win/cloud_print_service_config.cc b/cloud_print/service/win/cloud_print_service_config.cc index 7d50c13..422caeb 100644 --- a/cloud_print/service/win/cloud_print_service_config.cc +++ b/cloud_print/service/win/cloud_print_service_config.cc @@ -28,7 +28,7 @@ class SetupDialog : public base::RefCounted<SetupDialog>, public ATL::CDialogImpl<SetupDialog> { public: // Enables accelerators. - class MessageFilter : public MessageLoopForUI::MessageFilter { + class MessageFilter : public base::MessageLoopForUI::MessageFilter { public: explicit MessageFilter(SetupDialog* dialog) : dialog_(dialog){} virtual ~MessageFilter() {}; @@ -112,8 +112,8 @@ class SetupDialog : public base::RefCounted<SetupDialog>, ServiceController::State state_; base::Thread worker_; - MessageLoop* ui_loop_; - MessageLoop* io_loop_; + base::MessageLoop* ui_loop_; + base::MessageLoop* io_loop_; ServiceController controller_; }; @@ -121,12 +121,13 @@ class SetupDialog : public base::RefCounted<SetupDialog>, SetupDialog::SetupDialog() : state_(ServiceController::STATE_NOT_FOUND), worker_("worker") { - ui_loop_ = MessageLoop::current(); - DCHECK(ui_loop_->IsType(MessageLoop::TYPE_UI)); + ui_loop_ = base::MessageLoop::current(); + DCHECK(ui_loop_->IsType(base::MessageLoop::TYPE_UI)); - worker_.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); + worker_.StartWithOptions( + base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); io_loop_ = worker_.message_loop(); - DCHECK(io_loop_->IsType(MessageLoop::TYPE_IO)); + DCHECK(io_loop_->IsType(base::MessageLoop::TYPE_IO)); } void SetupDialog::PostUITask(const base::Closure& task) { @@ -138,22 +139,23 @@ void SetupDialog::PostIOTask(const base::Closure& task) { } void SetupDialog::ShowErrorMessageBox(const string16& error_message) { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_UI)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_UI)); MessageBox(error_message.c_str(), LoadLocalString(IDS_OPERATION_FAILED_TITLE).c_str(), MB_ICONERROR | MB_OK); } void SetupDialog::AskToCloseChrome() { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_UI)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_UI)); MessageBox(LoadLocalString(IDS_ADD_PRINTERS_USING_CHROME).c_str(), - LoadLocalString(IDS_CONTINUE_IN_CHROME_TITLE).c_str(), MB_OK); + LoadLocalString(IDS_CONTINUE_IN_CHROME_TITLE).c_str(), + MB_OK); } void SetupDialog::SetState(ServiceController::State status, const string16& user, bool is_logging_enabled) { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_UI)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_UI)); state_ = status; DWORD status_string = 0; @@ -266,7 +268,8 @@ LRESULT SetupDialog::OnCancel(UINT, INT nIdentifier, HWND, BOOL& handled) { LRESULT SetupDialog::OnDestroy(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { - MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); + base::MessageLoop::current()->PostTask(FROM_HERE, + base::MessageLoop::QuitClosure()); return 1; } @@ -299,16 +302,19 @@ bool SetupDialog::IsLoggingEnabled() const{ } void SetupDialog::UpdateState() { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_IO)); controller_.UpdateState(); PostUITask(base::Bind(&SetupDialog::SetState, this, controller_.state(), controller_.user(), controller_.is_logging_enabled())); } void SetupDialog::ShowError(const string16& error_message) { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)); - PostUITask(base::Bind(&SetupDialog::SetState, this, - ServiceController::STATE_UNKNOWN, L"", false)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_IO)); + PostUITask(base::Bind(&SetupDialog::SetState, + this, + ServiceController::STATE_UNKNOWN, + L"", + false)); PostUITask(base::Bind(&SetupDialog::ShowErrorMessageBox, this, error_message)); LOG(ERROR) << error_message; @@ -328,7 +334,7 @@ void SetupDialog::Install(const string16& user, const string16& password, base::ScopedClosureRunner scoped_update_status( base::Bind(&SetupDialog::UpdateState, this)); - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_IO)); SetupListener setup(GetUser()); HRESULT hr = controller_.InstallCheckService(user, password, @@ -396,7 +402,7 @@ void SetupDialog::Install(const string16& user, const string16& password, } void SetupDialog::Start() { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_IO)); HRESULT hr = controller_.StartService(); if (FAILED(hr)) ShowError(hr); @@ -404,7 +410,7 @@ void SetupDialog::Start() { } void SetupDialog::Stop() { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_IO)); HRESULT hr = controller_.StopService(); if (FAILED(hr)) ShowError(hr); @@ -412,7 +418,7 @@ void SetupDialog::Stop() { } void SetupDialog::Uninstall() { - DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)); + DCHECK(base::MessageLoop::current()->IsType(base::MessageLoop::TYPE_IO)); HRESULT hr = controller_.UninstallService(); if (FAILED(hr)) ShowError(hr); @@ -432,7 +438,7 @@ int WINAPI WinMain(__in HINSTANCE hInstance, base::AtExitManager at_exit; CommandLine::Init(0, NULL); - MessageLoopForUI loop; + base::MessageLoopForUI loop; scoped_refptr<SetupDialog> dialog(new SetupDialog()); dialog->Create(NULL); dialog->ShowWindow(SW_SHOW); diff --git a/cloud_print/service/win/service_listener.cc b/cloud_print/service/win/service_listener.cc index 83200c8..1d8cbf5 100644 --- a/cloud_print/service/win/service_listener.cc +++ b/cloud_print/service/win/service_listener.cc @@ -57,10 +57,10 @@ std::string GetEnvironment(const base::FilePath& user_data_dir) { ServiceListener::ServiceListener(const base::FilePath& user_data_dir) : ipc_thread_(new base::Thread("ipc_thread")), user_data_dir_(user_data_dir) { - ipc_thread_->StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); - ipc_thread_->message_loop()->PostTask(FROM_HERE, - base::Bind(&ServiceListener::Connect, - base::Unretained(this))); + ipc_thread_->StartWithOptions( + base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); + ipc_thread_->message_loop()->PostTask( + FROM_HERE, base::Bind(&ServiceListener::Connect, base::Unretained(this))); } ServiceListener::~ServiceListener() { diff --git a/cloud_print/service/win/setup_listener.cc b/cloud_print/service/win/setup_listener.cc index 2678bc7..ebf475f 100644 --- a/cloud_print/service/win/setup_listener.cc +++ b/cloud_print/service/win/setup_listener.cc @@ -31,11 +31,11 @@ SetupListener::SetupListener(const string16& user) ipc_thread_(new base::Thread("ipc_thread")), succeded_(false), is_xps_available_(false) { - ipc_thread_->StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); - ipc_thread_->message_loop()->PostTask(FROM_HERE, - base::Bind(&SetupListener::Connect, - base::Unretained(this), - user)); + ipc_thread_->StartWithOptions( + base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); + ipc_thread_->message_loop()->PostTask( + FROM_HERE, + base::Bind(&SetupListener::Connect, base::Unretained(this), user)); } SetupListener::~SetupListener() { |