| 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 <unordered_map> | 10 #include <unordered_map> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class TaskRunner; | 21 class TaskRunner; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace mojo { | 24 namespace mojo { |
| 25 | 25 |
| 26 namespace embedder { | 26 namespace embedder { |
| 27 class MasterProcessDelegate; | 27 class MasterProcessDelegate; |
| 28 using SlaveInfo = void*; | 28 using SlaveInfo = void*; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace util { | |
| 32 class AutoResetWaitableEvent; | |
| 33 } | |
| 34 | |
| 35 namespace system { | 31 namespace system { |
| 36 | 32 |
| 33 class AutoResetWaitableEvent; |
| 34 |
| 37 // The |ConnectionManager| implementation for the master process. | 35 // The |ConnectionManager| implementation for the master process. |
| 38 // | 36 // |
| 39 // This class is thread-safe (except that no public methods may be called from | 37 // This class is thread-safe (except that no public methods may be called from |
| 40 // its internal, private thread), with condition that |Init()| be called before | 38 // its internal, private thread), with condition that |Init()| be called before |
| 41 // anything else and |Shutdown()| be called before destruction (and no other | 39 // anything else and |Shutdown()| be called before destruction (and no other |
| 42 // public methods may be called during/after |Shutdown()|). | 40 // public methods may be called during/after |Shutdown()|). |
| 43 class MasterConnectionManager final : public ConnectionManager { | 41 class MasterConnectionManager final : public ConnectionManager { |
| 44 public: | 42 public: |
| 45 // Note: None of the public methods may be called from |private_thread_|. | 43 // Note: None of the public methods may be called from |private_thread_|. |
| 46 | 44 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ProcessIdentifier peer_process_identifier, | 109 ProcessIdentifier peer_process_identifier, |
| 112 embedder::ScopedPlatformHandle* platform_handle) | 110 embedder::ScopedPlatformHandle* platform_handle) |
| 113 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 111 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
| 114 | 112 |
| 115 // These should only be called on |private_thread_|: | 113 // These should only be called on |private_thread_|: |
| 116 void ShutdownOnPrivateThread() MOJO_NOT_THREAD_SAFE; | 114 void ShutdownOnPrivateThread() MOJO_NOT_THREAD_SAFE; |
| 117 // Signals |*event| on completion. | 115 // Signals |*event| on completion. |
| 118 void AddSlaveOnPrivateThread(embedder::SlaveInfo slave_info, | 116 void AddSlaveOnPrivateThread(embedder::SlaveInfo slave_info, |
| 119 embedder::ScopedPlatformHandle platform_handle, | 117 embedder::ScopedPlatformHandle platform_handle, |
| 120 ProcessIdentifier slave_process_identifier, | 118 ProcessIdentifier slave_process_identifier, |
| 121 util::AutoResetWaitableEvent* event); | 119 AutoResetWaitableEvent* event); |
| 122 // Called by |Helper::OnError()|. | 120 // Called by |Helper::OnError()|. |
| 123 void OnError(ProcessIdentifier process_identifier); | 121 void OnError(ProcessIdentifier process_identifier); |
| 124 // Posts a call to |master_process_delegate_->OnSlaveDisconnect()|. | 122 // Posts a call to |master_process_delegate_->OnSlaveDisconnect()|. |
| 125 void CallOnSlaveDisconnect(embedder::SlaveInfo slave_info); | 123 void CallOnSlaveDisconnect(embedder::SlaveInfo slave_info); |
| 126 | 124 |
| 127 // Asserts that the current thread is *not* |private_thread_| (no-op if | 125 // Asserts that the current thread is *not* |private_thread_| (no-op if |
| 128 // DCHECKs are not enabled). This should only be called while | 126 // DCHECKs are not enabled). This should only be called while |
| 129 // |private_thread_| is alive (i.e., after |Init()| but before |Shutdown()|). | 127 // |private_thread_| is alive (i.e., after |Init()| but before |Shutdown()|). |
| 130 void AssertNotOnPrivateThread() const; | 128 void AssertNotOnPrivateThread() const; |
| 131 | 129 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 std::unordered_map<ProcessIdentifier, ProcessConnections*> connections_ | 170 std::unordered_map<ProcessIdentifier, ProcessConnections*> connections_ |
| 173 MOJO_GUARDED_BY(mutex_); // Owns its values. | 171 MOJO_GUARDED_BY(mutex_); // Owns its values. |
| 174 | 172 |
| 175 MOJO_DISALLOW_COPY_AND_ASSIGN(MasterConnectionManager); | 173 MOJO_DISALLOW_COPY_AND_ASSIGN(MasterConnectionManager); |
| 176 }; | 174 }; |
| 177 | 175 |
| 178 } // namespace system | 176 } // namespace system |
| 179 } // namespace mojo | 177 } // namespace mojo |
| 180 | 178 |
| 181 #endif // MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ | 179 #endif // MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ |
| OLD | NEW |