Index: mojo/system/message_pipe_dispatcher.cc |
diff --git a/mojo/system/message_pipe_dispatcher.cc b/mojo/system/message_pipe_dispatcher.cc |
index 89bc16abb13f9089e9f251eab6a1c8775eb3d0f4..8bd7ba0e6045c4b6b996ea04d625dd16a74ed746 100644 |
--- a/mojo/system/message_pipe_dispatcher.cc |
+++ b/mojo/system/message_pipe_dispatcher.cc |
@@ -11,6 +11,7 @@ |
#include "mojo/system/memory.h" |
#include "mojo/system/message_in_transit.h" |
#include "mojo/system/message_pipe.h" |
+#include "mojo/system/options_validation.h" |
#include "mojo/system/proxy_message_pipe_endpoint.h" |
namespace mojo { |
@@ -28,10 +29,42 @@ struct SerializedMessagePipeDispatcher { |
// MessagePipeDispatcher ------------------------------------------------------- |
-MessagePipeDispatcher::MessagePipeDispatcher() |
+// static |
+const MojoCreateMessagePipeOptions |
+ MessagePipeDispatcher::kDefaultCreateOptions = { |
+ static_cast<uint32_t>(sizeof(MojoCreateMessagePipeOptions)), |
+ MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE |
+}; |
+ |
+MessagePipeDispatcher::MessagePipeDispatcher( |
+ const MojoCreateMessagePipeOptions& /*validated_options*/) |
: port_(kInvalidPort) { |
} |
+// static |
+MojoResult MessagePipeDispatcher::ValidateCreateOptions( |
+ const MojoCreateMessagePipeOptions* in_options, |
+ MojoCreateMessagePipeOptions* out_options) { |
+ const MojoCreateMessagePipeOptionsFlags kKnownFlags = |
+ MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE; |
+ |
+ *out_options = kDefaultCreateOptions; |
+ if (!in_options) |
+ return MOJO_RESULT_OK; |
+ |
+ MojoResult result = |
+ ValidateOptionsStructPointerSizeAndFlags<MojoCreateMessagePipeOptions>( |
+ in_options, kKnownFlags, out_options); |
+ if (result != MOJO_RESULT_OK) |
+ return result; |
+ |
+ // Checks for fields beyond |flags|: |
+ |
+ // (Nothing here yet.) |
+ |
+ return MOJO_RESULT_OK; |
+} |
+ |
void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe, |
unsigned port) { |
DCHECK(message_pipe); |
@@ -52,7 +85,8 @@ MessagePipeDispatcher::CreateRemoteMessagePipe() { |
new MessagePipe( |
scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), |
scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); |
- scoped_refptr<MessagePipeDispatcher> dispatcher(new MessagePipeDispatcher()); |
+ scoped_refptr<MessagePipeDispatcher> dispatcher(new MessagePipeDispatcher( |
+ MessagePipeDispatcher::kDefaultCreateOptions)); |
dispatcher->Init(message_pipe, 0); |
return std::make_pair(dispatcher, message_pipe); |
@@ -133,7 +167,11 @@ scoped_refptr<Dispatcher> |
MessagePipeDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
lock().AssertAcquired(); |
- scoped_refptr<MessagePipeDispatcher> rv = new MessagePipeDispatcher(); |
+ // TODO(vtl): Currently, there are no options, so we just use |
+ // |kDefaultCreateOptions|. Eventually, we'll have to duplicate the options |
+ // too. |
+ scoped_refptr<MessagePipeDispatcher> rv = |
+ new MessagePipeDispatcher(kDefaultCreateOptions); |
rv->Init(message_pipe_, port_); |
message_pipe_ = NULL; |
port_ = kInvalidPort; |