| 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 #ifndef MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ |
| 6 #define MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ | 6 #define MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "mojo/edk/embedder/platform_task_runner.h" | |
| 12 #include "mojo/edk/embedder/scoped_platform_handle.h" | 11 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 13 #include "mojo/edk/embedder/slave_process_delegate.h" | 12 #include "mojo/edk/embedder/slave_process_delegate.h" |
| 13 #include "mojo/edk/platform/task_runner.h" |
| 14 #include "mojo/edk/system/connection_manager.h" | 14 #include "mojo/edk/system/connection_manager.h" |
| 15 #include "mojo/edk/system/raw_channel.h" | 15 #include "mojo/edk/system/raw_channel.h" |
| 16 #include "mojo/edk/util/mutex.h" | 16 #include "mojo/edk/util/mutex.h" |
| 17 #include "mojo/edk/util/ref_ptr.h" | 17 #include "mojo/edk/util/ref_ptr.h" |
| 18 #include "mojo/edk/util/waitable_event.h" | 18 #include "mojo/edk/util/waitable_event.h" |
| 19 #include "mojo/public/cpp/system/macros.h" | 19 #include "mojo/public/cpp/system/macros.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class TaskRunner; | 22 class TaskRunner; |
| 23 } | 23 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 // |platform_support| must be valid and remain alive until after |Shutdown()| | 44 // |platform_support| must be valid and remain alive until after |Shutdown()| |
| 45 // has completed. | 45 // has completed. |
| 46 explicit SlaveConnectionManager(embedder::PlatformSupport* platform_support); | 46 explicit SlaveConnectionManager(embedder::PlatformSupport* platform_support); |
| 47 ~SlaveConnectionManager() override; | 47 ~SlaveConnectionManager() override; |
| 48 | 48 |
| 49 // No other methods may be called until after this has been called. | 49 // No other methods may be called until after this has been called. |
| 50 // |delegate_thread_task_runner| should be the task runner for the "delegate | 50 // |delegate_thread_task_runner| should be the task runner for the "delegate |
| 51 // thread", on which |slave_process_delegate|'s methods will be called. Both | 51 // thread", on which |slave_process_delegate|'s methods will be called. Both |
| 52 // must stay alive at least until after |Shutdown()| has been called. | 52 // must stay alive at least until after |Shutdown()| has been called. |
| 53 void Init( | 53 void Init(util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner, |
| 54 util::RefPtr<embedder::PlatformTaskRunner>&& delegate_thread_task_runner, | 54 embedder::SlaveProcessDelegate* slave_process_delegate, |
| 55 embedder::SlaveProcessDelegate* slave_process_delegate, | 55 embedder::ScopedPlatformHandle platform_handle); |
| 56 embedder::ScopedPlatformHandle platform_handle); | |
| 57 | 56 |
| 58 // |ConnectionManager| methods: | 57 // |ConnectionManager| methods: |
| 59 void Shutdown() override; | 58 void Shutdown() override; |
| 60 bool AllowConnect(const ConnectionIdentifier& connection_id) override; | 59 bool AllowConnect(const ConnectionIdentifier& connection_id) override; |
| 61 bool CancelConnect(const ConnectionIdentifier& connection_id) override; | 60 bool CancelConnect(const ConnectionIdentifier& connection_id) override; |
| 62 Result Connect(const ConnectionIdentifier& connection_id, | 61 Result Connect(const ConnectionIdentifier& connection_id, |
| 63 ProcessIdentifier* peer_process_identifier, | 62 ProcessIdentifier* peer_process_identifier, |
| 64 bool* is_first, | 63 bool* is_first, |
| 65 embedder::ScopedPlatformHandle* platform_handle) override; | 64 embedder::ScopedPlatformHandle* platform_handle) override; |
| 66 | 65 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 | 90 |
| 92 // Asserts that the current thread is |private_thread_| (no-op if DCHECKs are | 91 // Asserts that the current thread is |private_thread_| (no-op if DCHECKs are |
| 93 // not enabled). This should only be called while |private_thread_| is alive | 92 // not enabled). This should only be called while |private_thread_| is alive |
| 94 // (i.e., after |Init()| but before |Shutdown()|). | 93 // (i.e., after |Init()| but before |Shutdown()|). |
| 95 void AssertOnPrivateThread() const; | 94 void AssertOnPrivateThread() const; |
| 96 | 95 |
| 97 // These are set in |Init()| before |private_thread_| exists and only cleared | 96 // These are set in |Init()| before |private_thread_| exists and only cleared |
| 98 // in |Shutdown()| after |private_thread_| is dead. Thus it's safe to "use" on | 97 // in |Shutdown()| after |private_thread_| is dead. Thus it's safe to "use" on |
| 99 // |private_thread_|. (Note that |slave_process_delegate_| may only be called | 98 // |private_thread_|. (Note that |slave_process_delegate_| may only be called |
| 100 // from the delegate thread.) | 99 // from the delegate thread.) |
| 101 util::RefPtr<embedder::PlatformTaskRunner> delegate_thread_task_runner_; | 100 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_; |
| 102 embedder::SlaveProcessDelegate* slave_process_delegate_; | 101 embedder::SlaveProcessDelegate* slave_process_delegate_; |
| 103 | 102 |
| 104 // This is a private I/O thread on which this class does the bulk of its work. | 103 // This is a private I/O thread on which this class does the bulk of its work. |
| 105 // It is started in |Init()| and terminated in |Shutdown()|. | 104 // It is started in |Init()| and terminated in |Shutdown()|. |
| 106 // TODO(vtl): This isn't really necessary. | 105 // TODO(vtl): This isn't really necessary. |
| 107 base::Thread private_thread_; | 106 base::Thread private_thread_; |
| 108 | 107 |
| 109 // Only accessed on |private_thread_|: | 108 // Only accessed on |private_thread_|: |
| 110 std::unique_ptr<RawChannel> raw_channel_; | 109 std::unique_ptr<RawChannel> raw_channel_; |
| 111 enum AwaitingAckType { | 110 enum AwaitingAckType { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 util::Mutex mutex_; | 149 util::Mutex mutex_; |
| 151 util::AutoResetWaitableEvent event_; | 150 util::AutoResetWaitableEvent event_; |
| 152 | 151 |
| 153 MOJO_DISALLOW_COPY_AND_ASSIGN(SlaveConnectionManager); | 152 MOJO_DISALLOW_COPY_AND_ASSIGN(SlaveConnectionManager); |
| 154 }; | 153 }; |
| 155 | 154 |
| 156 } // namespace system | 155 } // namespace system |
| 157 } // namespace mojo | 156 } // namespace mojo |
| 158 | 157 |
| 159 #endif // MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ | 158 #endif // MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ |
| OLD | NEW |