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_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
6 #define MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 6 #define MOJO_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/public/c/system/message_pipe.h" | 15 #include "mojo/public/c/system/message_pipe.h" |
16 #include "mojo/public/c/system/types.h" | 16 #include "mojo/public/c/system/types.h" |
17 #include "mojo/system/dispatcher.h" | 17 #include "mojo/system/dispatcher.h" |
| 18 #include "mojo/system/memory.h" |
18 #include "mojo/system/message_in_transit.h" | 19 #include "mojo/system/message_in_transit.h" |
19 #include "mojo/system/system_impl_export.h" | 20 #include "mojo/system/system_impl_export.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 namespace system { | 23 namespace system { |
23 | 24 |
24 class Channel; | 25 class Channel; |
25 class Waiter; | 26 class Waiter; |
26 | 27 |
27 // 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 |
(...skipping 26 matching lines...) Expand all Loading... |
54 // Implementations must override these if they represent a local endpoint, | 55 // Implementations must override these if they represent a local endpoint, |
55 // i.e., one for which there's a |MessagePipeDispatcher| (and thus a handle). | 56 // i.e., one for which there's a |MessagePipeDispatcher| (and thus a handle). |
56 // An implementation for a proxy endpoint (for which there's no dispatcher) | 57 // An implementation for a proxy endpoint (for which there's no dispatcher) |
57 // needs not override these methods, since they should never be called. | 58 // needs not override these methods, since they should never be called. |
58 // | 59 // |
59 // These methods implement the methods of the same name in |MessagePipe|, | 60 // These methods implement the methods of the same name in |MessagePipe|, |
60 // though |MessagePipe|'s implementation may have to do a little more if the | 61 // though |MessagePipe|'s implementation may have to do a little more if the |
61 // operation involves both endpoints. | 62 // operation involves both endpoints. |
62 virtual void Close(); | 63 virtual void Close(); |
63 virtual void CancelAllWaiters(); | 64 virtual void CancelAllWaiters(); |
64 virtual MojoResult ReadMessage(void* bytes, | 65 virtual MojoResult ReadMessage(UserPointer<void> bytes, |
65 uint32_t* num_bytes, | 66 UserPointer<uint32_t> num_bytes, |
66 DispatcherVector* dispatchers, | 67 DispatcherVector* dispatchers, |
67 uint32_t* num_dispatchers, | 68 uint32_t* num_dispatchers, |
68 MojoReadMessageFlags flags); | 69 MojoReadMessageFlags flags); |
69 virtual MojoResult AddWaiter(Waiter* waiter, | 70 virtual MojoResult AddWaiter(Waiter* waiter, |
70 MojoHandleSignals signals, | 71 MojoHandleSignals signals, |
71 uint32_t context); | 72 uint32_t context); |
72 virtual void RemoveWaiter(Waiter* waiter); | 73 virtual void RemoveWaiter(Waiter* waiter); |
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(scoped_refptr<Channel> channel, | 78 virtual void Attach(scoped_refptr<Channel> channel, |
78 MessageInTransit::EndpointId local_id); | 79 MessageInTransit::EndpointId local_id); |
79 // Returns false if the endpoint should be closed and destroyed, else true. | 80 // Returns false if the endpoint should be closed and destroyed, else true. |
80 virtual bool Run(MessageInTransit::EndpointId remote_id); | 81 virtual bool Run(MessageInTransit::EndpointId remote_id); |
81 virtual void OnRemove(); | 82 virtual void OnRemove(); |
82 | 83 |
83 protected: | 84 protected: |
84 MessagePipeEndpoint() {} | 85 MessagePipeEndpoint() {} |
85 | 86 |
86 private: | 87 private: |
87 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); | 88 DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint); |
88 }; | 89 }; |
89 | 90 |
90 } // namespace system | 91 } // namespace system |
91 } // namespace mojo | 92 } // namespace mojo |
92 | 93 |
93 #endif // MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ | 94 #endif // MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_ |
OLD | NEW |