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

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

Issue 898623002: Make mojo::system::Core not own the PlatformSupport. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: foo Created 5 years, 10 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
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/core_test_base.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/edk/system/core.h" 5 #include "mojo/edk/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // 71 //
72 // Notes: 72 // Notes:
73 // - While holding a |Dispatcher| lock, you may not unconditionally attempt 73 // - While holding a |Dispatcher| lock, you may not unconditionally attempt
74 // to take another |Dispatcher| lock. (This has consequences on the 74 // to take another |Dispatcher| lock. (This has consequences on the
75 // concurrency semantics of |MojoWriteMessage()| when passing handles.) 75 // concurrency semantics of |MojoWriteMessage()| when passing handles.)
76 // Doing so would lead to deadlock. 76 // Doing so would lead to deadlock.
77 // - Locks at the "INF" level may not have any locks taken while they are 77 // - Locks at the "INF" level may not have any locks taken while they are
78 // held. 78 // held.
79 79
80 // TODO(vtl): This should take a |scoped_ptr<PlatformSupport>| as a parameter. 80 // TODO(vtl): This should take a |scoped_ptr<PlatformSupport>| as a parameter.
81 Core::Core(scoped_ptr<embedder::PlatformSupport> platform_support) 81 Core::Core(embedder::PlatformSupport* platform_support)
82 : platform_support_(platform_support.Pass()) { 82 : platform_support_(platform_support) {
83 } 83 }
84 84
85 Core::~Core() { 85 Core::~Core() {
86 } 86 }
87 87
88 MojoHandle Core::AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher) { 88 MojoHandle Core::AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher) {
89 base::AutoLock locker(handle_table_lock_); 89 base::AutoLock locker(handle_table_lock_);
90 return handle_table_.AddDispatcher(dispatcher); 90 return handle_table_.AddDispatcher(dispatcher);
91 } 91 }
92 92
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 UserPointer<const MojoCreateSharedBufferOptions> options, 462 UserPointer<const MojoCreateSharedBufferOptions> options,
463 uint64_t num_bytes, 463 uint64_t num_bytes,
464 UserPointer<MojoHandle> shared_buffer_handle) { 464 UserPointer<MojoHandle> shared_buffer_handle) {
465 MojoCreateSharedBufferOptions validated_options = {}; 465 MojoCreateSharedBufferOptions validated_options = {};
466 MojoResult result = SharedBufferDispatcher::ValidateCreateOptions( 466 MojoResult result = SharedBufferDispatcher::ValidateCreateOptions(
467 options, &validated_options); 467 options, &validated_options);
468 if (result != MOJO_RESULT_OK) 468 if (result != MOJO_RESULT_OK)
469 return result; 469 return result;
470 470
471 scoped_refptr<SharedBufferDispatcher> dispatcher; 471 scoped_refptr<SharedBufferDispatcher> dispatcher;
472 result = SharedBufferDispatcher::Create(platform_support(), validated_options, 472 result = SharedBufferDispatcher::Create(platform_support_, validated_options,
473 num_bytes, &dispatcher); 473 num_bytes, &dispatcher);
474 if (result != MOJO_RESULT_OK) { 474 if (result != MOJO_RESULT_OK) {
475 DCHECK(!dispatcher); 475 DCHECK(!dispatcher);
476 return result; 476 return result;
477 } 477 }
478 478
479 MojoHandle h = AddDispatcher(dispatcher); 479 MojoHandle h = AddDispatcher(dispatcher);
480 if (h == MOJO_HANDLE_INVALID) { 480 if (h == MOJO_HANDLE_INVALID) {
481 LOG(ERROR) << "Handle table full"; 481 LOG(ERROR) << "Handle table full";
482 dispatcher->Close(); 482 dispatcher->Close();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 if (signals_states) { 600 if (signals_states) {
601 for (; i < num_handles; i++) 601 for (; i < num_handles; i++)
602 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 602 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
603 } 603 }
604 604
605 return rv; 605 return rv;
606 } 606 }
607 607
608 } // namespace system 608 } // namespace system
609 } // namespace mojo 609 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/core_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698