Commit 07ed1e38 authored by darin@chromium.org's avatar darin@chromium.org

Mojo: Make overriding OnConnectionError optional

Using mojo::Application::AddService<ServiceImpl> results in the system taking care of error handling for you. There's no need to force ServiceImpl to override OnConnectionError in this case.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271287 0039d316-1c4b-4281-b951-d872f2087c98
parent 2d6a14f3
......@@ -206,9 +206,6 @@ class LauncherImpl : public InterfaceImpl<Launcher>,
base::Bind(&LauncherImpl::HostContextCreated, base::Unretained(this))));
}
// Overridden from InterfaceImpl:
virtual void OnConnectionError() OVERRIDE {}
private:
// Overridden from Launcher:
virtual void Show() OVERRIDE {
......
......@@ -21,17 +21,19 @@ class InterfaceImpl : public internal::InterfaceImplBase<Interface> {
InterfaceImpl() : internal_state_(this) {}
virtual ~InterfaceImpl() {}
// Subclasses can override this to handle post connection initialization.
virtual void OnConnectionEstablished() {}
// Returns a proxy to the client interface. This is null upon construction,
// and becomes non-null after OnClientConnected. NOTE: It remains non-null
// until this instance is deleted.
Client* client() { return internal_state_.client(); }
// Subclasses must handle connection errors.
virtual void OnConnectionError() = 0;
// Called when the client has connected to this instance.
virtual void OnConnectionEstablished() {}
// We override SetClient here so subclasses don't each have to.
virtual void SetClient(Client* client) MOJO_OVERRIDE {
internal_state_.set_client(client);
}
Client* client() { return internal_state_.client(); }
// Called when the client is no longer connected to this instance. NOTE: The
// client() method continues to return a non-null pointer after this method
// is called. After this method is called, any method calls made on client()
// will be silently ignored.
virtual void OnConnectionError() {}
// DO NOT USE. Exposed only for internal use and for testing.
internal::InterfaceImplState<Interface>* internal_state() {
......@@ -39,6 +41,9 @@ class InterfaceImpl : public internal::InterfaceImplBase<Interface> {
}
private:
virtual void SetClient(Client* client) MOJO_OVERRIDE {
internal_state_.set_client(client);
}
internal::InterfaceImplState<Interface> internal_state_;
MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceImpl);
};
......
......@@ -34,10 +34,6 @@ class TestServiceImpl : public InterfaceImpl<TestService> {
--context_->num_impls;
}
// InterfaceImpl<TestService> implementation.
virtual void OnConnectionError() OVERRIDE {
}
// TestService implementation:
virtual void Test(const mojo::String& test_string) OVERRIDE {
context_->last_test_string = test_string.To<std::string>();
......
......@@ -21,8 +21,6 @@ class EchoServiceImpl : public mojo::InterfaceImpl<mojo::EchoService> {
EchoServiceImpl() {}
virtual ~EchoServiceImpl() {}
virtual void OnConnectionError() OVERRIDE {}
protected:
virtual void Echo(
const mojo::String& in_to_echo,
......
......@@ -41,8 +41,6 @@ class NativeViewportImpl
native_viewport_.reset();
}
virtual void OnConnectionError() OVERRIDE {}
virtual void Create(const Rect& bounds) OVERRIDE {
native_viewport_ =
services::NativeViewport::Create(context_, this);
......
......@@ -70,8 +70,6 @@ void ViewManagerConnection::OnConnectionEstablished() {
Array<INode>::From(to_send));
}
void ViewManagerConnection::OnConnectionError() {}
const Node* ViewManagerConnection::GetNode(const NodeId& id) const {
if (id_ == id.connection_id) {
NodeMap::const_iterator i = node_map_.find(id.node_id);
......
......@@ -40,7 +40,6 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
virtual ~ViewManagerConnection();
virtual void OnConnectionEstablished() MOJO_OVERRIDE;
virtual void OnConnectionError() MOJO_OVERRIDE;
TransportConnectionId id() const { return id_; }
......
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