Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Unified Diff: mojo/public/cpp/bindings/interface_impl.h

Issue 289873008: Mojo: Make overriding OnConnectionError optional (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/examples/launcher/launcher.cc ('k') | mojo/service_manager/service_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/interface_impl.h
diff --git a/mojo/public/cpp/bindings/interface_impl.h b/mojo/public/cpp/bindings/interface_impl.h
index 15dc9807adbf3548917023d6717dec3afef0910e..e64d0f4941591f149ec93814f680b0c661b9bc1d 100644
--- a/mojo/public/cpp/bindings/interface_impl.h
+++ b/mojo/public/cpp/bindings/interface_impl.h
@@ -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);
};
« no previous file with comments | « mojo/examples/launcher/launcher.cc ('k') | mojo/service_manager/service_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698