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

Unified Diff: chrome/browser/sync/notifier/listener/mediator_thread_impl.cc

Issue 984001: Force TalkMediator::Logout to wait until the Login task has been destroyed an... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | « chrome/browser/sync/notifier/listener/mediator_thread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/notifier/listener/mediator_thread_impl.cc
===================================================================
--- chrome/browser/sync/notifier/listener/mediator_thread_impl.cc (revision 41596)
+++ chrome/browser/sync/notifier/listener/mediator_thread_impl.cc (working copy)
@@ -59,20 +59,8 @@
socket_server->WakeUp();
#endif
- do {
-#if defined(OS_WIN)
- ::MSG message;
- if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) {
- ::TranslateMessage(&message);
- ::DispatchMessage(&message);
- }
-#endif
- ProcessMessages(100);
- if (pump_.get() && pump_->HasPendingTimeoutTask()) {
- pump_->WakeTasks();
- }
- MessageLoop::current()->RunAllPending();
- } while (!IsQuitting());
+ Post(this, CMD_PUMP_AUXILIARY_LOOPS);
+ ProcessMessages(talk_base::kForever);
#if defined(OS_WIN)
set_socketserver(old_socket_server);
@@ -80,11 +68,36 @@
#endif
}
+void MediatorThreadImpl::PumpAuxiliaryLoops() {
+#if defined(OS_WIN)
+ ::MSG message;
+ if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) {
+ ::TranslateMessage(&message);
+ ::DispatchMessage(&message);
+ }
+#endif
+ if (pump_.get() && pump_->HasPendingTimeoutTask()) {
+ pump_->WakeTasks();
+ }
+ MessageLoop::current()->RunAllPending();
+ // We want to pump auxiliary loops every 100ms until this thread is stopped,
+ // at which point this call will do nothing.
+ PostDelayed(100, this, CMD_PUMP_AUXILIARY_LOOPS);
+}
+
void MediatorThreadImpl::Login(const buzz::XmppClientSettings& settings) {
Post(this, CMD_LOGIN, new LoginData(settings));
}
+void MediatorThreadImpl::Stop() {
+ Thread::Stop();
+ CHECK(!login_.get() && !pump_.get()) << "Logout should be called prior to"
+ << "message queue exit.";
+}
+
void MediatorThreadImpl::Logout() {
+ CHECK(!IsQuitting())
+ << "Logout should be called prior to message queue exit.";
Post(this, CMD_DISCONNECT);
Stop();
}
@@ -125,6 +138,9 @@
case CMD_SUBSCRIBE_FOR_UPDATES:
DoSubscribeForUpdates();
break;
+ case CMD_PUMP_AUXILIARY_LOOPS:
+ PumpAuxiliaryLoops();
+ break;
default:
LOG(ERROR) << "P2P: Someone passed a bad message to the thread.";
break;
« no previous file with comments | « chrome/browser/sync/notifier/listener/mediator_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698