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/cpp/bindings/lib/message_queue.h" | 9 #include "mojo/public/cpp/bindings/lib/message_queue.h" |
9 #include "mojo/public/cpp/bindings/message.h" | 10 #include "mojo/public/cpp/bindings/message.h" |
10 #include "mojo/public/cpp/environment/default_async_waiter.h" | 11 #include "mojo/public/cpp/environment/environment.h" |
11 #include "mojo/public/cpp/system/core.h" | 12 #include "mojo/public/cpp/system/core.h" |
12 | 13 |
13 namespace mojo { | 14 namespace mojo { |
14 class ErrorHandler; | 15 class ErrorHandler; |
15 | 16 |
16 namespace internal { | 17 namespace internal { |
17 | 18 |
18 // The Connector class is responsible for performing read/write operations on a | 19 // The Connector class is responsible for performing read/write operations on a |
19 // MessagePipe. It writes messages it receives through the MessageReceiver | 20 // MessagePipe. It writes messages it receives through the MessageReceiver |
20 // interface that it subclasses, and it forwards messages it reads through the | 21 // interface that it subclasses, and it forwards messages it reads through the |
21 // MessageReceiver interface assigned as its incoming receiver. | 22 // MessageReceiver interface assigned as its incoming receiver. |
22 // | 23 // |
23 // NOTE: MessagePipe I/O is non-blocking. | 24 // NOTE: MessagePipe I/O is non-blocking. |
24 // | 25 // |
25 class Connector : public MessageReceiver { | 26 class Connector : public MessageReceiver { |
26 public: | 27 public: |
27 // The Connector takes ownership of |message_pipe|. | 28 // The Connector takes ownership of |message_pipe|. |
28 explicit Connector(ScopedMessagePipeHandle message_pipe, | 29 explicit Connector( |
29 const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); | 30 ScopedMessagePipeHandle message_pipe, |
| 31 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()); |
30 virtual ~Connector(); | 32 virtual ~Connector(); |
31 | 33 |
32 // Sets the receiver to handle messages read from the message pipe. The | 34 // Sets the receiver to handle messages read from the message pipe. The |
33 // Connector will read messages from the pipe regardless of whether or not an | 35 // Connector will read messages from the pipe regardless of whether or not an |
34 // incoming receiver has been set. | 36 // incoming receiver has been set. |
35 void set_incoming_receiver(MessageReceiver* receiver) { | 37 void set_incoming_receiver(MessageReceiver* receiver) { |
36 incoming_receiver_ = receiver; | 38 incoming_receiver_ = receiver; |
37 } | 39 } |
38 | 40 |
39 // Errors from incoming receivers will force the connector into an error | 41 // Errors from incoming receivers will force the connector into an error |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // of dispatching an incoming message. | 91 // of dispatching an incoming message. |
90 bool* destroyed_flag_; | 92 bool* destroyed_flag_; |
91 | 93 |
92 MOJO_DISALLOW_COPY_AND_ASSIGN(Connector); | 94 MOJO_DISALLOW_COPY_AND_ASSIGN(Connector); |
93 }; | 95 }; |
94 | 96 |
95 } // namespace internal | 97 } // namespace internal |
96 } // namespace mojo | 98 } // namespace mojo |
97 | 99 |
98 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ | 100 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ |
OLD | NEW |