This source file includes following definitions.
- RunWithDispatcher
- QuitNestedMessageLoop
#include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h"
#include "base/auto_reset.h"
#include "base/run_loop.h"
namespace views {
DesktopDispatcherClient::DesktopDispatcherClient()
: weak_ptr_factory_(this) {}
DesktopDispatcherClient::~DesktopDispatcherClient() {
}
void DesktopDispatcherClient::RunWithDispatcher(
base::MessagePumpDispatcher* nested_dispatcher) {
base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop);
base::Closure old_quit_closure = quit_closure_;
base::RunLoop run_loop(nested_dispatcher);
quit_closure_ = run_loop.QuitClosure();
base::WeakPtr<DesktopDispatcherClient> alive(weak_ptr_factory_.GetWeakPtr());
run_loop.Run();
if (alive) {
weak_ptr_factory_.InvalidateWeakPtrs();
quit_closure_ = old_quit_closure;
}
}
void DesktopDispatcherClient::QuitNestedMessageLoop() {
CHECK(!quit_closure_.is_null());
quit_closure_.Run();
}
}