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