| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |