| 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/public/c/system/core.h" | 17 #include "mojo/public/c/system/core.h" |
| 18 // TODO(vtl): We need this since we can't forward declare | |
| 19 // |RawSharedBuffer::Mapping|. Maybe fix this. | |
| 20 #include "mojo/system/raw_shared_buffer.h" | |
| 21 #include "mojo/system/system_impl_export.h" | 18 #include "mojo/system/system_impl_export.h" |
| 22 | 19 |
| 23 namespace mojo { | 20 namespace mojo { |
| 24 namespace system { | 21 namespace system { |
| 25 | 22 |
| 26 class Channel; | 23 class Channel; |
| 27 class CoreImpl; | 24 class CoreImpl; |
| 28 class Dispatcher; | 25 class Dispatcher; |
| 29 class DispatcherTransport; | 26 class DispatcherTransport; |
| 30 class HandleTable; | 27 class HandleTable; |
| 31 class LocalMessagePipeEndpoint; | 28 class LocalMessagePipeEndpoint; |
| 32 class MessageInTransit; | 29 class MessageInTransit; |
| 33 class ProxyMessagePipeEndpoint; | 30 class ProxyMessagePipeEndpoint; |
| 31 class RawSharedBufferMapping; |
| 34 class Waiter; | 32 class Waiter; |
| 35 | 33 |
| 36 namespace test { | 34 namespace test { |
| 37 | 35 |
| 38 // Test helper. We need to declare it here so we can friend it. | 36 // Test helper. We need to declare it here so we can friend it. |
| 39 MOJO_SYSTEM_IMPL_EXPORT DispatcherTransport DispatcherTryStartTransport( | 37 MOJO_SYSTEM_IMPL_EXPORT DispatcherTransport DispatcherTryStartTransport( |
| 40 Dispatcher* dispatcher); | 38 Dispatcher* dispatcher); |
| 41 | 39 |
| 42 } // namespace test | 40 } // namespace test |
| 43 | 41 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 MojoResult EndReadData(uint32_t num_bytes_read); | 98 MojoResult EndReadData(uint32_t num_bytes_read); |
| 101 // |options| may be null. |new_dispatcher| must not be null, but | 99 // |options| may be null. |new_dispatcher| must not be null, but |
| 102 // |*new_dispatcher| should be null (and will contain the dispatcher for the | 100 // |*new_dispatcher| should be null (and will contain the dispatcher for the |
| 103 // new handle on success). | 101 // new handle on success). |
| 104 MojoResult DuplicateBufferHandle( | 102 MojoResult DuplicateBufferHandle( |
| 105 const MojoDuplicateBufferHandleOptions* options, | 103 const MojoDuplicateBufferHandleOptions* options, |
| 106 scoped_refptr<Dispatcher>* new_dispatcher); | 104 scoped_refptr<Dispatcher>* new_dispatcher); |
| 107 MojoResult MapBuffer(uint64_t offset, | 105 MojoResult MapBuffer(uint64_t offset, |
| 108 uint64_t num_bytes, | 106 uint64_t num_bytes, |
| 109 MojoMapBufferFlags flags, | 107 MojoMapBufferFlags flags, |
| 110 scoped_ptr<RawSharedBuffer::Mapping>* mapping); | 108 scoped_ptr<RawSharedBufferMapping>* mapping); |
| 111 | 109 |
| 112 // Adds a waiter to this dispatcher. The waiter will be woken up when this | 110 // Adds a waiter to this dispatcher. The waiter will be woken up when this |
| 113 // object changes state to satisfy |flags| with result |wake_result| (which | 111 // object changes state to satisfy |flags| with result |wake_result| (which |
| 114 // must be >= 0, i.e., a success status). It will also be woken up when it | 112 // must be >= 0, i.e., a success status). It will also be woken up when it |
| 115 // becomes impossible for the object to ever satisfy |flags| with a suitable | 113 // becomes impossible for the object to ever satisfy |flags| with a suitable |
| 116 // error status. | 114 // error status. |
| 117 // | 115 // |
| 118 // Returns: | 116 // Returns: |
| 119 // - |MOJO_RESULT_OK| if the waiter was added; | 117 // - |MOJO_RESULT_OK| if the waiter was added; |
| 120 // - |MOJO_RESULT_ALREADY_EXISTS| if |flags| is already satisfied; | 118 // - |MOJO_RESULT_ALREADY_EXISTS| if |flags| is already satisfied; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 uint32_t* buffer_num_bytes, | 220 uint32_t* buffer_num_bytes, |
| 223 MojoReadDataFlags flags); | 221 MojoReadDataFlags flags); |
| 224 virtual MojoResult EndReadDataImplNoLock(uint32_t num_bytes_read); | 222 virtual MojoResult EndReadDataImplNoLock(uint32_t num_bytes_read); |
| 225 virtual MojoResult DuplicateBufferHandleImplNoLock( | 223 virtual MojoResult DuplicateBufferHandleImplNoLock( |
| 226 const MojoDuplicateBufferHandleOptions* options, | 224 const MojoDuplicateBufferHandleOptions* options, |
| 227 scoped_refptr<Dispatcher>* new_dispatcher); | 225 scoped_refptr<Dispatcher>* new_dispatcher); |
| 228 virtual MojoResult MapBufferImplNoLock( | 226 virtual MojoResult MapBufferImplNoLock( |
| 229 uint64_t offset, | 227 uint64_t offset, |
| 230 uint64_t num_bytes, | 228 uint64_t num_bytes, |
| 231 MojoMapBufferFlags flags, | 229 MojoMapBufferFlags flags, |
| 232 scoped_ptr<RawSharedBuffer::Mapping>* mapping); | 230 scoped_ptr<RawSharedBufferMapping>* mapping); |
| 233 virtual MojoResult AddWaiterImplNoLock(Waiter* waiter, | 231 virtual MojoResult AddWaiterImplNoLock(Waiter* waiter, |
| 234 MojoWaitFlags flags, | 232 MojoWaitFlags flags, |
| 235 MojoResult wake_result); | 233 MojoResult wake_result); |
| 236 virtual void RemoveWaiterImplNoLock(Waiter* waiter); | 234 virtual void RemoveWaiterImplNoLock(Waiter* waiter); |
| 237 | 235 |
| 238 // These implement the API used to serialize dispatchers to a |Channel| | 236 // These implement the API used to serialize dispatchers to a |Channel| |
| 239 // (described below). They will only be called on a dispatcher that's attached | 237 // (described below). They will only be called on a dispatcher that's attached |
| 240 // to and "owned" by a |MessageInTransit|. See the non-"impl" versions for | 238 // to and "owned" by a |MessageInTransit|. See the non-"impl" versions for |
| 241 // more information. | 239 // more information. |
| 242 // TODO(vtl): Consider making these pure virtual once most things support | 240 // TODO(vtl): Consider making these pure virtual once most things support |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 331 |
| 334 Dispatcher* dispatcher_; | 332 Dispatcher* dispatcher_; |
| 335 | 333 |
| 336 // Copy and assign allowed. | 334 // Copy and assign allowed. |
| 337 }; | 335 }; |
| 338 | 336 |
| 339 } // namespace system | 337 } // namespace system |
| 340 } // namespace mojo | 338 } // namespace mojo |
| 341 | 339 |
| 342 #endif // MOJO_SYSTEM_DISPATCHER_H_ | 340 #endif // MOJO_SYSTEM_DISPATCHER_H_ |
| OLD | NEW |