Index: mojo/shell/public/cpp/lib/application_runner.cc |
diff --git a/mojo/shell/public/cpp/lib/application_runner.cc b/mojo/shell/public/cpp/lib/application_runner.cc |
index 5253053d43f55ebe113404b038976858ab1abffc..31f3c74321cc30481c66ebf35775c9085e88c004 100644 |
--- a/mojo/shell/public/cpp/lib/application_runner.cc |
+++ b/mojo/shell/public/cpp/lib/application_runner.cc |
@@ -5,6 +5,7 @@ |
#include "mojo/shell/public/cpp/application_runner.h" |
#include "base/at_exit.h" |
+#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop/message_loop.h" |
@@ -13,6 +14,16 @@ |
#include "mojo/shell/public/cpp/shell_connection.h" |
namespace mojo { |
+namespace { |
+ |
+void QuitMessageLoop() { |
+ if (base::MessageLoop::current() && |
+ base::MessageLoop::current()->is_running()) { |
+ base::MessageLoop::current()->QuitWhenIdle(); |
sky
2016/03/18 16:20:37
If the messageloop is nested this quits the topmos
|
+ } |
+} |
+ |
+} // namespace |
int g_application_runner_argc; |
const char* const* g_application_runner_argv; |
@@ -54,6 +65,7 @@ MojoResult ApplicationRunner::Run(MojoHandle shell_client_request_handle, |
client_.get(), |
MakeRequest<shell::mojom::ShellClient>(MakeScopedHandle( |
MessagePipeHandle(shell_client_request_handle))))); |
+ connection_->set_connection_lost_closure(base::Bind(&QuitMessageLoop)); |
loop->Run(); |
// It's very common for the client to cache the app and terminate on errors. |
// If we don't delete the client before the app we run the risk of the |