summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/message_loop.cc22
-rw-r--r--base/message_loop.h13
-rw-r--r--chrome/common/ipc_sync_channel.cc2
3 files changed, 20 insertions, 17 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc
index d348908..1fa1b29 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -176,7 +176,7 @@ void MessageLoop::Run(Dispatcher* dispatcher) {
RunHandler(dispatcher, false);
}
-void MessageLoop::RunOnce() {
+void MessageLoop::RunAllPending() {
RunHandler(NULL, true);
}
@@ -185,15 +185,15 @@ void MessageLoop::RunOnce() {
// one that calls SetUnhandledExceptionFilter().
// enable_SEH_restoration_ = true : any unhandled exception goes to the filter
// that was existed before the loop was run.
-void MessageLoop::RunHandler(Dispatcher* dispatcher, bool run_loop_once) {
+void MessageLoop::RunHandler(Dispatcher* dispatcher, bool non_blocking) {
if (exception_restoration_) {
LPTOP_LEVEL_EXCEPTION_FILTER current_filter = GetTopSEHFilter();
__try {
- RunInternal(dispatcher, run_loop_once);
+ RunInternal(dispatcher, non_blocking);
} __except(SEHFilter(current_filter)) {
}
} else {
- RunInternal(dispatcher, run_loop_once);
+ RunInternal(dispatcher, non_blocking);
}
}
@@ -210,7 +210,7 @@ void MessageLoop::RunHandler(Dispatcher* dispatcher, bool run_loop_once) {
// Summary: none of the above classes is starved, and sent messages has twice
// the chance of being processed (i.e., reduced service time).
-void MessageLoop::RunInternal(Dispatcher* dispatcher, bool run_loop_once) {
+void MessageLoop::RunInternal(Dispatcher* dispatcher, bool non_blocking) {
// Preserve ability to be called recursively.
ScopedStateSave save(this); // State is restored on exit.
dispatcher_ = dispatcher;
@@ -224,12 +224,12 @@ void MessageLoop::RunInternal(Dispatcher* dispatcher, bool run_loop_once) {
// shutting down properly as some operations may depend on further event
// processing. (Note: some tests may use quit_now_ to exit more swiftly,
// and leave messages pending, so don't assert the above fact).
- RunTraditional(run_loop_once);
- DCHECK(run_loop_once || quit_received_ || quit_now_);
+ RunTraditional(non_blocking);
+ DCHECK(non_blocking || quit_received_ || quit_now_);
}
-void MessageLoop::RunTraditional(bool run_loop_once) {
- do {
+void MessageLoop::RunTraditional(bool non_blocking) {
+ for (;;) {
// If we do any work, we may create more messages etc., and more work
// may possibly be waiting in another task group. When we (for example)
// ProcessNextWindowsMessage(), there is a good chance there are still more
@@ -260,12 +260,12 @@ void MessageLoop::RunTraditional(bool run_loop_once) {
if (ProcessNextDelayedNonNestableTask())
continue;
- if (run_loop_once)
+ if (non_blocking)
return;
// We service APCs in WaitForWork, without returning.
WaitForWork(); // Wait (sleep) until we have work to do again.
- } while (!run_loop_once);
+ }
}
//------------------------------------------------------------------------------
diff --git a/base/message_loop.h b/base/message_loop.h
index ecb7e27..1610d07 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -252,8 +252,9 @@ class MessageLoop {
// Run the message loop.
void Run();
- // Run just one pass through the message loop.
- void RunOnce();
+ // Process all pending tasks, windows messages, etc., but don't wait/sleep.
+ // Return as soon as all items that can be run are taken care of.
+ void RunAllPending();
// See description of Dispatcher for how Run uses Dispatcher.
void Run(Dispatcher* dispatcher);
@@ -443,16 +444,18 @@ class MessageLoop {
// stacks around the running of a main message loop.
// It will run the message loop in a SEH try block or not depending on the
// set_SEH_restoration() flag.
- void RunHandler(Dispatcher* dispatcher, bool run_loop_once);
+ void RunHandler(Dispatcher* dispatcher, bool non_blocking);
// A surrounding stack frame around the running of the message loop that
// supports all saving and restoring of state, as is needed for any/all (ugly)
// recursive calls.
- void RunInternal(Dispatcher* dispatcher, bool run_loop_once);
+ void RunInternal(Dispatcher* dispatcher, bool non_blocking);
// An extended message loop (message pump) that loops mostly forever, and
// processes task, signals, timers, etc.
- void RunTraditional(bool run_loop_once);
+ // If non-blocking is set, it will return rather than wait for new things to
+ // arrive for processing.
+ void RunTraditional(bool non_blocking);
//----------------------------------------------------------------------------
// A list of method wrappers with identical calling signatures (no arguments)
diff --git a/chrome/common/ipc_sync_channel.cc b/chrome/common/ipc_sync_channel.cc
index 1dc106c..897e7bf 100644
--- a/chrome/common/ipc_sync_channel.cc
+++ b/chrome/common/ipc_sync_channel.cc
@@ -448,7 +448,7 @@ bool SyncChannel::Send(IPC::Message* message) {
MessageLoop::current()->SetNestableTasksAllowed(true);
// Process a message, but come right back out of the MessageLoop (don't
// loop, sleep, or wait for a kMsgQuit).
- MessageLoop::current()->RunOnce();
+ MessageLoop::current()->RunAllPending();
MessageLoop::current()->SetNestableTasksAllowed(old_state);
pump_messages_events_.pop();
} else {