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

Unified Diff: mojo/shell/public/cpp/lib/application_runner.cc

Issue 1814223002: Quit the message loop by default in ShellConnectionLost when ApplicationRunner is used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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 | « mojo/shell/background/tests/test_service.cc ('k') | mojo/shell/public/cpp/lib/shell_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « mojo/shell/background/tests/test_service.cc ('k') | mojo/shell/public/cpp/lib/shell_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698