OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LIB_CONNECTOR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ |
7 | 7 |
8 #include "mojo/public/c/environment/async_waiter.h" | 8 #include "mojo/public/c/environment/async_waiter.h" |
9 #include "mojo/public/cpp/bindings/lib/message_queue.h" | 9 #include "mojo/public/cpp/bindings/lib/message_queue.h" |
10 #include "mojo/public/cpp/bindings/message.h" | 10 #include "mojo/public/cpp/bindings/message.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 bool encountered_error() const { return error_; } | 56 bool encountered_error() const { return error_; } |
57 | 57 |
58 // Closes the pipe, triggering the error state. Connector is put into a | 58 // Closes the pipe, triggering the error state. Connector is put into a |
59 // quiescent state. | 59 // quiescent state. |
60 void CloseMessagePipe(); | 60 void CloseMessagePipe(); |
61 | 61 |
62 // Releases the pipe, not triggering the error state. Connector is put into | 62 // Releases the pipe, not triggering the error state. Connector is put into |
63 // a quiescent state. | 63 // a quiescent state. |
64 ScopedMessagePipeHandle PassMessagePipe(); | 64 ScopedMessagePipeHandle PassMessagePipe(); |
65 | 65 |
| 66 // Is the connector bound to a MessagePipe handle? |
| 67 bool is_valid() const { return message_pipe_.is_valid(); } |
| 68 |
66 // Waits for the next message on the pipe, blocking until one arrives or an | 69 // Waits for the next message on the pipe, blocking until one arrives or an |
67 // error happens. Returns |true| if a message has been delivered, |false| | 70 // error happens. Returns |true| if a message has been delivered, |false| |
68 // otherwise. | 71 // otherwise. |
69 bool WaitForIncomingMessage(); | 72 bool WaitForIncomingMessage(); |
70 | 73 |
71 // MessageReceiver implementation: | 74 // MessageReceiver implementation: |
72 bool Accept(Message* message) override; | 75 bool Accept(Message* message) override; |
73 | 76 |
74 private: | 77 private: |
75 static void CallOnHandleReady(void* closure, MojoResult result); | 78 static void CallOnHandleReady(void* closure, MojoResult result); |
(...skipping 28 matching lines...) Expand all Loading... |
104 // of dispatching an incoming message. | 107 // of dispatching an incoming message. |
105 bool* destroyed_flag_; | 108 bool* destroyed_flag_; |
106 | 109 |
107 MOJO_DISALLOW_COPY_AND_ASSIGN(Connector); | 110 MOJO_DISALLOW_COPY_AND_ASSIGN(Connector); |
108 }; | 111 }; |
109 | 112 |
110 } // namespace internal | 113 } // namespace internal |
111 } // namespace mojo | 114 } // namespace mojo |
112 | 115 |
113 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ | 116 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ |
OLD | NEW |