OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | |
6 #define MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "mojo/public/system/core.h" | |
10 | |
11 namespace mojo { | |
12 namespace system { | |
13 | |
14 class Waiter; | |
15 | |
16 // This is an interface to one of the ends of a message pipe, and is used by | |
17 // |MessagePipe|. Its most important role is to provide a sink for messages | |
18 // (i.e., a place where messages can be sent). It has a secondary role: When the | |
19 // endpoint is local (i.e., in the current process), there'll be a dispatcher | |
20 // corresponding to the endpoint, and |MessagePipeEndpoint| also implements the | |
darin (slow to review)
2013/10/15 06:50:36
nit: Is the comment "|MessagePipeEndpoint| also im
viettrungluu
2013/10/15 17:48:58
Errr, "the implementation of |MessagePipeEndpoint|
| |
21 // requisite functionality, e.g., to read messages and to wait. This class is | |
22 // not thread-safe; instances are protected by |MesssagePipe|'s lock. | |
23 class MessagePipeEndpoint { | |
24 public: | |
25 virtual ~MessagePipeEndpoint() {} | |
26 | |
27 // All implementations must implement these. | |
28 virtual void OnPeerClose() = 0; | |
29 virtual MojoResult EnqueueMessage( | |
30 const void* bytes, uint32_t num_bytes, | |
31 const MojoHandle* handles, uint32_t num_handles, | |
32 MojoWriteMessageFlags flags) = 0; | |
33 | |
34 // Implementations must implement/override these if they are "connected" to a | |
35 // local |MessagePipeDispatcher| (the default implementations should never be | |
darin (slow to review)
2013/10/15 06:50:36
I'm having trouble following this design. Are you
viettrungluu
2013/10/15 17:48:58
A MessagePipeDispatcher corresponds to a handle, s
| |
36 // called). They implement the methods of the same name in |MessagePipe|, | |
37 // though |MessagePipe|'s implementation may have to do a little more if the | |
38 // operation involves both endpoints. | |
39 virtual void CancelAllWaiters(); | |
40 virtual void Close(); | |
41 virtual MojoResult ReadMessage(void* bytes, uint32_t* num_bytes, | |
42 MojoHandle* handles, uint32_t* num_handles, | |
43 MojoReadMessageFlags flags); | |
44 virtual MojoResult AddWaiter(Waiter* waiter, | |
45 MojoWaitFlags flags, | |
46 MojoResult wake_result); | |
47 virtual void RemoveWaiter(Waiter* waiter); | |
48 | |
49 protected: | |
50 MessagePipeEndpoint() {} | |
51 | |
52 private: | |
53 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); | |
54 }; | |
55 | |
56 } // namespace system | |
57 } // namespace mojo | |
58 | |
59 #endif // MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | |
OLD | NEW |