Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: mojo/system/core.cc

Issue 324783002: Mojo: Add a MojoCreateMessagePipeOptions struct parameter to MojoCreateMessagePipe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/system/core.h ('k') | mojo/system/core_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/core.h" 5 #include "mojo/system/core.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return MOJO_RESULT_INVALID_ARGUMENT; 131 return MOJO_RESULT_INVALID_ARGUMENT;
132 if (!VerifyUserPointerWithCount<MojoWaitFlags>(flags, num_handles)) 132 if (!VerifyUserPointerWithCount<MojoWaitFlags>(flags, num_handles))
133 return MOJO_RESULT_INVALID_ARGUMENT; 133 return MOJO_RESULT_INVALID_ARGUMENT;
134 if (num_handles < 1) 134 if (num_handles < 1)
135 return MOJO_RESULT_INVALID_ARGUMENT; 135 return MOJO_RESULT_INVALID_ARGUMENT;
136 if (num_handles > kMaxWaitManyNumHandles) 136 if (num_handles > kMaxWaitManyNumHandles)
137 return MOJO_RESULT_RESOURCE_EXHAUSTED; 137 return MOJO_RESULT_RESOURCE_EXHAUSTED;
138 return WaitManyInternal(handles, flags, num_handles, deadline); 138 return WaitManyInternal(handles, flags, num_handles, deadline);
139 } 139 }
140 140
141 MojoResult Core::CreateMessagePipe(MojoHandle* message_pipe_handle0, 141 MojoResult Core::CreateMessagePipe(const MojoCreateMessagePipeOptions* options,
142 MojoHandle* message_pipe_handle0,
142 MojoHandle* message_pipe_handle1) { 143 MojoHandle* message_pipe_handle1) {
144 MojoCreateMessagePipeOptions validated_options = {};
145 // This will verify the |options| pointer.
146 MojoResult result = MessagePipeDispatcher::ValidateCreateOptions(
147 options, &validated_options);
148 if (result != MOJO_RESULT_OK)
149 return result;
143 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle0)) 150 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle0))
144 return MOJO_RESULT_INVALID_ARGUMENT; 151 return MOJO_RESULT_INVALID_ARGUMENT;
145 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle1)) 152 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle1))
146 return MOJO_RESULT_INVALID_ARGUMENT; 153 return MOJO_RESULT_INVALID_ARGUMENT;
147 154
148 scoped_refptr<MessagePipeDispatcher> dispatcher0(new MessagePipeDispatcher()); 155 scoped_refptr<MessagePipeDispatcher> dispatcher0(
149 scoped_refptr<MessagePipeDispatcher> dispatcher1(new MessagePipeDispatcher()); 156 new MessagePipeDispatcher(validated_options));
157 scoped_refptr<MessagePipeDispatcher> dispatcher1(
158 new MessagePipeDispatcher(validated_options));
150 159
151 std::pair<MojoHandle, MojoHandle> handle_pair; 160 std::pair<MojoHandle, MojoHandle> handle_pair;
152 { 161 {
153 base::AutoLock locker(handle_table_lock_); 162 base::AutoLock locker(handle_table_lock_);
154 handle_pair = handle_table_.AddDispatcherPair(dispatcher0, dispatcher1); 163 handle_pair = handle_table_.AddDispatcherPair(dispatcher0, dispatcher1);
155 } 164 }
156 if (handle_pair.first == MOJO_HANDLE_INVALID) { 165 if (handle_pair.first == MOJO_HANDLE_INVALID) {
157 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); 166 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID);
158 LOG(ERROR) << "Handle table full"; 167 LOG(ERROR) << "Handle table full";
159 dispatcher0->Close(); 168 dispatcher0->Close();
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be 550 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be
542 // destroyed, but this would still be required if the waiter were in TLS.) 551 // destroyed, but this would still be required if the waiter were in TLS.)
543 for (i = 0; i < num_added; i++) 552 for (i = 0; i < num_added; i++)
544 dispatchers[i]->RemoveWaiter(&waiter); 553 dispatchers[i]->RemoveWaiter(&waiter);
545 554
546 return rv; 555 return rv;
547 } 556 }
548 557
549 } // namespace system 558 } // namespace system
550 } // namespace mojo 559 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/core.h ('k') | mojo/system/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698