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 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "mojo/edk/embedder/master_process_delegate.h" | 16 #include "mojo/edk/embedder/master_process_delegate.h" |
17 #include "mojo/edk/embedder/platform_channel_pair.h" | 17 #include "mojo/edk/embedder/platform_channel_pair.h" |
18 #include "mojo/edk/embedder/platform_handle.h" | 18 #include "mojo/edk/embedder/platform_handle.h" |
19 #include "mojo/edk/embedder/platform_handle_vector.h" | 19 #include "mojo/edk/embedder/platform_handle_vector.h" |
20 #include "mojo/edk/system/connection_manager_messages.h" | 20 #include "mojo/edk/system/connection_manager_messages.h" |
21 #include "mojo/edk/system/message_in_transit.h" | 21 #include "mojo/edk/system/message_in_transit.h" |
22 #include "mojo/edk/system/raw_channel.h" | 22 #include "mojo/edk/system/raw_channel.h" |
23 #include "mojo/edk/system/transport_data.h" | 23 #include "mojo/edk/system/transport_data.h" |
24 #include "mojo/edk/util/make_unique.h" | 24 #include "mojo/edk/util/make_unique.h" |
25 #include "mojo/edk/util/waitable_event.h" | 25 #include "mojo/edk/util/waitable_event.h" |
26 #include "mojo/public/cpp/system/macros.h" | 26 #include "mojo/public/cpp/system/macros.h" |
27 | 27 |
| 28 using mojo::platform::TaskRunner; |
28 using mojo::util::AutoResetWaitableEvent; | 29 using mojo::util::AutoResetWaitableEvent; |
29 using mojo::util::MutexLocker; | 30 using mojo::util::MutexLocker; |
30 using mojo::util::RefPtr; | 31 using mojo::util::RefPtr; |
31 | 32 |
32 namespace mojo { | 33 namespace mojo { |
33 namespace system { | 34 namespace system { |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 const ProcessIdentifier kFirstSlaveProcessIdentifier = 2; | 38 const ProcessIdentifier kFirstSlaveProcessIdentifier = 2; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 336 |
336 MasterConnectionManager::~MasterConnectionManager() { | 337 MasterConnectionManager::~MasterConnectionManager() { |
337 DCHECK(!delegate_thread_task_runner_); | 338 DCHECK(!delegate_thread_task_runner_); |
338 DCHECK(!master_process_delegate_); | 339 DCHECK(!master_process_delegate_); |
339 DCHECK(!private_thread_.message_loop()); | 340 DCHECK(!private_thread_.message_loop()); |
340 DCHECK(helpers_.empty()); | 341 DCHECK(helpers_.empty()); |
341 DCHECK(pending_connects_.empty()); | 342 DCHECK(pending_connects_.empty()); |
342 } | 343 } |
343 | 344 |
344 void MasterConnectionManager::Init( | 345 void MasterConnectionManager::Init( |
345 RefPtr<embedder::PlatformTaskRunner>&& delegate_thread_task_runner, | 346 RefPtr<TaskRunner>&& delegate_thread_task_runner, |
346 embedder::MasterProcessDelegate* master_process_delegate) { | 347 embedder::MasterProcessDelegate* master_process_delegate) { |
347 DCHECK(delegate_thread_task_runner); | 348 DCHECK(delegate_thread_task_runner); |
348 DCHECK(master_process_delegate); | 349 DCHECK(master_process_delegate); |
349 DCHECK(!delegate_thread_task_runner_); | 350 DCHECK(!delegate_thread_task_runner_); |
350 DCHECK(!master_process_delegate_); | 351 DCHECK(!master_process_delegate_); |
351 DCHECK(!private_thread_.message_loop()); | 352 DCHECK(!private_thread_.message_loop()); |
352 | 353 |
353 delegate_thread_task_runner_ = std::move(delegate_thread_task_runner); | 354 delegate_thread_task_runner_ = std::move(delegate_thread_task_runner); |
354 master_process_delegate_ = master_process_delegate; | 355 master_process_delegate_ = master_process_delegate; |
355 CHECK(private_thread_.StartWithOptions( | 356 CHECK(private_thread_.StartWithOptions( |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 } | 742 } |
742 | 743 |
743 void MasterConnectionManager::AssertOnPrivateThread() const { | 744 void MasterConnectionManager::AssertOnPrivateThread() const { |
744 // This should only be called after |Init()| and before |Shutdown()|. | 745 // This should only be called after |Init()| and before |Shutdown()|. |
745 DCHECK(private_thread_.message_loop()); | 746 DCHECK(private_thread_.message_loop()); |
746 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); | 747 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); |
747 } | 748 } |
748 | 749 |
749 } // namespace system | 750 } // namespace system |
750 } // namespace mojo | 751 } // namespace mojo |
OLD | NEW |