| 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(
|
|
|