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

Unified Diff: ui/views/controls/menu/menu_message_loop_aura.cc

Issue 280483003: wm: Change the DispatcherClient interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-tests Created 6 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
Index: ui/views/controls/menu/menu_message_loop_aura.cc
diff --git a/ui/views/controls/menu/menu_message_loop_aura.cc b/ui/views/controls/menu/menu_message_loop_aura.cc
index f49920b937d7a8e4cc8bf68d10771125613fab7e..47dd6d64d7df5eb03813545d51fae203999623d9 100644
--- a/ui/views/controls/menu/menu_message_loop_aura.cc
+++ b/ui/views/controls/menu/menu_message_loop_aura.cc
@@ -130,6 +130,12 @@ void MenuMessageLoopAura::Run(MenuController* controller,
// |owner_| may be NULL.
owner_ = owner;
aura::Window* root = GetOwnerRootWindow(owner_);
+ // It is possible for the same MenuMessageLoopAura to start a nested
+ // message-loop while it is already running a nested loop. So make sure the
+ // quit-closure gets reset to the outer loop's quit-closure once the innermost
+ // loop terminates.
+ base::AutoReset<base::Closure> reset_quit_closure(&message_loop_quit_,
+ base::Closure());
#if defined(OS_WIN)
internal::MenuMessagePumpDispatcher nested_dispatcher(controller);
@@ -138,11 +144,12 @@ void MenuMessageLoopAura::Run(MenuController* controller,
if (!nested_menu)
observer.reset(new ActivationChangeObserverImpl(controller, root));
aura::client::GetDispatcherClient(root)
- ->RunWithDispatcher(&nested_dispatcher);
+ ->RunWithDispatcher(&nested_dispatcher, &message_loop_quit_);
} else {
base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
base::MessageLoop::ScopedNestableTaskAllower allow(loop);
base::RunLoop run_loop(&nested_dispatcher);
+ message_loop_quit_ = run_loop.QuitClosure();
run_loop.Run();
}
#else
@@ -158,11 +165,13 @@ void MenuMessageLoopAura::Run(MenuController* controller,
scoped_ptr<ActivationChangeObserverImpl> observer;
if (!nested_menu)
observer.reset(new ActivationChangeObserverImpl(controller, root));
- aura::client::GetDispatcherClient(root)->RunWithDispatcher(NULL);
+ aura::client::GetDispatcherClient(root)->RunWithDispatcher(
+ NULL, &message_loop_quit_);
} else {
base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
base::MessageLoop::ScopedNestableTaskAllower allow(loop);
base::RunLoop run_loop;
+ message_loop_quit_ = run_loop.QuitClosure();
run_loop.Run();
}
nested_dispatcher_ = old_dispatcher.Pass();
@@ -176,14 +185,8 @@ bool MenuMessageLoopAura::ShouldQuitNow() const {
}
void MenuMessageLoopAura::QuitNow() {
- if (owner_) {
- // It's safe to invoke QuitNestedMessageLoop() multiple times, it only
- // effects the current loop.
- aura::Window* root = owner_->GetNativeWindow()->GetRootWindow();
- aura::client::GetDispatcherClient(root)->QuitNestedMessageLoop();
- } else {
- base::MessageLoop::current()->QuitNow();
- }
+ CHECK(!message_loop_quit_.is_null());
+ message_loop_quit_.Run();
// Restore the previous dispatcher.
nested_dispatcher_.reset();
}

Powered by Google App Engine
This is Rietveld 408576698