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

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

Issue 414393002: Convert verification of options structs to use the new user pointer handling (see r285350). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: temporarily disable part of OptionsValidationTest.InvalidDeath Created 6 years, 4 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 | « no previous file | mojo/system/data_pipe.h » ('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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 deadline, &result_index); 142 deadline, &result_index);
143 return (result == MOJO_RESULT_OK) ? static_cast<MojoResult>(result_index) : 143 return (result == MOJO_RESULT_OK) ? static_cast<MojoResult>(result_index) :
144 result; 144 result;
145 } 145 }
146 146
147 MojoResult Core::CreateMessagePipe( 147 MojoResult Core::CreateMessagePipe(
148 UserPointer<const MojoCreateMessagePipeOptions> options, 148 UserPointer<const MojoCreateMessagePipeOptions> options,
149 UserPointer<MojoHandle> message_pipe_handle0, 149 UserPointer<MojoHandle> message_pipe_handle0,
150 UserPointer<MojoHandle> message_pipe_handle1) { 150 UserPointer<MojoHandle> message_pipe_handle1) {
151 MojoCreateMessagePipeOptions validated_options = {}; 151 MojoCreateMessagePipeOptions validated_options = {};
152 // This will verify the |options| pointer.
153 MojoResult result = MessagePipeDispatcher::ValidateCreateOptions( 152 MojoResult result = MessagePipeDispatcher::ValidateCreateOptions(
154 options.GetPointerUnsafe(), &validated_options); 153 options, &validated_options);
155 if (result != MOJO_RESULT_OK) 154 if (result != MOJO_RESULT_OK)
156 return result; 155 return result;
157 156
158 scoped_refptr<MessagePipeDispatcher> dispatcher0( 157 scoped_refptr<MessagePipeDispatcher> dispatcher0(
159 new MessagePipeDispatcher(validated_options)); 158 new MessagePipeDispatcher(validated_options));
160 scoped_refptr<MessagePipeDispatcher> dispatcher1( 159 scoped_refptr<MessagePipeDispatcher> dispatcher1(
161 new MessagePipeDispatcher(validated_options)); 160 new MessagePipeDispatcher(validated_options));
162 161
163 std::pair<MojoHandle, MojoHandle> handle_pair; 162 std::pair<MojoHandle, MojoHandle> handle_pair;
164 { 163 {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (!num_handles.IsNull()) 308 if (!num_handles.IsNull())
310 num_handles.Put(num_handles_value); 309 num_handles.Put(num_handles_value);
311 return rv; 310 return rv;
312 } 311 }
313 312
314 MojoResult Core::CreateDataPipe( 313 MojoResult Core::CreateDataPipe(
315 UserPointer<const MojoCreateDataPipeOptions> options, 314 UserPointer<const MojoCreateDataPipeOptions> options,
316 UserPointer<MojoHandle> data_pipe_producer_handle, 315 UserPointer<MojoHandle> data_pipe_producer_handle,
317 UserPointer<MojoHandle> data_pipe_consumer_handle) { 316 UserPointer<MojoHandle> data_pipe_consumer_handle) {
318 MojoCreateDataPipeOptions validated_options = {}; 317 MojoCreateDataPipeOptions validated_options = {};
319 // This will verify the |options| pointer. 318 MojoResult result = DataPipe::ValidateCreateOptions(options,
320 MojoResult result = DataPipe::ValidateCreateOptions( 319 &validated_options);
321 options.GetPointerUnsafe(), &validated_options);
322 if (result != MOJO_RESULT_OK) 320 if (result != MOJO_RESULT_OK)
323 return result; 321 return result;
324 322
325 scoped_refptr<DataPipeProducerDispatcher> producer_dispatcher( 323 scoped_refptr<DataPipeProducerDispatcher> producer_dispatcher(
326 new DataPipeProducerDispatcher()); 324 new DataPipeProducerDispatcher());
327 scoped_refptr<DataPipeConsumerDispatcher> consumer_dispatcher( 325 scoped_refptr<DataPipeConsumerDispatcher> consumer_dispatcher(
328 new DataPipeConsumerDispatcher()); 326 new DataPipeConsumerDispatcher());
329 327
330 std::pair<MojoHandle, MojoHandle> handle_pair; 328 std::pair<MojoHandle, MojoHandle> handle_pair;
331 { 329 {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return MOJO_RESULT_INVALID_ARGUMENT; 415 return MOJO_RESULT_INVALID_ARGUMENT;
418 416
419 return dispatcher->EndReadData(num_bytes_read); 417 return dispatcher->EndReadData(num_bytes_read);
420 } 418 }
421 419
422 MojoResult Core::CreateSharedBuffer( 420 MojoResult Core::CreateSharedBuffer(
423 UserPointer<const MojoCreateSharedBufferOptions> options, 421 UserPointer<const MojoCreateSharedBufferOptions> options,
424 uint64_t num_bytes, 422 uint64_t num_bytes,
425 UserPointer<MojoHandle> shared_buffer_handle) { 423 UserPointer<MojoHandle> shared_buffer_handle) {
426 MojoCreateSharedBufferOptions validated_options = {}; 424 MojoCreateSharedBufferOptions validated_options = {};
427 // This will verify the |options| pointer.
428 MojoResult result = 425 MojoResult result =
429 SharedBufferDispatcher::ValidateCreateOptions(options.GetPointerUnsafe(), 426 SharedBufferDispatcher::ValidateCreateOptions(options,
430 &validated_options); 427 &validated_options);
431 if (result != MOJO_RESULT_OK) 428 if (result != MOJO_RESULT_OK)
432 return result; 429 return result;
433 430
434 scoped_refptr<SharedBufferDispatcher> dispatcher; 431 scoped_refptr<SharedBufferDispatcher> dispatcher;
435 result = SharedBufferDispatcher::Create(validated_options, num_bytes, 432 result = SharedBufferDispatcher::Create(validated_options, num_bytes,
436 &dispatcher); 433 &dispatcher);
437 if (result != MOJO_RESULT_OK) { 434 if (result != MOJO_RESULT_OK) {
438 DCHECK(!dispatcher); 435 DCHECK(!dispatcher);
439 return result; 436 return result;
(...skipping 13 matching lines...) Expand all
453 MojoResult Core::DuplicateBufferHandle( 450 MojoResult Core::DuplicateBufferHandle(
454 MojoHandle buffer_handle, 451 MojoHandle buffer_handle,
455 UserPointer<const MojoDuplicateBufferHandleOptions> options, 452 UserPointer<const MojoDuplicateBufferHandleOptions> options,
456 UserPointer<MojoHandle> new_buffer_handle) { 453 UserPointer<MojoHandle> new_buffer_handle) {
457 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(buffer_handle)); 454 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(buffer_handle));
458 if (!dispatcher) 455 if (!dispatcher)
459 return MOJO_RESULT_INVALID_ARGUMENT; 456 return MOJO_RESULT_INVALID_ARGUMENT;
460 457
461 // Don't verify |options| here; that's the dispatcher's job. 458 // Don't verify |options| here; that's the dispatcher's job.
462 scoped_refptr<Dispatcher> new_dispatcher; 459 scoped_refptr<Dispatcher> new_dispatcher;
463 MojoResult result = dispatcher->DuplicateBufferHandle( 460 MojoResult result = dispatcher->DuplicateBufferHandle(options,
464 options.GetPointerUnsafe(), &new_dispatcher); 461 &new_dispatcher);
465 if (result != MOJO_RESULT_OK) 462 if (result != MOJO_RESULT_OK)
466 return result; 463 return result;
467 464
468 MojoHandle new_handle = AddDispatcher(new_dispatcher); 465 MojoHandle new_handle = AddDispatcher(new_dispatcher);
469 if (new_handle == MOJO_HANDLE_INVALID) { 466 if (new_handle == MOJO_HANDLE_INVALID) {
470 LOG(ERROR) << "Handle table full"; 467 LOG(ERROR) << "Handle table full";
471 dispatcher->Close(); 468 dispatcher->Close();
472 return MOJO_RESULT_RESOURCE_EXHAUSTED; 469 return MOJO_RESULT_RESOURCE_EXHAUSTED;
473 } 470 }
474 471
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be 552 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be
556 // destroyed, but this would still be required if the waiter were in TLS.) 553 // destroyed, but this would still be required if the waiter were in TLS.)
557 for (i = 0; i < num_added; i++) 554 for (i = 0; i < num_added; i++)
558 dispatchers[i]->RemoveWaiter(&waiter); 555 dispatchers[i]->RemoveWaiter(&waiter);
559 556
560 return rv; 557 return rv;
561 } 558 }
562 559
563 } // namespace system 560 } // namespace system
564 } // namespace mojo 561 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/system/data_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698