Commit 5a47aeab authored by jam's avatar jam Committed by Commit bot

Terminate the ViewManagerInit app when its binding has a connection error.

This is split off https://codereview.chromium.org/1139673003

BUG=484234

Review URL: https://codereview.chromium.org/1142083002

Cr-Commit-Position: refs/heads/master@{#330382}
parent 133ead2f
...@@ -35,6 +35,7 @@ ViewManagerInit::ViewManagerInit(ApplicationImpl* app, ...@@ -35,6 +35,7 @@ ViewManagerInit::ViewManagerInit(ApplicationImpl* app,
app_->ConnectToApplication("mojo:view_manager"); app_->ConnectToApplication("mojo:view_manager");
connection->AddService(client_factory_.get()); connection->AddService(client_factory_.get());
connection->ConnectToService(&service_); connection->ConnectToService(&service_);
service_.set_error_handler(this);
connection->ConnectToService(&view_manager_root_); connection->ConnectToService(&view_manager_root_);
if (root_client) { if (root_client) {
root_client_binding_.reset(new Binding<ViewManagerRootClient>(root_client)); root_client_binding_.reset(new Binding<ViewManagerRootClient>(root_client));
...@@ -55,4 +56,8 @@ void ViewManagerInit::OnCreate(InterfaceRequest<ViewManagerClient> request) { ...@@ -55,4 +56,8 @@ void ViewManagerInit::OnCreate(InterfaceRequest<ViewManagerClient> request) {
client->SetViewManagerService(service_.Pass()); client->SetViewManagerService(service_.Pass());
} }
void ViewManagerInit::OnConnectionError() {
mojo::ApplicationImpl::Terminate();
}
} // namespace mojo } // namespace mojo
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "components/view_manager/public/interfaces/view_manager.mojom.h" #include "components/view_manager/public/interfaces/view_manager.mojom.h"
#include "components/view_manager/public/interfaces/view_manager_root.mojom.h" #include "components/view_manager/public/interfaces/view_manager_root.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
namespace mojo { namespace mojo {
class ApplicationImpl; class ApplicationImpl;
...@@ -18,13 +20,13 @@ class ViewManagerDelegate; ...@@ -18,13 +20,13 @@ class ViewManagerDelegate;
// ViewManagerInit is used to establish the initial connection to the // ViewManagerInit is used to establish the initial connection to the
// ViewManager. Use it when you know the ViewManager is not running and you're // ViewManager. Use it when you know the ViewManager is not running and you're
// app is going to be the first one to contact it. // app is going to be the first one to contact it.
class ViewManagerInit { class ViewManagerInit : public mojo::ErrorHandler {
public: public:
// |root_client| is optional. // |root_client| is optional.
ViewManagerInit(ApplicationImpl* app, ViewManagerInit(ApplicationImpl* app,
ViewManagerDelegate* delegate, ViewManagerDelegate* delegate,
ViewManagerRootClient* root_client); ViewManagerRootClient* root_client);
~ViewManagerInit(); ~ViewManagerInit() override;
// Returns the ViewManagerRoot. This is only valid if |root_client| was // Returns the ViewManagerRoot. This is only valid if |root_client| was
// supplied to the constructor. // supplied to the constructor.
...@@ -35,6 +37,9 @@ class ViewManagerInit { ...@@ -35,6 +37,9 @@ class ViewManagerInit {
void OnCreate(InterfaceRequest<ViewManagerClient> request); void OnCreate(InterfaceRequest<ViewManagerClient> request);
// ErrorHandler:
void OnConnectionError() override;
ApplicationImpl* app_; ApplicationImpl* app_;
ViewManagerDelegate* delegate_; ViewManagerDelegate* delegate_;
scoped_ptr<ClientFactory> client_factory_; scoped_ptr<ClientFactory> client_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment