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

Unified Diff: mash/browser_driver/browser_driver_application_delegate.cc

Issue 1810713002: Cascade shutdown of instances (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@55all_users
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
Index: mash/browser_driver/browser_driver_application_delegate.cc
diff --git a/mash/browser_driver/browser_driver_application_delegate.cc b/mash/browser_driver/browser_driver_application_delegate.cc
index 64ee8e4de7d7dbe05927247526514547f7c823a7..d30225ec8d1c58710c000c14fa23c7d7a4250a8d 100644
--- a/mash/browser_driver/browser_driver_application_delegate.cc
+++ b/mash/browser_driver/browser_driver_application_delegate.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
#include "components/mus/public/cpp/event_matcher.h"
#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/connector.h"
@@ -42,11 +43,14 @@ void AssertTrue(bool success) {
DCHECK(success);
}
+void DoNothing() {}
+
} // namespace
BrowserDriverApplicationDelegate::BrowserDriverApplicationDelegate()
: connector_(nullptr),
- binding_(this) {}
+ binding_(this),
+ weak_factory_(this) {}
BrowserDriverApplicationDelegate::~BrowserDriverApplicationDelegate() {}
@@ -63,6 +67,12 @@ bool BrowserDriverApplicationDelegate::AcceptConnection(
return true;
}
+void BrowserDriverApplicationDelegate::ShellConnectionLost() {
+ // Prevent the code in AddAccelerators() from keeping this app alive.
+ binding_.set_connection_error_handler(base::Bind(&DoNothing));
+ base::MessageLoop::current()->QuitWhenIdle();
+}
+
void BrowserDriverApplicationDelegate::OnAccelerator(
uint32_t id, mus::mojom::EventPtr event) {
switch (static_cast<Accelerator>(id)) {
@@ -92,7 +102,7 @@ void BrowserDriverApplicationDelegate::AddAccelerators() {
// to re-add our accelerators when the window manager comes back up.
binding_.set_connection_error_handler(
base::Bind(&BrowserDriverApplicationDelegate::AddAccelerators,
- base::Unretained(this)));
+ weak_factory_.GetWeakPtr()));
for (const AcceleratorSpec& spec : g_spec) {
registrar->AddAccelerator(
« no previous file with comments | « mash/browser_driver/browser_driver_application_delegate.h ('k') | mash/example/window_type_launcher/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698