| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/message.h" | 10 #include "mojo/public/cpp/bindings/message.h" |
| 11 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 | 14 |
| 15 | 15 |
| 16 // NoInterface is for use in cases when a non-existent or empty interface is | 16 // NoInterface is for use in cases when a non-existent or empty interface is |
| 17 // needed (e.g., when the Mojom "Peer" attribute is not present). | 17 // needed (e.g., when the Mojom "Peer" attribute is not present). |
| 18 | 18 |
| 19 class NoInterface; | 19 class NoInterfaceProxy; |
| 20 class NoInterfaceStub; |
| 21 |
| 22 class NoInterface { |
| 23 public: |
| 24 typedef NoInterfaceProxy Proxy_; |
| 25 typedef NoInterfaceStub Stub_; |
| 26 typedef NoInterface Client_; |
| 27 virtual ~NoInterface() {} |
| 28 virtual void SetClient(NoInterface* client) {} |
| 29 }; |
| 30 |
| 31 class NoInterfaceProxy : public NoInterface { |
| 32 public: |
| 33 explicit NoInterfaceProxy(MessageReceiver* receiver) {} |
| 34 }; |
| 20 | 35 |
| 21 class NoInterfaceStub : public MessageReceiver { | 36 class NoInterfaceStub : public MessageReceiver { |
| 22 public: | 37 public: |
| 23 NoInterfaceStub(NoInterface* unused) {} | 38 NoInterfaceStub() {} |
| 39 void set_sink(NoInterface* sink) {} |
| 24 virtual bool Accept(Message* message) MOJO_OVERRIDE; | 40 virtual bool Accept(Message* message) MOJO_OVERRIDE; |
| 25 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) | 41 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) |
| 26 MOJO_OVERRIDE; | 42 MOJO_OVERRIDE; |
| 27 }; | 43 }; |
| 28 | 44 |
| 29 class NoInterface { | |
| 30 public: | |
| 31 typedef NoInterfaceStub _Stub; | |
| 32 typedef NoInterface _Peer; | |
| 33 }; | |
| 34 | |
| 35 | 45 |
| 36 // AnyInterface is for use in cases where any interface would do (e.g., see the | 46 // AnyInterface is for use in cases where any interface would do (e.g., see the |
| 37 // Shell::Connect method). | 47 // Shell::Connect method). |
| 38 | 48 |
| 39 typedef NoInterface AnyInterface; | 49 typedef NoInterface AnyInterface; |
| 40 | 50 |
| 51 #if 0 |
| 41 | 52 |
| 42 // InterfaceHandle<S> | 53 // InterfaceHandle<S> |
| 43 | 54 |
| 44 template <typename S> | 55 template <typename S> |
| 45 class InterfaceHandle : public MessagePipeHandle { | 56 class InterfaceHandle : public MessagePipeHandle { |
| 46 public: | 57 public: |
| 47 InterfaceHandle() {} | 58 InterfaceHandle() {} |
| 48 explicit InterfaceHandle(MojoHandle value) : MessagePipeHandle(value) {} | 59 explicit InterfaceHandle(MojoHandle value) : MessagePipeHandle(value) {} |
| 49 }; | 60 }; |
| 50 | 61 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 76 MojoResult result MOJO_ALLOW_UNUSED = | 87 MojoResult result MOJO_ALLOW_UNUSED = |
| 77 MojoCreateMessagePipe(h0.mutable_value(), h1.mutable_value()); | 88 MojoCreateMessagePipe(h0.mutable_value(), h1.mutable_value()); |
| 78 assert(result == MOJO_RESULT_OK); | 89 assert(result == MOJO_RESULT_OK); |
| 79 handle_to_self.reset(h0); | 90 handle_to_self.reset(h0); |
| 80 handle_to_peer.reset(h1); | 91 handle_to_peer.reset(h1); |
| 81 } | 92 } |
| 82 | 93 |
| 83 typename Interface<S>::ScopedHandle handle_to_self; | 94 typename Interface<S>::ScopedHandle handle_to_self; |
| 84 typename Interface<P>::ScopedHandle handle_to_peer; | 95 typename Interface<P>::ScopedHandle handle_to_peer; |
| 85 }; | 96 }; |
| 97 #endif |
| 86 | 98 |
| 87 // TODO(darin): Once we have the ability to use C++11 features, consider | 99 // TODO(darin): Once we have the ability to use C++11 features, consider |
| 88 // defining a template alias for ScopedInterfaceHandle<S>. | 100 // defining a template alias for ScopedInterfaceHandle<S>. |
| 89 | 101 |
| 90 } // namespace mojo | 102 } // namespace mojo |
| 91 | 103 |
| 92 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_H_ | 104 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_H_ |
| OLD | NEW |