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

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

Issue 133453003: Mojo: Change "handle_[01]" -> "handle[01]". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 6 years, 11 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_impl.h ('k') | no next file » | 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_impl.h" 5 #include "mojo/system/core_impl.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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return MOJO_RESULT_INVALID_ARGUMENT; 141 return MOJO_RESULT_INVALID_ARGUMENT;
142 if (!VerifyUserPointer<MojoWaitFlags>(flags, num_handles)) 142 if (!VerifyUserPointer<MojoWaitFlags>(flags, num_handles))
143 return MOJO_RESULT_INVALID_ARGUMENT; 143 return MOJO_RESULT_INVALID_ARGUMENT;
144 if (num_handles < 1) 144 if (num_handles < 1)
145 return MOJO_RESULT_INVALID_ARGUMENT; 145 return MOJO_RESULT_INVALID_ARGUMENT;
146 if (num_handles > kMaxWaitManyNumHandles) 146 if (num_handles > kMaxWaitManyNumHandles)
147 return MOJO_RESULT_RESOURCE_EXHAUSTED; 147 return MOJO_RESULT_RESOURCE_EXHAUSTED;
148 return WaitManyInternal(handles, flags, num_handles, deadline); 148 return WaitManyInternal(handles, flags, num_handles, deadline);
149 } 149 }
150 150
151 MojoResult CoreImpl::CreateMessagePipe(MojoHandle* message_pipe_handle_0, 151 MojoResult CoreImpl::CreateMessagePipe(MojoHandle* message_pipe_handle0,
152 MojoHandle* message_pipe_handle_1) { 152 MojoHandle* message_pipe_handle1) {
153 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle_0, 1)) 153 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle0, 1))
154 return MOJO_RESULT_INVALID_ARGUMENT; 154 return MOJO_RESULT_INVALID_ARGUMENT;
155 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle_1, 1)) 155 if (!VerifyUserPointer<MojoHandle>(message_pipe_handle1, 1))
156 return MOJO_RESULT_INVALID_ARGUMENT; 156 return MOJO_RESULT_INVALID_ARGUMENT;
157 157
158 scoped_refptr<MessagePipeDispatcher> dispatcher_0( 158 scoped_refptr<MessagePipeDispatcher> dispatcher_0(
159 new MessagePipeDispatcher()); 159 new MessagePipeDispatcher());
160 scoped_refptr<MessagePipeDispatcher> dispatcher_1( 160 scoped_refptr<MessagePipeDispatcher> dispatcher_1(
161 new MessagePipeDispatcher()); 161 new MessagePipeDispatcher());
162 162
163 MojoHandle h0, h1; 163 MojoHandle h0, h1;
164 { 164 {
165 base::AutoLock locker(handle_table_lock_); 165 base::AutoLock locker(handle_table_lock_);
166 166
167 h0 = AddDispatcherNoLock(dispatcher_0); 167 h0 = AddDispatcherNoLock(dispatcher_0);
168 if (h0 == MOJO_HANDLE_INVALID) 168 if (h0 == MOJO_HANDLE_INVALID)
169 return MOJO_RESULT_RESOURCE_EXHAUSTED; 169 return MOJO_RESULT_RESOURCE_EXHAUSTED;
170 170
171 h1 = AddDispatcherNoLock(dispatcher_1); 171 h1 = AddDispatcherNoLock(dispatcher_1);
172 if (h1 == MOJO_HANDLE_INVALID) { 172 if (h1 == MOJO_HANDLE_INVALID) {
173 handle_table_.erase(h0); 173 handle_table_.erase(h0);
174 return MOJO_RESULT_RESOURCE_EXHAUSTED; 174 return MOJO_RESULT_RESOURCE_EXHAUSTED;
175 } 175 }
176 } 176 }
177 177
178 scoped_refptr<MessagePipe> message_pipe(new MessagePipe()); 178 scoped_refptr<MessagePipe> message_pipe(new MessagePipe());
179 dispatcher_0->Init(message_pipe, 0); 179 dispatcher_0->Init(message_pipe, 0);
180 dispatcher_1->Init(message_pipe, 1); 180 dispatcher_1->Init(message_pipe, 1);
181 181
182 *message_pipe_handle_0 = h0; 182 *message_pipe_handle0 = h0;
183 *message_pipe_handle_1 = h1; 183 *message_pipe_handle1 = h1;
184 return MOJO_RESULT_OK; 184 return MOJO_RESULT_OK;
185 } 185 }
186 186
187 MojoResult CoreImpl::WriteMessage(MojoHandle message_pipe_handle, 187 MojoResult CoreImpl::WriteMessage(MojoHandle message_pipe_handle,
188 const void* bytes, 188 const void* bytes,
189 uint32_t num_bytes, 189 uint32_t num_bytes,
190 const MojoHandle* handles, 190 const MojoHandle* handles,
191 uint32_t num_handles, 191 uint32_t num_handles,
192 MojoWriteMessageFlags flags) { 192 MojoWriteMessageFlags flags) {
193 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(message_pipe_handle)); 193 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(message_pipe_handle));
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be 563 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be
564 // destroyed, but this would still be required if the waiter were in TLS.) 564 // destroyed, but this would still be required if the waiter were in TLS.)
565 for (i = 0; i < num_added; i++) 565 for (i = 0; i < num_added; i++)
566 dispatchers[i]->RemoveWaiter(&waiter); 566 dispatchers[i]->RemoveWaiter(&waiter);
567 567
568 return rv; 568 return rv;
569 } 569 }
570 570
571 } // namespace system 571 } // namespace system
572 } // namespace mojo 572 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/core_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698