| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/master_connection_manager.h" | 5 #include "mojo/edk/system/master_connection_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "mojo/edk/embedder/master_process_delegate.h" | 13 #include "mojo/edk/embedder/master_process_delegate.h" |
| 14 #include "mojo/edk/embedder/platform_channel_pair.h" | |
| 15 #include "mojo/edk/platform/io_thread.h" | 14 #include "mojo/edk/platform/io_thread.h" |
| 16 #include "mojo/edk/platform/platform_handle.h" | 15 #include "mojo/edk/platform/platform_handle.h" |
| 16 #include "mojo/edk/platform/platform_pipe.h" |
| 17 #include "mojo/edk/platform/thread.h" | 17 #include "mojo/edk/platform/thread.h" |
| 18 #include "mojo/edk/system/connection_manager_messages.h" | 18 #include "mojo/edk/system/connection_manager_messages.h" |
| 19 #include "mojo/edk/system/message_in_transit.h" | 19 #include "mojo/edk/system/message_in_transit.h" |
| 20 #include "mojo/edk/system/raw_channel.h" | 20 #include "mojo/edk/system/raw_channel.h" |
| 21 #include "mojo/edk/system/transport_data.h" | 21 #include "mojo/edk/system/transport_data.h" |
| 22 #include "mojo/edk/util/make_unique.h" | 22 #include "mojo/edk/util/make_unique.h" |
| 23 #include "mojo/edk/util/waitable_event.h" | 23 #include "mojo/edk/util/waitable_event.h" |
| 24 #include "mojo/public/cpp/system/macros.h" | 24 #include "mojo/public/cpp/system/macros.h" |
| 25 | 25 |
| 26 using mojo::platform::PlatformHandle; | 26 using mojo::platform::PlatformHandle; |
| 27 using mojo::platform::PlatformHandleWatcher; | 27 using mojo::platform::PlatformHandleWatcher; |
| 28 using mojo::platform::PlatformPipe; |
| 28 using mojo::platform::ScopedPlatformHandle; | 29 using mojo::platform::ScopedPlatformHandle; |
| 29 using mojo::platform::TaskRunner; | 30 using mojo::platform::TaskRunner; |
| 30 using mojo::platform::Thread; | 31 using mojo::platform::Thread; |
| 31 using mojo::util::AutoResetWaitableEvent; | 32 using mojo::util::AutoResetWaitableEvent; |
| 32 using mojo::util::MakeUnique; | 33 using mojo::util::MakeUnique; |
| 33 using mojo::util::MutexLocker; | 34 using mojo::util::MutexLocker; |
| 34 using mojo::util::RefPtr; | 35 using mojo::util::RefPtr; |
| 35 | 36 |
| 36 namespace mojo { | 37 namespace mojo { |
| 37 namespace system { | 38 namespace system { |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 DCHECK(connections_.find(peer_process_identifier) != connections_.end()); | 625 DCHECK(connections_.find(peer_process_identifier) != connections_.end()); |
| 625 switch (process_connections->GetConnectionStatus(peer_process_identifier, | 626 switch (process_connections->GetConnectionStatus(peer_process_identifier, |
| 626 platform_handle)) { | 627 platform_handle)) { |
| 627 case ProcessConnections::ConnectionStatus::NONE: { | 628 case ProcessConnections::ConnectionStatus::NONE: { |
| 628 // TODO(vtl): In the "second connect" case, this should never be reached | 629 // TODO(vtl): In the "second connect" case, this should never be reached |
| 629 // (but it's not easy to DCHECK this invariant here). | 630 // (but it's not easy to DCHECK this invariant here). |
| 630 process_connections->AddConnection( | 631 process_connections->AddConnection( |
| 631 peer_process_identifier, | 632 peer_process_identifier, |
| 632 ProcessConnections::ConnectionStatus::RUNNING, | 633 ProcessConnections::ConnectionStatus::RUNNING, |
| 633 ScopedPlatformHandle()); | 634 ScopedPlatformHandle()); |
| 634 embedder::PlatformChannelPair platform_channel_pair; | 635 PlatformPipe platform_channel_pair; |
| 635 *platform_handle = platform_channel_pair.handle0.Pass(); | 636 *platform_handle = platform_channel_pair.handle0.Pass(); |
| 636 | 637 |
| 637 connections_[peer_process_identifier]->AddConnection( | 638 connections_[peer_process_identifier]->AddConnection( |
| 638 process_identifier, ProcessConnections::ConnectionStatus::PENDING, | 639 process_identifier, ProcessConnections::ConnectionStatus::PENDING, |
| 639 platform_channel_pair.handle1.Pass()); | 640 platform_channel_pair.handle1.Pass()); |
| 640 break; | 641 break; |
| 641 } | 642 } |
| 642 case ProcessConnections::ConnectionStatus::PENDING: | 643 case ProcessConnections::ConnectionStatus::PENDING: |
| 643 DCHECK(connections_[peer_process_identifier]->GetConnectionStatus( | 644 DCHECK(connections_[peer_process_identifier]->GetConnectionStatus( |
| 644 process_identifier, nullptr) == | 645 process_identifier, nullptr) == |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 DCHECK(!private_thread_task_runner_->RunsTasksOnCurrentThread()); | 751 DCHECK(!private_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 751 } | 752 } |
| 752 | 753 |
| 753 void MasterConnectionManager::AssertOnPrivateThread() const { | 754 void MasterConnectionManager::AssertOnPrivateThread() const { |
| 754 // This should only be called after |Init()| and before |Shutdown()|. | 755 // This should only be called after |Init()| and before |Shutdown()|. |
| 755 DCHECK(private_thread_task_runner_->RunsTasksOnCurrentThread()); | 756 DCHECK(private_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 756 } | 757 } |
| 757 | 758 |
| 758 } // namespace system | 759 } // namespace system |
| 759 } // namespace mojo | 760 } // namespace mojo |
| OLD | NEW |