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 #include "mojo/system/message_pipe_dispatcher.h" | 5 #include "mojo/system/message_pipe_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/system/channel.h" | 8 #include "mojo/system/channel.h" |
9 #include "mojo/system/constants.h" | 9 #include "mojo/system/constants.h" |
10 #include "mojo/system/local_message_pipe_endpoint.h" | 10 #include "mojo/system/local_message_pipe_endpoint.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE | 36 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE |
37 }; | 37 }; |
38 | 38 |
39 MessagePipeDispatcher::MessagePipeDispatcher( | 39 MessagePipeDispatcher::MessagePipeDispatcher( |
40 const MojoCreateMessagePipeOptions& /*validated_options*/) | 40 const MojoCreateMessagePipeOptions& /*validated_options*/) |
41 : port_(kInvalidPort) { | 41 : port_(kInvalidPort) { |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 MojoResult MessagePipeDispatcher::ValidateCreateOptions( | 45 MojoResult MessagePipeDispatcher::ValidateCreateOptions( |
46 const MojoCreateMessagePipeOptions* in_options, | 46 UserPointer<const MojoCreateMessagePipeOptions> in_options, |
47 MojoCreateMessagePipeOptions* out_options) { | 47 MojoCreateMessagePipeOptions* out_options) { |
48 const MojoCreateMessagePipeOptionsFlags kKnownFlags = | 48 const MojoCreateMessagePipeOptionsFlags kKnownFlags = |
49 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE; | 49 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE; |
50 | 50 |
51 *out_options = kDefaultCreateOptions; | 51 *out_options = kDefaultCreateOptions; |
52 if (!in_options) | 52 if (in_options.IsNull()) |
53 return MOJO_RESULT_OK; | 53 return MOJO_RESULT_OK; |
54 | 54 |
55 MojoResult result = | 55 UserOptionsReader<MojoCreateMessagePipeOptions> reader(in_options); |
56 ValidateOptionsStructPointerSizeAndFlags<MojoCreateMessagePipeOptions>( | 56 if (!reader.is_valid()) |
57 in_options, kKnownFlags, out_options); | 57 return MOJO_RESULT_INVALID_ARGUMENT; |
58 if (result != MOJO_RESULT_OK) | 58 |
59 return result; | 59 if (!OPTIONS_STRUCT_HAS_MEMBER(MojoCreateMessagePipeOptions, flags, reader)) |
| 60 return MOJO_RESULT_OK; |
| 61 if ((reader.options().flags & ~kKnownFlags)) |
| 62 return MOJO_RESULT_UNIMPLEMENTED; |
| 63 out_options->flags = reader.options().flags; |
60 | 64 |
61 // Checks for fields beyond |flags|: | 65 // Checks for fields beyond |flags|: |
62 | 66 |
63 // (Nothing here yet.) | 67 // (Nothing here yet.) |
64 | 68 |
65 return MOJO_RESULT_OK; | 69 return MOJO_RESULT_OK; |
66 } | 70 } |
67 | 71 |
68 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe, | 72 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe, |
69 unsigned port) { | 73 unsigned port) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 266 |
263 // MessagePipeDispatcherTransport ---------------------------------------------- | 267 // MessagePipeDispatcherTransport ---------------------------------------------- |
264 | 268 |
265 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 269 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
266 DispatcherTransport transport) : DispatcherTransport(transport) { | 270 DispatcherTransport transport) : DispatcherTransport(transport) { |
267 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 271 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
268 } | 272 } |
269 | 273 |
270 } // namespace system | 274 } // namespace system |
271 } // namespace mojo | 275 } // namespace mojo |
OLD | NEW |