| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace system { | 28 namespace system { |
| 29 | 29 |
| 30 // 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 |
| 31 // 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 |
| 32 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). | 32 // (which would entail overriding |GetHandleSignalsStateImplNoLock()|, etc.). |
| 33 class SharedBufferDispatcher final : public SimpleDispatcher { | 33 class SharedBufferDispatcher final : public SimpleDispatcher { |
| 34 public: | 34 public: |
| 35 // The default/standard rights for a shared buffer handle. Note that they're | 35 // The default/standard rights for a shared buffer handle. Note that they're |
| 36 // duplicable by default. | 36 // duplicatable by default. |
| 37 static constexpr MojoHandleRights kDefaultHandleRights = | 37 static constexpr MojoHandleRights kDefaultHandleRights = |
| 38 MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER | | 38 MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER | |
| 39 MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS | | 39 MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS | |
| 40 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE | | 40 MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE | |
| 41 MOJO_HANDLE_RIGHT_MAP_EXECUTABLE; | 41 MOJO_HANDLE_RIGHT_MAP_EXECUTABLE; |
| 42 | 42 |
| 43 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses | 43 // The default options to use for |MojoCreateSharedBuffer()|. (Real uses |
| 44 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; | 44 // should obtain this via |ValidateCreateOptions()| with a null |in_options|; |
| 45 // this is exposed directly for testing convenience.) | 45 // this is exposed directly for testing convenience.) |
| 46 static const MojoCreateSharedBufferOptions kDefaultCreateOptions; | 46 static const MojoCreateSharedBufferOptions kDefaultCreateOptions; |
| 47 | 47 |
| 48 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|. | 48 // Validates and/or sets default options for |MojoCreateSharedBufferOptions|. |
| 49 // If non-null, |in_options| must point to a struct of at least | 49 // If non-null, |in_options| must point to a struct of at least |
| 50 // |in_options->struct_size| bytes. |out_options| must point to a (current) | 50 // |in_options->struct_size| bytes. |out_options| must point to a (current) |
| 51 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success | 51 // |MojoCreateSharedBufferOptions| and will be entirely overwritten on success |
| 52 // (it may be partly overwritten on failure). | 52 // (it may be partly overwritten on failure). |
| 53 static MojoResult ValidateCreateOptions( | 53 static MojoResult ValidateCreateOptions( |
| 54 UserPointer<const MojoCreateSharedBufferOptions> in_options, | 54 UserPointer<const MojoCreateSharedBufferOptions> in_options, |
| 55 MojoCreateSharedBufferOptions* out_options); | 55 MojoCreateSharedBufferOptions* out_options); |
| 56 | 56 |
| 57 // Static factory method: |validated_options| must be validated (obviously). | 57 // Static factory method: |validated_options| must be validated (obviously). |
| 58 // Returns null on error; |*result| will be set to an appropriate result | 58 // Returns null on error; |*result| will be set to an appropriate result code. |
| 59 // code). | |
| 60 static util::RefPtr<SharedBufferDispatcher> Create( | 59 static util::RefPtr<SharedBufferDispatcher> Create( |
| 61 embedder::PlatformSupport* platform_support, | 60 embedder::PlatformSupport* platform_support, |
| 62 const MojoCreateSharedBufferOptions& validated_options, | 61 const MojoCreateSharedBufferOptions& validated_options, |
| 63 uint64_t num_bytes, | 62 uint64_t num_bytes, |
| 64 MojoResult* result); | 63 MojoResult* result); |
| 65 | 64 |
| 66 // |Dispatcher| public methods: | 65 // |Dispatcher| public methods: |
| 67 Type GetType() const override; | 66 Type GetType() const override; |
| 68 bool SupportsEntrypointClass(EntrypointClass entrypoint_class) const override; | 67 bool SupportsEntrypointClass(EntrypointClass entrypoint_class) const override; |
| 69 | 68 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 util::RefPtr<platform::PlatformSharedBuffer> shared_buffer_ | 125 util::RefPtr<platform::PlatformSharedBuffer> shared_buffer_ |
| 127 MOJO_GUARDED_BY(mutex()); | 126 MOJO_GUARDED_BY(mutex()); |
| 128 | 127 |
| 129 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); | 128 MOJO_DISALLOW_COPY_AND_ASSIGN(SharedBufferDispatcher); |
| 130 }; | 129 }; |
| 131 | 130 |
| 132 } // namespace system | 131 } // namespace system |
| 133 } // namespace mojo | 132 } // namespace mojo |
| 134 | 133 |
| 135 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ | 134 #endif // MOJO_EDK_SYSTEM_SHARED_BUFFER_DISPATCHER_H_ |
| OLD | NEW |