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_DISPATCHER_H_ | 5 #ifndef MOJO_SYSTEM_DISPATCHER_H_ |
6 #define MOJO_SYSTEM_DISPATCHER_H_ | 6 #define MOJO_SYSTEM_DISPATCHER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 class Core; | 25 class Core; |
26 class Dispatcher; | 26 class Dispatcher; |
27 class DispatcherTransport; | 27 class DispatcherTransport; |
28 class HandleTable; | 28 class HandleTable; |
29 class LocalMessagePipeEndpoint; | 29 class LocalMessagePipeEndpoint; |
30 class ProxyMessagePipeEndpoint; | 30 class ProxyMessagePipeEndpoint; |
31 class RawSharedBufferMapping; | 31 class RawSharedBufferMapping; |
32 class TransportData; | 32 class TransportData; |
33 class Waiter; | 33 class Waiter; |
34 | 34 |
| 35 typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector; |
| 36 |
35 namespace test { | 37 namespace test { |
36 | 38 |
37 // Test helper. We need to declare it here so we can friend it. | 39 // Test helper. We need to declare it here so we can friend it. |
38 MOJO_SYSTEM_IMPL_EXPORT DispatcherTransport DispatcherTryStartTransport( | 40 MOJO_SYSTEM_IMPL_EXPORT DispatcherTransport DispatcherTryStartTransport( |
39 Dispatcher* dispatcher); | 41 Dispatcher* dispatcher); |
40 | 42 |
41 } // namespace test | 43 } // namespace test |
42 | 44 |
43 // A |Dispatcher| implements Mojo primitives that are "attached" to a particular | 45 // A |Dispatcher| implements Mojo primitives that are "attached" to a particular |
44 // handle. This includes most (all?) primitives except for |MojoWait...()|. This | 46 // handle. This includes most (all?) primitives except for |MojoWait...()|. This |
(...skipping 25 matching lines...) Expand all Loading... |
70 // written; not that |this| must not be in |transports|. On success, all the | 72 // written; not that |this| must not be in |transports|. On success, all the |
71 // dispatchers in |transports| must have been moved to a closed state; on | 73 // dispatchers in |transports| must have been moved to a closed state; on |
72 // failure, they should remain in their original state. | 74 // failure, they should remain in their original state. |
73 MojoResult WriteMessage(const void* bytes, | 75 MojoResult WriteMessage(const void* bytes, |
74 uint32_t num_bytes, | 76 uint32_t num_bytes, |
75 std::vector<DispatcherTransport>* transports, | 77 std::vector<DispatcherTransport>* transports, |
76 MojoWriteMessageFlags flags); | 78 MojoWriteMessageFlags flags); |
77 // |dispatchers| must be non-null but empty, if |num_dispatchers| is non-null | 79 // |dispatchers| must be non-null but empty, if |num_dispatchers| is non-null |
78 // and nonzero. On success, it will be set to the dispatchers to be received | 80 // and nonzero. On success, it will be set to the dispatchers to be received |
79 // (and assigned handles) as part of the message. | 81 // (and assigned handles) as part of the message. |
80 MojoResult ReadMessage( | 82 MojoResult ReadMessage(void* bytes, |
81 void* bytes, | 83 uint32_t* num_bytes, |
82 uint32_t* num_bytes, | 84 DispatcherVector* dispatchers, |
83 std::vector<scoped_refptr<Dispatcher> >* dispatchers, | 85 uint32_t* num_dispatchers, |
84 uint32_t* num_dispatchers, | 86 MojoReadMessageFlags flags); |
85 MojoReadMessageFlags flags); | |
86 MojoResult WriteData(const void* elements, | 87 MojoResult WriteData(const void* elements, |
87 uint32_t* elements_num_bytes, | 88 uint32_t* elements_num_bytes, |
88 MojoWriteDataFlags flags); | 89 MojoWriteDataFlags flags); |
89 MojoResult BeginWriteData(void** buffer, | 90 MojoResult BeginWriteData(void** buffer, |
90 uint32_t* buffer_num_bytes, | 91 uint32_t* buffer_num_bytes, |
91 MojoWriteDataFlags flags); | 92 MojoWriteDataFlags flags); |
92 MojoResult EndWriteData(uint32_t num_bytes_written); | 93 MojoResult EndWriteData(uint32_t num_bytes_written); |
93 MojoResult ReadData(void* elements, | 94 MojoResult ReadData(void* elements, |
94 uint32_t* num_bytes, | 95 uint32_t* num_bytes, |
95 MojoReadDataFlags flags); | 96 MojoReadDataFlags flags); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 199 |
199 // These are to be overridden by subclasses (if necessary). They are never | 200 // These are to be overridden by subclasses (if necessary). They are never |
200 // called after the dispatcher has been closed. They are called under |lock_|. | 201 // called after the dispatcher has been closed. They are called under |lock_|. |
201 // See the descriptions of the methods without the "ImplNoLock" for more | 202 // See the descriptions of the methods without the "ImplNoLock" for more |
202 // information. | 203 // information. |
203 virtual MojoResult WriteMessageImplNoLock( | 204 virtual MojoResult WriteMessageImplNoLock( |
204 const void* bytes, | 205 const void* bytes, |
205 uint32_t num_bytes, | 206 uint32_t num_bytes, |
206 std::vector<DispatcherTransport>* transports, | 207 std::vector<DispatcherTransport>* transports, |
207 MojoWriteMessageFlags flags); | 208 MojoWriteMessageFlags flags); |
208 virtual MojoResult ReadMessageImplNoLock( | 209 virtual MojoResult ReadMessageImplNoLock(void* bytes, |
209 void* bytes, | 210 uint32_t* num_bytes, |
210 uint32_t* num_bytes, | 211 DispatcherVector* dispatchers, |
211 std::vector<scoped_refptr<Dispatcher> >* dispatchers, | 212 uint32_t* num_dispatchers, |
212 uint32_t* num_dispatchers, | 213 MojoReadMessageFlags flags); |
213 MojoReadMessageFlags flags); | |
214 virtual MojoResult WriteDataImplNoLock(const void* elements, | 214 virtual MojoResult WriteDataImplNoLock(const void* elements, |
215 uint32_t* num_bytes, | 215 uint32_t* num_bytes, |
216 MojoWriteDataFlags flags); | 216 MojoWriteDataFlags flags); |
217 virtual MojoResult BeginWriteDataImplNoLock(void** buffer, | 217 virtual MojoResult BeginWriteDataImplNoLock(void** buffer, |
218 uint32_t* buffer_num_bytes, | 218 uint32_t* buffer_num_bytes, |
219 MojoWriteDataFlags flags); | 219 MojoWriteDataFlags flags); |
220 virtual MojoResult EndWriteDataImplNoLock(uint32_t num_bytes_written); | 220 virtual MojoResult EndWriteDataImplNoLock(uint32_t num_bytes_written); |
221 virtual MojoResult ReadDataImplNoLock(void* elements, | 221 virtual MojoResult ReadDataImplNoLock(void* elements, |
222 uint32_t* num_bytes, | 222 uint32_t* num_bytes, |
223 MojoReadDataFlags flags); | 223 MojoReadDataFlags flags); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 Dispatcher* dispatcher_; | 362 Dispatcher* dispatcher_; |
363 | 363 |
364 // Copy and assign allowed. | 364 // Copy and assign allowed. |
365 }; | 365 }; |
366 | 366 |
367 } // namespace system | 367 } // namespace system |
368 } // namespace mojo | 368 } // namespace mojo |
369 | 369 |
370 #endif // MOJO_SYSTEM_DISPATCHER_H_ | 370 #endif // MOJO_SYSTEM_DISPATCHER_H_ |
OLD | NEW |