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

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

Issue 475223002: Mojo: Add embedder::PlatformSupport and a simple implementation (and a bit of plumbing). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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"
11 #include "mojo/embedder/platform_shared_buffer.h" 11 #include "mojo/embedder/platform_shared_buffer.h"
12 #include "mojo/embedder/simple_platform_support.h" // TODO(vtl): Remove this.
12 #include "mojo/public/c/system/macros.h" 13 #include "mojo/public/c/system/macros.h"
13 #include "mojo/system/constants.h" 14 #include "mojo/system/constants.h"
14 #include "mojo/system/data_pipe.h" 15 #include "mojo/system/data_pipe.h"
15 #include "mojo/system/data_pipe_consumer_dispatcher.h" 16 #include "mojo/system/data_pipe_consumer_dispatcher.h"
16 #include "mojo/system/data_pipe_producer_dispatcher.h" 17 #include "mojo/system/data_pipe_producer_dispatcher.h"
17 #include "mojo/system/dispatcher.h" 18 #include "mojo/system/dispatcher.h"
18 #include "mojo/system/handle_signals_state.h" 19 #include "mojo/system/handle_signals_state.h"
19 #include "mojo/system/local_data_pipe.h" 20 #include "mojo/system/local_data_pipe.h"
20 #include "mojo/system/memory.h" 21 #include "mojo/system/memory.h"
21 #include "mojo/system/message_pipe.h" 22 #include "mojo/system/message_pipe.h"
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 MojoResult Core::CreateSharedBuffer( 456 MojoResult Core::CreateSharedBuffer(
456 UserPointer<const MojoCreateSharedBufferOptions> options, 457 UserPointer<const MojoCreateSharedBufferOptions> options,
457 uint64_t num_bytes, 458 uint64_t num_bytes,
458 UserPointer<MojoHandle> shared_buffer_handle) { 459 UserPointer<MojoHandle> shared_buffer_handle) {
459 MojoCreateSharedBufferOptions validated_options = {}; 460 MojoCreateSharedBufferOptions validated_options = {};
460 MojoResult result = SharedBufferDispatcher::ValidateCreateOptions( 461 MojoResult result = SharedBufferDispatcher::ValidateCreateOptions(
461 options, &validated_options); 462 options, &validated_options);
462 if (result != MOJO_RESULT_OK) 463 if (result != MOJO_RESULT_OK)
463 return result; 464 return result;
464 465
466 // TODO(vtl): |Core| should have a |PlatformSupport| passed in at creation
467 // time, and we should use that instead.
468 embedder::SimplePlatformSupport platform_support;
465 scoped_refptr<SharedBufferDispatcher> dispatcher; 469 scoped_refptr<SharedBufferDispatcher> dispatcher;
466 result = 470 result = SharedBufferDispatcher::Create(
467 SharedBufferDispatcher::Create(validated_options, num_bytes, &dispatcher); 471 &platform_support, validated_options, num_bytes, &dispatcher);
468 if (result != MOJO_RESULT_OK) { 472 if (result != MOJO_RESULT_OK) {
469 DCHECK(!dispatcher); 473 DCHECK(!dispatcher);
470 return result; 474 return result;
471 } 475 }
472 476
473 MojoHandle h = AddDispatcher(dispatcher); 477 MojoHandle h = AddDispatcher(dispatcher);
474 if (h == MOJO_HANDLE_INVALID) { 478 if (h == MOJO_HANDLE_INVALID) {
475 LOG(ERROR) << "Handle table full"; 479 LOG(ERROR) << "Handle table full";
476 dispatcher->Close(); 480 dispatcher->Close();
477 return MOJO_RESULT_RESOURCE_EXHAUSTED; 481 return MOJO_RESULT_RESOURCE_EXHAUSTED;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 if (signals_states) { 598 if (signals_states) {
595 for (; i < num_handles; i++) 599 for (; i < num_handles; i++)
596 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 600 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
597 } 601 }
598 602
599 return rv; 603 return rv;
600 } 604 }
601 605
602 } // namespace system 606 } // namespace system
603 } // namespace mojo 607 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698