| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "mojo/edk/system/wait_set_dispatcher.h" | 5 #include "mojo/edk/system/wait_set_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/edk/system/options_validation.h" | 8 #include "mojo/edk/system/options_validation.h" |
| 9 | 9 |
| 10 using mojo::util::MutexLocker; | 10 using mojo::util::MutexLocker; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 return MOJO_RESULT_UNIMPLEMENTED; | 42 return MOJO_RESULT_UNIMPLEMENTED; |
| 43 out_options->flags = reader.options().flags; | 43 out_options->flags = reader.options().flags; |
| 44 | 44 |
| 45 // Checks for fields beyond |flags|: | 45 // Checks for fields beyond |flags|: |
| 46 | 46 |
| 47 // (Nothing here yet.) | 47 // (Nothing here yet.) |
| 48 | 48 |
| 49 return MOJO_RESULT_OK; | 49 return MOJO_RESULT_OK; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static |
| 53 MojoResult WaitSetDispatcher::ValidateWaitSetAddOptions( |
| 54 UserPointer<const MojoWaitSetAddOptions> in_options, |
| 55 MojoWaitSetAddOptions* out_options) { |
| 56 const MojoWaitSetAddOptionsFlags kKnownFlags = |
| 57 MOJO_WAIT_SET_ADD_OPTIONS_FLAG_NONE; |
| 58 static const MojoWaitSetAddOptions kDefaultOptions = { |
| 59 static_cast<uint32_t>(sizeof(MojoWaitSetAddOptions)), |
| 60 MOJO_WAIT_SET_ADD_OPTIONS_FLAG_NONE}; |
| 61 |
| 62 *out_options = kDefaultOptions; |
| 63 if (in_options.IsNull()) |
| 64 return MOJO_RESULT_OK; |
| 65 |
| 66 UserOptionsReader<MojoWaitSetAddOptions> reader(in_options); |
| 67 if (!reader.is_valid()) |
| 68 return MOJO_RESULT_INVALID_ARGUMENT; |
| 69 |
| 70 if (!OPTIONS_STRUCT_HAS_MEMBER(MojoWaitSetAddOptions, flags, reader)) |
| 71 return MOJO_RESULT_OK; |
| 72 if ((reader.options().flags & ~kKnownFlags)) |
| 73 return MOJO_RESULT_UNIMPLEMENTED; |
| 74 out_options->flags = reader.options().flags; |
| 75 |
| 76 // Checks for fields beyond |flags|: |
| 77 |
| 78 // (Nothing here yet.) |
| 79 |
| 80 return MOJO_RESULT_OK; |
| 81 } |
| 82 |
| 52 Dispatcher::Type WaitSetDispatcher::GetType() const { | 83 Dispatcher::Type WaitSetDispatcher::GetType() const { |
| 53 return Type::WAIT_SET; | 84 return Type::WAIT_SET; |
| 54 } | 85 } |
| 55 | 86 |
| 56 bool WaitSetDispatcher::SupportsEntrypointClass( | 87 bool WaitSetDispatcher::SupportsEntrypointClass( |
| 57 EntrypointClass entrypoint_class) const { | 88 EntrypointClass entrypoint_class) const { |
| 58 return (entrypoint_class == EntrypointClass::NONE || | 89 return (entrypoint_class == EntrypointClass::NONE || |
| 59 entrypoint_class == EntrypointClass::WAIT_SET); | 90 entrypoint_class == EntrypointClass::WAIT_SET); |
| 60 } | 91 } |
| 61 | 92 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 } | 104 } |
| 74 | 105 |
| 75 MojoResult WaitSetDispatcher::WaitSetAddImpl( | 106 MojoResult WaitSetDispatcher::WaitSetAddImpl( |
| 76 UserPointer<const MojoWaitSetAddOptions> options, | 107 UserPointer<const MojoWaitSetAddOptions> options, |
| 77 Handle&& handle, | 108 Handle&& handle, |
| 78 MojoHandleSignals signals, | 109 MojoHandleSignals signals, |
| 79 uint64_t cookie) { | 110 uint64_t cookie) { |
| 80 MutexLocker locker(&mutex()); | 111 MutexLocker locker(&mutex()); |
| 81 if (is_closed_no_lock()) | 112 if (is_closed_no_lock()) |
| 82 return MOJO_RESULT_INVALID_ARGUMENT; | 113 return MOJO_RESULT_INVALID_ARGUMENT; |
| 114 MojoWaitSetAddOptions validated_options; |
| 115 MojoResult result = ValidateWaitSetAddOptions(options, &validated_options); |
| 116 if (result != MOJO_RESULT_OK) |
| 117 return result; |
| 83 | 118 |
| 84 // TODO(vtl) | 119 // TODO(vtl) |
| 85 NOTIMPLEMENTED(); | 120 NOTIMPLEMENTED(); |
| 86 return MOJO_RESULT_UNIMPLEMENTED; | 121 return MOJO_RESULT_UNIMPLEMENTED; |
| 87 } | 122 } |
| 88 | 123 |
| 89 MojoResult WaitSetDispatcher::WaitSetRemoveImpl(uint64_t cookie) { | 124 MojoResult WaitSetDispatcher::WaitSetRemoveImpl(uint64_t cookie) { |
| 90 MutexLocker locker(&mutex()); | 125 MutexLocker locker(&mutex()); |
| 91 if (is_closed_no_lock()) | 126 if (is_closed_no_lock()) |
| 92 return MOJO_RESULT_INVALID_ARGUMENT; | 127 return MOJO_RESULT_INVALID_ARGUMENT; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 if (is_closed_no_lock()) | 140 if (is_closed_no_lock()) |
| 106 return MOJO_RESULT_INVALID_ARGUMENT; | 141 return MOJO_RESULT_INVALID_ARGUMENT; |
| 107 | 142 |
| 108 // TODO(vtl) | 143 // TODO(vtl) |
| 109 NOTIMPLEMENTED(); | 144 NOTIMPLEMENTED(); |
| 110 return MOJO_RESULT_UNIMPLEMENTED; | 145 return MOJO_RESULT_UNIMPLEMENTED; |
| 111 } | 146 } |
| 112 | 147 |
| 113 } // namespace system | 148 } // namespace system |
| 114 } // namespace mojo | 149 } // namespace mojo |
| OLD | NEW |