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_EDK_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "mojo/edk/system/dispatcher.h" | 15 #include "mojo/edk/system/dispatcher.h" |
16 #include "mojo/edk/system/memory.h" | 16 #include "mojo/edk/system/memory.h" |
17 #include "mojo/edk/system/message_in_transit.h" | 17 #include "mojo/edk/system/message_in_transit.h" |
18 #include "mojo/edk/system/system_impl_export.h" | 18 #include "mojo/edk/system/system_impl_export.h" |
19 #include "mojo/public/c/system/message_pipe.h" | 19 #include "mojo/public/c/system/message_pipe.h" |
20 #include "mojo/public/c/system/types.h" | 20 #include "mojo/public/c/system/types.h" |
21 | 21 |
22 namespace mojo { | 22 namespace mojo { |
23 namespace system { | 23 namespace system { |
24 | 24 |
25 class ChannelEndpoint; | 25 class ChannelEndpoint; |
26 class Waiter; | 26 class Awakable; |
27 | 27 |
28 // This is an interface to one of the ends of a message pipe, and is used by | 28 // This is an interface to one of the ends of a message pipe, and is used by |
29 // |MessagePipe|. Its most important role is to provide a sink for messages | 29 // |MessagePipe|. Its most important role is to provide a sink for messages |
30 // (i.e., a place where messages can be sent). It has a secondary role: When the | 30 // (i.e., a place where messages can be sent). It has a secondary role: When the |
31 // endpoint is local (i.e., in the current process), there'll be a dispatcher | 31 // endpoint is local (i.e., in the current process), there'll be a dispatcher |
32 // corresponding to the endpoint. In that case, the implementation of | 32 // corresponding to the endpoint. In that case, the implementation of |
33 // |MessagePipeEndpoint| also implements the functionality required by the | 33 // |MessagePipeEndpoint| also implements the functionality required by the |
34 // dispatcher, e.g., to read messages and to wait. Implementations of this class | 34 // dispatcher, e.g., to read messages and to wait. Implementations of this class |
35 // are not thread-safe; instances are protected by |MesssagePipe|'s lock. | 35 // are not thread-safe; instances are protected by |MesssagePipe|'s lock. |
36 class MOJO_SYSTEM_IMPL_EXPORT MessagePipeEndpoint { | 36 class MOJO_SYSTEM_IMPL_EXPORT MessagePipeEndpoint { |
(...skipping 14 matching lines...) Expand all Loading... |
51 virtual void Close() = 0; | 51 virtual void Close() = 0; |
52 | 52 |
53 // Implementations must override these if they represent a local endpoint, | 53 // Implementations must override these if they represent a local endpoint, |
54 // i.e., one for which there's a |MessagePipeDispatcher| (and thus a handle). | 54 // i.e., one for which there's a |MessagePipeDispatcher| (and thus a handle). |
55 // An implementation for a proxy endpoint (for which there's no dispatcher) | 55 // An implementation for a proxy endpoint (for which there's no dispatcher) |
56 // needs not override these methods, since they should never be called. | 56 // needs not override these methods, since they should never be called. |
57 // | 57 // |
58 // These methods implement the methods of the same name in |MessagePipe|, | 58 // These methods implement the methods of the same name in |MessagePipe|, |
59 // though |MessagePipe|'s implementation may have to do a little more if the | 59 // though |MessagePipe|'s implementation may have to do a little more if the |
60 // operation involves both endpoints. | 60 // operation involves both endpoints. |
61 virtual void CancelAllWaiters(); | 61 virtual void CancelAllAwakables(); |
62 virtual MojoResult ReadMessage(UserPointer<void> bytes, | 62 virtual MojoResult ReadMessage(UserPointer<void> bytes, |
63 UserPointer<uint32_t> num_bytes, | 63 UserPointer<uint32_t> num_bytes, |
64 DispatcherVector* dispatchers, | 64 DispatcherVector* dispatchers, |
65 uint32_t* num_dispatchers, | 65 uint32_t* num_dispatchers, |
66 MojoReadMessageFlags flags); | 66 MojoReadMessageFlags flags); |
67 virtual HandleSignalsState GetHandleSignalsState() const; | 67 virtual HandleSignalsState GetHandleSignalsState() const; |
68 virtual MojoResult AddWaiter(Waiter* waiter, | 68 virtual MojoResult AddAwakable(Awakable* awakable, |
69 MojoHandleSignals signals, | 69 MojoHandleSignals signals, |
70 uint32_t context, | 70 uint32_t context, |
71 HandleSignalsState* signals_state); | 71 HandleSignalsState* signals_state); |
72 virtual void RemoveWaiter(Waiter* waiter, HandleSignalsState* signals_state); | 72 virtual void RemoveAwakable(Awakable* awakable, |
| 73 HandleSignalsState* signals_state); |
73 | 74 |
74 // Implementations must override these if they represent a proxy endpoint. An | 75 // Implementations must override these if they represent a proxy endpoint. An |
75 // implementation for a local endpoint needs not override these methods, since | 76 // implementation for a local endpoint needs not override these methods, since |
76 // they should never be called. | 77 // they should never be called. |
77 virtual void Attach(ChannelEndpoint* channel_endpoint); | 78 virtual void Attach(ChannelEndpoint* channel_endpoint); |
78 | 79 |
79 protected: | 80 protected: |
80 MessagePipeEndpoint() {} | 81 MessagePipeEndpoint() {} |
81 | 82 |
82 private: | 83 private: |
83 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); | 84 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); |
84 }; | 85 }; |
85 | 86 |
86 } // namespace system | 87 } // namespace system |
87 } // namespace mojo | 88 } // namespace mojo |
88 | 89 |
89 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 90 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
OLD | NEW |