| 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_MASTER_CONNECTION_MANAGER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ |
| 6 #define MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ | 6 #define MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 | 12 |
| 13 #include "mojo/edk/platform/scoped_platform_handle.h" | 13 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 14 #include "mojo/edk/platform/task_runner.h" | 14 #include "mojo/edk/platform/task_runner.h" |
| 15 #include "mojo/edk/system/connection_manager.h" | 15 #include "mojo/edk/system/connection_manager.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/thread_annotations.h" | 18 #include "mojo/edk/util/thread_annotations.h" |
| 19 #include "mojo/public/cpp/system/macros.h" | 19 #include "mojo/public/cpp/system/macros.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 | 22 |
| 23 namespace embedder { | 23 namespace embedder { |
| 24 class MasterProcessDelegate; | 24 class MasterProcessDelegate; |
| 25 using SlaveInfo = void*; | 25 using SlaveInfo = void*; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace platform { | 28 namespace platform { |
| 29 class PlatformHandleWatcher; |
| 29 class Thread; | 30 class Thread; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace util { | 33 namespace util { |
| 33 class AutoResetWaitableEvent; | 34 class AutoResetWaitableEvent; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace system { | 37 namespace system { |
| 37 | 38 |
| 38 // The |ConnectionManager| implementation for the master process. | 39 // The |ConnectionManager| implementation for the master process. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // in |Shutdown()| after |private_thread_| is dead. Thus it's safe to "use" on | 140 // in |Shutdown()| after |private_thread_| is dead. Thus it's safe to "use" on |
| 140 // |private_thread_|. (Note that |master_process_delegate_| may only be called | 141 // |private_thread_|. (Note that |master_process_delegate_| may only be called |
| 141 // from the delegate thread.) | 142 // from the delegate thread.) |
| 142 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_; | 143 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_; |
| 143 embedder::MasterProcessDelegate* master_process_delegate_; | 144 embedder::MasterProcessDelegate* master_process_delegate_; |
| 144 | 145 |
| 145 // This is a private I/O thread on which this class does the bulk of its work. | 146 // This is a private I/O thread on which this class does the bulk of its work. |
| 146 // It is started in |Init()| and terminated in |Shutdown()|. | 147 // It is started in |Init()| and terminated in |Shutdown()|. |
| 147 std::unique_ptr<platform::Thread> private_thread_; | 148 std::unique_ptr<platform::Thread> private_thread_; |
| 148 util::RefPtr<platform::TaskRunner> private_thread_task_runner_; | 149 util::RefPtr<platform::TaskRunner> private_thread_task_runner_; |
| 150 platform::PlatformHandleWatcher* private_thread_platform_handle_watcher_; |
| 149 | 151 |
| 150 // The following members are only accessed on |private_thread_|: | 152 // The following members are only accessed on |private_thread_|: |
| 151 // TODO(vtl): Make the values unique_ptrs. | 153 // TODO(vtl): Make the values unique_ptrs. |
| 152 std::unordered_map<ProcessIdentifier, Helper*> helpers_; // Owns its values. | 154 std::unordered_map<ProcessIdentifier, Helper*> helpers_; // Owns its values. |
| 153 | 155 |
| 154 // Note: |mutex_| is not needed in the constructor, |Init()|, | 156 // Note: |mutex_| is not needed in the constructor, |Init()|, |
| 155 // |Shutdown()|/|ShutdownOnPrivateThread()|, or the destructor | 157 // |Shutdown()|/|ShutdownOnPrivateThread()|, or the destructor |
| 156 util::Mutex mutex_; | 158 util::Mutex mutex_; |
| 157 | 159 |
| 158 ProcessIdentifier next_process_identifier_ MOJO_GUARDED_BY(mutex_); | 160 ProcessIdentifier next_process_identifier_ MOJO_GUARDED_BY(mutex_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 175 std::unordered_map<ProcessIdentifier, ProcessConnections*> connections_ | 177 std::unordered_map<ProcessIdentifier, ProcessConnections*> connections_ |
| 176 MOJO_GUARDED_BY(mutex_); // Owns its values. | 178 MOJO_GUARDED_BY(mutex_); // Owns its values. |
| 177 | 179 |
| 178 MOJO_DISALLOW_COPY_AND_ASSIGN(MasterConnectionManager); | 180 MOJO_DISALLOW_COPY_AND_ASSIGN(MasterConnectionManager); |
| 179 }; | 181 }; |
| 180 | 182 |
| 181 } // namespace system | 183 } // namespace system |
| 182 } // namespace mojo | 184 } // namespace mojo |
| 183 | 185 |
| 184 #endif // MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ | 186 #endif // MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ |
| OLD | NEW |