Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: chrome/browser/sync/tools/sync_listen_notifications.cc

Issue 2471006: Refactored MediatorThread to use Chrome threads primarily. (Closed)
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/net/notifier/communicator/login_failure.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/tools/sync_listen_notifications.cc
diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc
index d57f466af8978d40049bc7471eddbaef1067ce47..c70fd4cf58a6ac5926d5c358ae5da87589a4078d 100644
--- a/chrome/browser/sync/tools/sync_listen_notifications.cc
+++ b/chrome/browser/sync/tools/sync_listen_notifications.cc
@@ -42,6 +42,14 @@
namespace {
+void PumpAuxiliaryLoops() {
+ talk_base::Thread* current_thread =
+ talk_base::ThreadManager::CurrentThread();
+ current_thread->ProcessMessages(100);
+ MessageLoop::current()->PostTask(
+ FROM_HERE, NewRunnableFunction(&PumpAuxiliaryLoops));
+}
+
// Main class that listens for and handles messages from the XMPP
// client.
class XmppNotificationClient : public sigslot::has_slots<> {
@@ -68,8 +76,7 @@ class XmppNotificationClient : public sigslot::has_slots<> {
explicit XmppNotificationClient(Delegate* delegate)
: delegate_(delegate),
- xmpp_client_(NULL),
- should_exit_(true) {
+ xmpp_client_(NULL) {
CHECK(delegate_);
}
@@ -95,13 +102,9 @@ class XmppNotificationClient : public sigslot::has_slots<> {
xmpp_socket_adapter, NULL);
CHECK_EQ(connect_status, buzz::XMPP_RETURN_OK);
xmpp_client_->Start();
- talk_base::Thread* current_thread =
- talk_base::ThreadManager::CurrentThread();
- should_exit_ = false;
- while (!should_exit_) {
- current_thread->ProcessMessages(100);
- MessageLoop::current()->RunAllPending();
- }
+ MessageLoop::current()->PostTask(
+ FROM_HERE, NewRunnableFunction(&PumpAuxiliaryLoops));
+ MessageLoop::current()->Run();
// xmpp_client_ is invalid here.
xmpp_client_ = NULL;
}
@@ -129,7 +132,7 @@ class XmppNotificationClient : public sigslot::has_slots<> {
} else {
delegate_->OnError(error, subcode);
}
- should_exit_ = true;
+ MessageLoop::current()->Quit();
buzz::XmppReturnStatus disconnect_status =
xmpp_client_->Disconnect();
CHECK_EQ(disconnect_status, buzz::XMPP_RETURN_OK);
@@ -150,7 +153,6 @@ class XmppNotificationClient : public sigslot::has_slots<> {
buzz::XmppClientSettings xmpp_client_settings_;
// Owned by task_pump.
buzz::XmppClient* xmpp_client_;
- bool should_exit_;
};
// Delegate for legacy notifications.
« no previous file with comments | « no previous file | chrome/common/net/notifier/communicator/login_failure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698