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 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "mojo/embedder/platform_handle.h" | 17 #include "mojo/embedder/platform_handle.h" |
18 #include "mojo/embedder/platform_handle_vector.h" | 18 #include "mojo/embedder/platform_handle_vector.h" |
19 #include "mojo/public/c/system/buffer.h" | 19 #include "mojo/public/c/system/buffer.h" |
20 #include "mojo/public/c/system/data_pipe.h" | 20 #include "mojo/public/c/system/data_pipe.h" |
21 #include "mojo/public/c/system/message_pipe.h" | 21 #include "mojo/public/c/system/message_pipe.h" |
22 #include "mojo/public/c/system/types.h" | 22 #include "mojo/public/c/system/types.h" |
23 #include "mojo/system/handle_signals_state.h" | 23 #include "mojo/system/handle_signals_state.h" |
24 #include "mojo/system/memory.h" | 24 #include "mojo/system/memory.h" |
25 #include "mojo/system/system_impl_export.h" | 25 #include "mojo/system/system_impl_export.h" |
26 | 26 |
27 namespace mojo { | 27 namespace mojo { |
| 28 |
| 29 namespace embedder { |
| 30 class PlatformSharedBufferMapping; |
| 31 } |
| 32 |
28 namespace system { | 33 namespace system { |
29 | 34 |
30 class Channel; | 35 class Channel; |
31 class Core; | 36 class Core; |
32 class Dispatcher; | 37 class Dispatcher; |
33 class DispatcherTransport; | 38 class DispatcherTransport; |
34 class HandleTable; | 39 class HandleTable; |
35 class LocalMessagePipeEndpoint; | 40 class LocalMessagePipeEndpoint; |
36 class ProxyMessagePipeEndpoint; | 41 class ProxyMessagePipeEndpoint; |
37 class RawSharedBufferMapping; | |
38 class TransportData; | 42 class TransportData; |
39 class Waiter; | 43 class Waiter; |
40 | 44 |
41 typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector; | 45 typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector; |
42 | 46 |
43 namespace test { | 47 namespace test { |
44 | 48 |
45 // Test helper. We need to declare it here so we can friend it. | 49 // Test helper. We need to declare it here so we can friend it. |
46 MOJO_SYSTEM_IMPL_EXPORT DispatcherTransport | 50 MOJO_SYSTEM_IMPL_EXPORT DispatcherTransport |
47 DispatcherTryStartTransport(Dispatcher* dispatcher); | 51 DispatcherTryStartTransport(Dispatcher* dispatcher); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 MojoResult BeginReadData(UserPointer<const void*> buffer, | 110 MojoResult BeginReadData(UserPointer<const void*> buffer, |
107 UserPointer<uint32_t> buffer_num_bytes, | 111 UserPointer<uint32_t> buffer_num_bytes, |
108 MojoReadDataFlags flags); | 112 MojoReadDataFlags flags); |
109 MojoResult EndReadData(uint32_t num_bytes_read); | 113 MojoResult EndReadData(uint32_t num_bytes_read); |
110 // |options| may be null. |new_dispatcher| must not be null, but | 114 // |options| may be null. |new_dispatcher| must not be null, but |
111 // |*new_dispatcher| should be null (and will contain the dispatcher for the | 115 // |*new_dispatcher| should be null (and will contain the dispatcher for the |
112 // new handle on success). | 116 // new handle on success). |
113 MojoResult DuplicateBufferHandle( | 117 MojoResult DuplicateBufferHandle( |
114 UserPointer<const MojoDuplicateBufferHandleOptions> options, | 118 UserPointer<const MojoDuplicateBufferHandleOptions> options, |
115 scoped_refptr<Dispatcher>* new_dispatcher); | 119 scoped_refptr<Dispatcher>* new_dispatcher); |
116 MojoResult MapBuffer(uint64_t offset, | 120 MojoResult MapBuffer( |
117 uint64_t num_bytes, | 121 uint64_t offset, |
118 MojoMapBufferFlags flags, | 122 uint64_t num_bytes, |
119 scoped_ptr<RawSharedBufferMapping>* mapping); | 123 MojoMapBufferFlags flags, |
| 124 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping); |
120 | 125 |
121 // Gets the current handle signals state. (The default implementation simply | 126 // Gets the current handle signals state. (The default implementation simply |
122 // returns a default-constructed |HandleSignalsState|, i.e., no signals | 127 // returns a default-constructed |HandleSignalsState|, i.e., no signals |
123 // satisfied or satisfiable.) Note: The state is subject to change from other | 128 // satisfied or satisfiable.) Note: The state is subject to change from other |
124 // threads. | 129 // threads. |
125 HandleSignalsState GetHandleSignalsState() const; | 130 HandleSignalsState GetHandleSignalsState() const; |
126 | 131 |
127 // Adds a waiter to this dispatcher. The waiter will be woken up when this | 132 // Adds a waiter to this dispatcher. The waiter will be woken up when this |
128 // object changes state to satisfy |signals| with context |context|. It will | 133 // object changes state to satisfy |signals| with context |context|. It will |
129 // also be woken up when it becomes impossible for the object to ever satisfy | 134 // also be woken up when it becomes impossible for the object to ever satisfy |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 UserPointer<uint32_t> buffer_num_bytes, | 258 UserPointer<uint32_t> buffer_num_bytes, |
254 MojoReadDataFlags flags); | 259 MojoReadDataFlags flags); |
255 virtual MojoResult EndReadDataImplNoLock(uint32_t num_bytes_read); | 260 virtual MojoResult EndReadDataImplNoLock(uint32_t num_bytes_read); |
256 virtual MojoResult DuplicateBufferHandleImplNoLock( | 261 virtual MojoResult DuplicateBufferHandleImplNoLock( |
257 UserPointer<const MojoDuplicateBufferHandleOptions> options, | 262 UserPointer<const MojoDuplicateBufferHandleOptions> options, |
258 scoped_refptr<Dispatcher>* new_dispatcher); | 263 scoped_refptr<Dispatcher>* new_dispatcher); |
259 virtual MojoResult MapBufferImplNoLock( | 264 virtual MojoResult MapBufferImplNoLock( |
260 uint64_t offset, | 265 uint64_t offset, |
261 uint64_t num_bytes, | 266 uint64_t num_bytes, |
262 MojoMapBufferFlags flags, | 267 MojoMapBufferFlags flags, |
263 scoped_ptr<RawSharedBufferMapping>* mapping); | 268 scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping); |
264 virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const; | 269 virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const; |
265 virtual MojoResult AddWaiterImplNoLock(Waiter* waiter, | 270 virtual MojoResult AddWaiterImplNoLock(Waiter* waiter, |
266 MojoHandleSignals signals, | 271 MojoHandleSignals signals, |
267 uint32_t context, | 272 uint32_t context, |
268 HandleSignalsState* signals_state); | 273 HandleSignalsState* signals_state); |
269 virtual void RemoveWaiterImplNoLock(Waiter* waiter, | 274 virtual void RemoveWaiterImplNoLock(Waiter* waiter, |
270 HandleSignalsState* signals_state); | 275 HandleSignalsState* signals_state); |
271 | 276 |
272 // These implement the API used to serialize dispatchers to a |Channel| | 277 // These implement the API used to serialize dispatchers to a |Channel| |
273 // (described below). They will only be called on a dispatcher that's attached | 278 // (described below). They will only be called on a dispatcher that's attached |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 396 |
392 Dispatcher* dispatcher_; | 397 Dispatcher* dispatcher_; |
393 | 398 |
394 // Copy and assign allowed. | 399 // Copy and assign allowed. |
395 }; | 400 }; |
396 | 401 |
397 } // namespace system | 402 } // namespace system |
398 } // namespace mojo | 403 } // namespace mojo |
399 | 404 |
400 #endif // MOJO_SYSTEM_DISPATCHER_H_ | 405 #endif // MOJO_SYSTEM_DISPATCHER_H_ |
OLD | NEW |