summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/mus/sysui_application.cc5
-rw-r--r--ash/mus/sysui_application.h1
-rw-r--r--components/filesystem/file_system_app.cc4
-rw-r--r--components/filesystem/file_system_app.h2
-rw-r--r--components/font_service/font_service_app.cc4
-rw-r--r--components/font_service/font_service_app.h1
-rw-r--r--components/leveldb/leveldb_app.cc5
-rw-r--r--components/leveldb/leveldb_app.h1
-rw-r--r--components/mus/mus_app.cc5
-rw-r--r--components/mus/mus_app.h1
-rw-r--r--components/resource_provider/resource_provider_app.cc5
-rw-r--r--components/resource_provider/resource_provider_app.h1
-rw-r--r--components/resource_provider/resource_provider_test_app.cc3
-rw-r--r--content/common/mojo/mojo_shell_connection_impl.cc4
-rw-r--r--content/common/mojo/mojo_shell_connection_impl.h1
-rw-r--r--mash/browser_driver/browser_driver_application_delegate.cc4
-rw-r--r--mash/browser_driver/browser_driver_application_delegate.h2
-rw-r--r--mash/example/window_type_launcher/window_type_launcher.cc3
-rw-r--r--mash/example/window_type_launcher/window_type_launcher.h2
-rw-r--r--mash/quick_launch/quick_launch_application.cc4
-rw-r--r--mash/quick_launch/quick_launch_application.h1
-rw-r--r--mash/wm/window_manager_application.cc4
-rw-r--r--mash/wm/window_manager_application.h1
-rw-r--r--mojo/services/network/network_service_delegate.cc4
-rw-r--r--mojo/services/network/network_service_delegate.h1
-rw-r--r--mojo/services/tracing/tracing_app.cc6
-rw-r--r--mojo/services/tracing/tracing_app.h2
-rw-r--r--mojo/shell/background/tests/test_service.cc4
-rw-r--r--mojo/shell/public/cpp/lib/application_runner.cc6
-rw-r--r--mojo/shell/public/cpp/lib/shell_client.cc2
-rw-r--r--mojo/shell/public/cpp/lib/shell_connection.cc3
-rw-r--r--mojo/shell/public/cpp/shell_client.h9
-rw-r--r--mojo/shell/public/cpp/shell_connection.h9
-rw-r--r--mojo/shell/tests/connect/connect_test_app.cc6
-rw-r--r--mojo/shell/tests/connect/connect_test_driver.cc5
-rw-r--r--mojo/shell/tests/connect/connect_test_package.cc6
-rw-r--r--mojo/shell/tests/lifecycle/app_client.cc4
-rw-r--r--mojo/shell/tests/lifecycle/app_client.h1
38 files changed, 40 insertions, 92 deletions
diff --git a/ash/mus/sysui_application.cc b/ash/mus/sysui_application.cc
index 15a5186..16585a3 100644
--- a/ash/mus/sysui_application.cc
+++ b/ash/mus/sysui_application.cc
@@ -16,7 +16,6 @@
#include "ash/shell_window_ids.h"
#include "base/bind.h"
#include "base/files/file_path.h"
-#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/mus/public/cpp/property_type_converters.h"
@@ -289,9 +288,5 @@ bool SysUIApplication::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void SysUIApplication::ShellConnectionLost() {
- base::MessageLoop::current()->QuitWhenIdle();
-}
-
} // namespace sysui
} // namespace ash
diff --git a/ash/mus/sysui_application.h b/ash/mus/sysui_application.h
index 2535c5e0..dba0f5e 100644
--- a/ash/mus/sysui_application.h
+++ b/ash/mus/sysui_application.h
@@ -26,7 +26,6 @@ class SysUIApplication : public mojo::ShellClient {
const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
mojo::TracingImpl tracing_;
scoped_ptr<AshInit> ash_init_;
diff --git a/components/filesystem/file_system_app.cc b/components/filesystem/file_system_app.cc
index 2163351..92f78b7 100644
--- a/components/filesystem/file_system_app.cc
+++ b/components/filesystem/file_system_app.cc
@@ -55,10 +55,6 @@ void FileSystemApp::Create(mojo::Connection* connection,
lock_table_);
}
-void FileSystemApp::ShellConnectionLost() {
- _exit(1);
-}
-
//static
base::FilePath FileSystemApp::GetUserDataDir() {
base::FilePath path;
diff --git a/components/filesystem/file_system_app.h b/components/filesystem/file_system_app.h
index 5e297ad..5b1d866 100644
--- a/components/filesystem/file_system_app.h
+++ b/components/filesystem/file_system_app.h
@@ -34,8 +34,6 @@ class FileSystemApp : public mojo::ShellClient,
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
-
// |InterfaceFactory<Files>| implementation:
void Create(mojo::Connection* connection,
mojo::InterfaceRequest<FileSystem> request) override;
diff --git a/components/font_service/font_service_app.cc b/components/font_service/font_service_app.cc
index 5942cb1..6e73b99 100644
--- a/components/font_service/font_service_app.cc
+++ b/components/font_service/font_service_app.cc
@@ -69,10 +69,6 @@ bool FontServiceApp::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void FontServiceApp::ShellConnectionLost() {
- _exit(1);
-}
-
void FontServiceApp::Create(mojo::Connection* connection,
mojo::InterfaceRequest<FontService> request) {
bindings_.AddBinding(this, std::move(request));
diff --git a/components/font_service/font_service_app.h b/components/font_service/font_service_app.h
index b7537da..957f231 100644
--- a/components/font_service/font_service_app.h
+++ b/components/font_service/font_service_app.h
@@ -30,7 +30,6 @@ class FontServiceApp : public mojo::ShellClient,
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
// mojo::InterfaceFactory<FontService>:
void Create(mojo::Connection* connection,
diff --git a/components/leveldb/leveldb_app.cc b/components/leveldb/leveldb_app.cc
index ac2855f..e216391 100644
--- a/components/leveldb/leveldb_app.cc
+++ b/components/leveldb/leveldb_app.cc
@@ -25,11 +25,6 @@ bool LevelDBApp::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void LevelDBApp::ShellConnectionLost() {
- // TODO: This should exit cleanly.
- _exit(1);
-}
-
void LevelDBApp::Create(mojo::Connection* connection,
leveldb::LevelDBServiceRequest request) {
if (!service_)
diff --git a/components/leveldb/leveldb_app.h b/components/leveldb/leveldb_app.h
index 6db5194..26a1152 100644
--- a/components/leveldb/leveldb_app.h
+++ b/components/leveldb/leveldb_app.h
@@ -25,7 +25,6 @@ class LevelDBApp : public mojo::ShellClient,
const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
// |InterfaceFactory<LevelDBService>| implementation:
void Create(mojo::Connection* connection,
diff --git a/components/mus/mus_app.cc b/components/mus/mus_app.cc
index 8128d02..6d15e5b 100644
--- a/components/mus/mus_app.cc
+++ b/components/mus/mus_app.cc
@@ -171,11 +171,6 @@ bool MandolineUIServicesApp::AcceptConnection(Connection* connection) {
return true;
}
-void MandolineUIServicesApp::ShellConnectionLost() {
- // TODO: This should exit cleanly.
- _exit(1);
-}
-
void MandolineUIServicesApp::OnFirstDisplayReady() {
PendingRequests requests;
requests.swap(pending_requests_);
diff --git a/components/mus/mus_app.h b/components/mus/mus_app.h
index e217fba..c66267f 100644
--- a/components/mus/mus_app.h
+++ b/components/mus/mus_app.h
@@ -75,7 +75,6 @@ class MandolineUIServicesApp
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
// WindowServerDelegate:
void OnFirstDisplayReady() override;
diff --git a/components/resource_provider/resource_provider_app.cc b/components/resource_provider/resource_provider_app.cc
index 18b4e42..cd16a98 100644
--- a/components/resource_provider/resource_provider_app.cc
+++ b/components/resource_provider/resource_provider_app.cc
@@ -37,11 +37,6 @@ bool ResourceProviderApp::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void ResourceProviderApp::ShellConnectionLost() {
- // TODO: This should exit cleanly.
- _exit(1);
-}
-
void ResourceProviderApp::Create(
mojo::Connection* connection,
mojo::InterfaceRequest<ResourceProvider> request) {
diff --git a/components/resource_provider/resource_provider_app.h b/components/resource_provider/resource_provider_app.h
index 96d6125..10f7602 100644
--- a/components/resource_provider/resource_provider_app.h
+++ b/components/resource_provider/resource_provider_app.h
@@ -28,7 +28,6 @@ class ResourceProviderApp : public mojo::ShellClient,
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
// mojo::InterfaceFactory<ResourceProvider>:
void Create(mojo::Connection* connection,
diff --git a/components/resource_provider/resource_provider_test_app.cc b/components/resource_provider/resource_provider_test_app.cc
index ab0147f..2c78352 100644
--- a/components/resource_provider/resource_provider_test_app.cc
+++ b/components/resource_provider/resource_provider_test_app.cc
@@ -99,9 +99,6 @@ class TestApp : public mojo::ShellClient,
connection->AddInterface<mojom::Test>(this);
return true;
}
- void ShellConnectionLost() override {
- base::MessageLoop::current()->QuitWhenIdle();
- }
// InterfaceFactory<mojom::Test>:
void Create(mojo::Connection* connection,
diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc
index 44310d3..42cfada6 100644
--- a/content/common/mojo/mojo_shell_connection_impl.cc
+++ b/content/common/mojo/mojo_shell_connection_impl.cc
@@ -126,10 +126,6 @@ bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) {
return found;
}
-void MojoShellConnectionImpl::ShellConnectionLost() {
- LOG(ERROR) << "Shell connection lost.";
-}
-
mojo::Connector* MojoShellConnectionImpl::GetConnector() {
DCHECK(shell_connection_);
return shell_connection_->connector();
diff --git a/content/common/mojo/mojo_shell_connection_impl.h b/content/common/mojo/mojo_shell_connection_impl.h
index 52ce78e..49bfefc 100644
--- a/content/common/mojo/mojo_shell_connection_impl.h
+++ b/content/common/mojo/mojo_shell_connection_impl.h
@@ -53,7 +53,6 @@ class MojoShellConnectionImpl : public MojoShellConnection,
const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
// MojoShellConnection:
mojo::Connector* GetConnector() override;
diff --git a/mash/browser_driver/browser_driver_application_delegate.cc b/mash/browser_driver/browser_driver_application_delegate.cc
index d30225e..cc6bbdc 100644
--- a/mash/browser_driver/browser_driver_application_delegate.cc
+++ b/mash/browser_driver/browser_driver_application_delegate.cc
@@ -67,10 +67,10 @@ bool BrowserDriverApplicationDelegate::AcceptConnection(
return true;
}
-void BrowserDriverApplicationDelegate::ShellConnectionLost() {
+bool BrowserDriverApplicationDelegate::ShellConnectionLost() {
// Prevent the code in AddAccelerators() from keeping this app alive.
binding_.set_connection_error_handler(base::Bind(&DoNothing));
- base::MessageLoop::current()->QuitWhenIdle();
+ return true;
}
void BrowserDriverApplicationDelegate::OnAccelerator(
diff --git a/mash/browser_driver/browser_driver_application_delegate.h b/mash/browser_driver/browser_driver_application_delegate.h
index f517a76..0c05779 100644
--- a/mash/browser_driver/browser_driver_application_delegate.h
+++ b/mash/browser_driver/browser_driver_application_delegate.h
@@ -31,7 +31,7 @@ class BrowserDriverApplicationDelegate : public mojo::ShellClient,
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
+ bool ShellConnectionLost() override;
// mus::mojom::AcceleratorHandler:
void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override;
diff --git a/mash/example/window_type_launcher/window_type_launcher.cc b/mash/example/window_type_launcher/window_type_launcher.cc
index 2628f03..0547e84 100644
--- a/mash/example/window_type_launcher/window_type_launcher.cc
+++ b/mash/example/window_type_launcher/window_type_launcher.cc
@@ -384,6 +384,7 @@ void WindowTypeLauncher::Initialize(mojo::Connector* connector,
widget->Show();
}
-void WindowTypeLauncher::ShellConnectionLost() {
+bool WindowTypeLauncher::ShellConnectionLost() {
base::MessageLoop::current()->QuitWhenIdle();
+ return false;
}
diff --git a/mash/example/window_type_launcher/window_type_launcher.h b/mash/example/window_type_launcher/window_type_launcher.h
index 4d5a266..fd05874 100644
--- a/mash/example/window_type_launcher/window_type_launcher.h
+++ b/mash/example/window_type_launcher/window_type_launcher.h
@@ -22,7 +22,7 @@ class WindowTypeLauncher : public mojo::ShellClient {
// mojo::ShellClient:
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
- void ShellConnectionLost() override;
+ bool ShellConnectionLost() override;
scoped_ptr<views::AuraInit> aura_init_;
diff --git a/mash/quick_launch/quick_launch_application.cc b/mash/quick_launch/quick_launch_application.cc
index 0f505a8..2b2764b 100644
--- a/mash/quick_launch/quick_launch_application.cc
+++ b/mash/quick_launch/quick_launch_application.cc
@@ -106,9 +106,5 @@ bool QuickLaunchApplication::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void QuickLaunchApplication::ShellConnectionLost() {
- base::MessageLoop::current()->QuitWhenIdle();
-}
-
} // namespace quick_launch
} // namespace mash
diff --git a/mash/quick_launch/quick_launch_application.h b/mash/quick_launch/quick_launch_application.h
index 93d72b2..130a1dd 100644
--- a/mash/quick_launch/quick_launch_application.h
+++ b/mash/quick_launch/quick_launch_application.h
@@ -28,7 +28,6 @@ class QuickLaunchApplication : public mojo::ShellClient {
const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
mojo::TracingImpl tracing_;
scoped_ptr<views::AuraInit> aura_init_;
diff --git a/mash/wm/window_manager_application.cc b/mash/wm/window_manager_application.cc
index 606de45..57fb884 100644
--- a/mash/wm/window_manager_application.cc
+++ b/mash/wm/window_manager_application.cc
@@ -127,10 +127,6 @@ bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void WindowManagerApplication::ShellConnectionLost() {
- _exit(1);
-}
-
void WindowManagerApplication::Create(
mojo::Connection* connection,
mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) {
diff --git a/mash/wm/window_manager_application.h b/mash/wm/window_manager_application.h
index 5ca2725..b6cd495 100644
--- a/mash/wm/window_manager_application.h
+++ b/mash/wm/window_manager_application.h
@@ -90,7 +90,6 @@ class WindowManagerApplication
void Initialize(mojo::Connector* connector, const mojo::Identity& identity,
uint32_t id) override;
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
// InterfaceFactory<mash::wm::mojom::UserWindowController>:
void Create(mojo::Connection* connection,
diff --git a/mojo/services/network/network_service_delegate.cc b/mojo/services/network/network_service_delegate.cc
index 1970928..b257331 100644
--- a/mojo/services/network/network_service_delegate.cc
+++ b/mojo/services/network/network_service_delegate.cc
@@ -78,10 +78,6 @@ bool NetworkServiceDelegate::AcceptConnection(Connection* connection) {
return true;
}
-void NetworkServiceDelegate::ShellConnectionLost() {
- base::MessageLoop::current()->QuitWhenIdle();
-}
-
void NetworkServiceDelegate::Create(Connection* connection,
InterfaceRequest<NetworkService> request) {
new NetworkServiceImpl(ref_factory_.CreateRef(), std::move(request));
diff --git a/mojo/services/network/network_service_delegate.h b/mojo/services/network/network_service_delegate.h
index 8997097..7098939 100644
--- a/mojo/services/network/network_service_delegate.h
+++ b/mojo/services/network/network_service_delegate.h
@@ -38,7 +38,6 @@ class NetworkServiceDelegate : public ShellClient,
void Initialize(Connector* connector, const Identity& identity,
uint32_t id) override;
bool AcceptConnection(Connection* connection) override;
- void ShellConnectionLost() override;
// InterfaceFactory<NetworkService> implementation.
void Create(Connection* connection,
diff --git a/mojo/services/tracing/tracing_app.cc b/mojo/services/tracing/tracing_app.cc
index 65b4421..d921a6d 100644
--- a/mojo/services/tracing/tracing_app.cc
+++ b/mojo/services/tracing/tracing_app.cc
@@ -42,8 +42,12 @@ bool TracingApp::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void TracingApp::ShellConnectionLost() {
+bool TracingApp::ShellConnectionLost() {
+ // TODO(beng): This is only required because TracingApp isn't run by
+ // ApplicationRunner - instead it's launched automatically by the standalone
+ // shell. It shouldn't be.
base::MessageLoop::current()->QuitWhenIdle();
+ return false;
}
void TracingApp::Create(mojo::Connection* connection,
diff --git a/mojo/services/tracing/tracing_app.h b/mojo/services/tracing/tracing_app.h
index 17f4132..eb5934a 100644
--- a/mojo/services/tracing/tracing_app.h
+++ b/mojo/services/tracing/tracing_app.h
@@ -34,7 +34,7 @@ class TracingApp
private:
// mojo::ShellClient implementation.
bool AcceptConnection(mojo::Connection* connection) override;
- void ShellConnectionLost() override;
+ bool ShellConnectionLost() override;
// mojo::InterfaceFactory<TraceCollector> implementation.
void Create(mojo::Connection* connection,
diff --git a/mojo/shell/background/tests/test_service.cc b/mojo/shell/background/tests/test_service.cc
index d030a81..e69640d 100644
--- a/mojo/shell/background/tests/test_service.cc
+++ b/mojo/shell/background/tests/test_service.cc
@@ -25,8 +25,8 @@ class TestClient : public ShellClient,
connection->AddInterface(this);
return true;
}
- void ShellConnectionLost() override {
- base::MessageLoop::current()->QuitWhenIdle();
+ bool ShellConnectionLost() override {
+ return true;
}
// InterfaceFactory<mojom::TestService>:
diff --git a/mojo/shell/public/cpp/lib/application_runner.cc b/mojo/shell/public/cpp/lib/application_runner.cc
index 5253053..201aa62 100644
--- a/mojo/shell/public/cpp/lib/application_runner.cc
+++ b/mojo/shell/public/cpp/lib/application_runner.cc
@@ -5,10 +5,12 @@
#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"
#include "base/process/launch.h"
+#include "base/run_loop.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
@@ -54,7 +56,9 @@ MojoResult ApplicationRunner::Run(MojoHandle shell_client_request_handle,
client_.get(),
MakeRequest<shell::mojom::ShellClient>(MakeScopedHandle(
MessagePipeHandle(shell_client_request_handle)))));
- loop->Run();
+ base::RunLoop run_loop;
+ connection_->set_connection_lost_closure(run_loop.QuitClosure());
+ run_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
// client having a stale reference to the app and trying to use it.
diff --git a/mojo/shell/public/cpp/lib/shell_client.cc b/mojo/shell/public/cpp/lib/shell_client.cc
index c41999b..3ca8cd7 100644
--- a/mojo/shell/public/cpp/lib/shell_client.cc
+++ b/mojo/shell/public/cpp/lib/shell_client.cc
@@ -17,6 +17,6 @@ bool ShellClient::AcceptConnection(Connection* connection) {
return false;
}
-void ShellClient::ShellConnectionLost() {}
+bool ShellClient::ShellConnectionLost() { return true; }
} // namespace mojo
diff --git a/mojo/shell/public/cpp/lib/shell_connection.cc b/mojo/shell/public/cpp/lib/shell_connection.cc
index d1cba7e..62ae598 100644
--- a/mojo/shell/public/cpp/lib/shell_connection.cc
+++ b/mojo/shell/public/cpp/lib/shell_connection.cc
@@ -86,7 +86,8 @@ void ShellConnection::OnConnectionError() {
// Note that the ShellClient doesn't technically have to quit now, it may live
// on to service existing connections. All existing Connectors however are
// invalid.
- client_->ShellConnectionLost();
+ if (client_->ShellConnectionLost() && !connection_lost_closure_.is_null())
+ connection_lost_closure_.Run();
// We don't reset the connector as clients may have taken a raw pointer to it.
// Connect() will return nullptr if they try to connect to anything.
}
diff --git a/mojo/shell/public/cpp/shell_client.h b/mojo/shell/public/cpp/shell_client.h
index d6fca12..aff1aac 100644
--- a/mojo/shell/public/cpp/shell_client.h
+++ b/mojo/shell/public/cpp/shell_client.h
@@ -43,8 +43,13 @@ class ShellClient {
// Called when ShellConnection's ShellClient binding (i.e. the pipe the
// Mojo Shell has to talk to us over) is closed. A shell client may use this
- // as a signal to terminate.
- virtual void ShellConnectionLost();
+ // as a signal to terminate. Return true from this method to tell the
+ // ShellConnection to run its connection lost closure if it has one, false to
+ // prevent it from being run. The default implementation returns true.
+ // When used in conjunction with ApplicationRunner, returning true here quits
+ // the message loop created by ApplicationRunner, which results in the app
+ // quitting.
+ virtual bool ShellConnectionLost();
private:
DISALLOW_COPY_AND_ASSIGN(ShellClient);
diff --git a/mojo/shell/public/cpp/shell_connection.h b/mojo/shell/public/cpp/shell_connection.h
index a05f6f1..3e00cd3 100644
--- a/mojo/shell/public/cpp/shell_connection.h
+++ b/mojo/shell/public/cpp/shell_connection.h
@@ -61,7 +61,12 @@ class ShellConnection : public shell::mojom::ShellClient {
// TODO(rockot): Remove this once we get rid of app tests.
void SetAppTestConnectorForTesting(shell::mojom::ConnectorPtr connector);
- private:
+ // Specify a function to be called when the connection to the shell is lost.
+ void set_connection_lost_closure(const base::Closure& closure) {
+ connection_lost_closure_ = closure;
+ }
+
+private:
// shell::mojom::ShellClient:
void Initialize(shell::mojom::IdentityPtr identity,
uint32_t id,
@@ -90,6 +95,8 @@ class ShellConnection : public shell::mojom::ShellClient {
Binding<shell::mojom::ShellClient> binding_;
scoped_ptr<Connector> connector_;
+ base::Closure connection_lost_closure_;
+
DISALLOW_COPY_AND_ASSIGN(ShellConnection);
};
diff --git a/mojo/shell/tests/connect/connect_test_app.cc b/mojo/shell/tests/connect/connect_test_app.cc
index 342e14d..4180763 100644
--- a/mojo/shell/tests/connect/connect_test_app.cc
+++ b/mojo/shell/tests/connect/connect_test_app.cc
@@ -79,12 +79,6 @@ class ConnectTestApp : public ShellClient,
return true;
}
- void ShellConnectionLost() override {
- if (base::MessageLoop::current() &&
- base::MessageLoop::current()->is_running()) {
- base::MessageLoop::current()->QuitWhenIdle();
- }
- }
// InterfaceFactory<test::mojom::ConnectTestService>:
void Create(Connection* connection,
diff --git a/mojo/shell/tests/connect/connect_test_driver.cc b/mojo/shell/tests/connect/connect_test_driver.cc
index ace64df..b1bdce4 100644
--- a/mojo/shell/tests/connect/connect_test_driver.cc
+++ b/mojo/shell/tests/connect/connect_test_driver.cc
@@ -37,8 +37,9 @@ class Driver : public mojo::ShellClient,
connection->AddInterface<ClientProcessTest>(this);
return true;
}
- void ShellConnectionLost() override {
- // TODO: This should exit cleanly.
+ bool ShellConnectionLost() override {
+ // TODO(rockot): http://crbug.com/596621. Should be able to remove this
+ // override entirely.
_exit(1);
}
diff --git a/mojo/shell/tests/connect/connect_test_package.cc b/mojo/shell/tests/connect/connect_test_package.cc
index c5a1a07..1458e65 100644
--- a/mojo/shell/tests/connect/connect_test_package.cc
+++ b/mojo/shell/tests/connect/connect_test_package.cc
@@ -184,12 +184,6 @@ class ConnectTestShellClient
connection->AddInterface<test::mojom::ConnectTestService>(this);
return true;
}
- void ShellConnectionLost() override {
- if (base::MessageLoop::current() &&
- base::MessageLoop::current()->is_running()) {
- base::MessageLoop::current()->QuitWhenIdle();
- }
- }
// InterfaceFactory<mojom::ShellClientFactory>:
void Create(Connection* connection,
diff --git a/mojo/shell/tests/lifecycle/app_client.cc b/mojo/shell/tests/lifecycle/app_client.cc
index a2400ec..657d967 100644
--- a/mojo/shell/tests/lifecycle/app_client.cc
+++ b/mojo/shell/tests/lifecycle/app_client.cc
@@ -20,10 +20,6 @@ bool AppClient::AcceptConnection(mojo::Connection* connection) {
return true;
}
-void AppClient::ShellConnectionLost() {
- GracefulQuit();
-}
-
void AppClient::Create(mojo::Connection* connection,
LifecycleControlRequest request) {
bindings_.AddBinding(this, std::move(request));
diff --git a/mojo/shell/tests/lifecycle/app_client.h b/mojo/shell/tests/lifecycle/app_client.h
index d389f20..5a7d5e6 100644
--- a/mojo/shell/tests/lifecycle/app_client.h
+++ b/mojo/shell/tests/lifecycle/app_client.h
@@ -37,7 +37,6 @@ class AppClient : public ShellClient,
// ShellClient:
bool AcceptConnection(Connection* connection) override;
- void ShellConnectionLost() override;
// InterfaceFactory<LifecycleControl>:
void Create(Connection* connection, LifecycleControlRequest request) override;