summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mojo/application/public/cpp/application_impl.h20
-rw-r--r--mojo/application/public/cpp/lib/application_impl.cc26
2 files changed, 14 insertions, 32 deletions
diff --git a/mojo/application/public/cpp/application_impl.h b/mojo/application/public/cpp/application_impl.h
index 00d616f..5d55a267 100644
--- a/mojo/application/public/cpp/application_impl.h
+++ b/mojo/application/public/cpp/application_impl.h
@@ -49,7 +49,8 @@ namespace mojo {
// app.AddService<BarImpl>(&context);
//
//
-class ApplicationImpl : public Application {
+class ApplicationImpl : public Application,
+ public ErrorHandler {
public:
// Does not take ownership of |delegate|, which must remain valid for the
// lifetime of ApplicationImpl.
@@ -94,27 +95,19 @@ class ApplicationImpl : public Application {
// Quits the main run loop for this application.
void Terminate();
- protected:
+ private:
// Application implementation.
void AcceptConnection(const String& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services,
const String& url) override;
+ void RequestQuit() override;
- private:
- class ShellPtrWatcher;
+ // ErrorHandler implementation.
+ void OnConnectionError() override;
void ClearConnections();
- void OnShellError() {
- delegate_->Quit();
- ClearConnections();
- Terminate();
- }
-
- // Application implementation.
- void RequestQuit() override;
-
typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList;
ServiceRegistryList incoming_service_registries_;
@@ -122,7 +115,6 @@ class ApplicationImpl : public Application {
ApplicationDelegate* delegate_;
Binding<Application> binding_;
ShellPtr shell_;
- ShellPtrWatcher* shell_watch_;
std::string url_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
diff --git a/mojo/application/public/cpp/lib/application_impl.cc b/mojo/application/public/cpp/lib/application_impl.cc
index 0a558ef..69bcd79 100644
--- a/mojo/application/public/cpp/lib/application_impl.cc
+++ b/mojo/application/public/cpp/lib/application_impl.cc
@@ -12,24 +12,10 @@
namespace mojo {
-class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
- public:
- ShellPtrWatcher(ApplicationImpl* impl) : impl_(impl) {}
-
- ~ShellPtrWatcher() override {}
-
- void OnConnectionError() override { impl_->OnShellError(); }
-
- private:
- ApplicationImpl* impl_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher);
-};
-
ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
InterfaceRequest<Application> request)
: delegate_(delegate),
- binding_(this, request.Pass()),
- shell_watch_(nullptr) {
+ binding_(this, request.Pass()) {
}
void ApplicationImpl::ClearConnections() {
@@ -47,7 +33,6 @@ void ApplicationImpl::ClearConnections() {
ApplicationImpl::~ApplicationImpl() {
ClearConnections();
- delete shell_watch_;
}
ApplicationConnection* ApplicationImpl::ConnectToApplication(
@@ -72,8 +57,7 @@ ApplicationConnection* ApplicationImpl::ConnectToApplication(
void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) {
shell_ = shell.Pass();
- shell_watch_ = new ShellPtrWatcher(this);
- shell_.set_error_handler(shell_watch_);
+ shell_.set_error_handler(this);
url_ = url;
delegate_->Initialize(this);
}
@@ -114,4 +98,10 @@ void ApplicationImpl::RequestQuit() {
Terminate();
}
+void ApplicationImpl::OnConnectionError() {
+ delegate_->Quit();
+ ClearConnections();
+ Terminate();
+}
+
} // namespace mojo