OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SHARED_BUFFER_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ |
6 #define MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "mojo/edk/system/memory.h" | 10 #include "mojo/edk/system/memory.h" |
11 #include "mojo/edk/system/simple_dispatcher.h" | 11 #include "mojo/edk/system/simple_dispatcher.h" |
12 #include "mojo/edk/util/ref_ptr.h" | 12 #include "mojo/edk/util/ref_ptr.h" |
13 #include "mojo/edk/util/thread_annotations.h" | 13 #include "mojo/edk/util/thread_annotations.h" |
| 14 #include "mojo/public/c/system/handle.h" |
14 #include "mojo/public/cpp/system/macros.h" | 15 #include "mojo/public/cpp/system/macros.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 | 18 |
18 namespace embedder { | 19 namespace embedder { |
19 class PlatformSupport; | 20 class PlatformSupport; |
20 } | 21 } |
21 | 22 |
22 namespace platform { | 23 namespace platform { |
23 class PlatformSharedBuffer; | 24 class PlatformSharedBuffer; |
24 class PlatformSharedBufferMapping; | 25 class PlatformSharedBufferMapping; |
25 } | 26 } |
26 | 27 |
27 namespace system { | 28 namespace system { |
28 | 29 |
29 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently | 30 // TODO(vtl): We derive from SimpleDispatcher, even though we don't currently |
30 // have anything that's waitable. I want to add a "transferrable" wait flag | 31 // have anything that's waitable. I want to add a "transferrable" wait flag |
31 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). | 32 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). |
32 class SharedBufferDispatcher final : public SimpleDispatcher { | 33 class SharedBufferDispatcher final : public SimpleDispatcher { |
33 public: | 34 public: |
| 35 // The default/standard rights for a shared buffer handle. Note that they're |
| 36 // duplicable by default. |
| 37 static constexpr MojoHandleRights kDefaultHandleRights = |
| 38 MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER | |
| 39 MOJO_HANDLE_RIGHT_READ | MOJO_HANDLE_RIGHT_WRITE | |
| 40 MOJO_HANDLE_RIGHT_EXECUTE; |
| 41 |
34 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses | 42 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses |
35 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; | 43 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; |
36 // this is exposed directly for testing convenience.) | 44 // this is exposed directly for testing convenience.) |
37 static const MojoCreateSharedBufferOptions kDefaultCreateOptions; | 45 static const MojoCreateSharedBufferOptions kDefaultCreateOptions; |
38 | 46 |
39 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|. | 47 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|. |
40 // If non-null, |in_options| must point to a struct of at least | 48 // If non-null, |in_options| must point to a struct of at least |
41 // |in_options->struct_size| bytes. |out_options| must point to a (current) | 49 // |in_options->struct_size| bytes. |out_options| must point to a (current) |
42 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success | 50 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success |
43 // (it may be partly overwritten on failure). | 51 // (it may be partly overwritten on failure). |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 util::RefPtr<platform::PlatformSharedBuffer> shared_buffer_ | 123 util::RefPtr<platform::PlatformSharedBuffer> shared_buffer_ |
116 MOJO_GUARDED_BY(mutex()); | 124 MOJO_GUARDED_BY(mutex()); |
117 | 125 |
118 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); | 126 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); |
119 }; | 127 }; |
120 | 128 |
121 } // namespace system | 129 } // namespace system |
122 } // namespace mojo | 130 } // namespace mojo |
123 | 131 |
124 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ | 132 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ |
OLD | NEW |