| 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> |
| 11 | 11 |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "mojo/edk/embedder/platform_task_runner.h" | 13 #include "mojo/edk/embedder/platform_task_runner.h" |
| 14 #include "mojo/edk/embedder/scoped_platform_handle.h" | 14 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 15 #include "mojo/edk/system/connection_manager.h" | 15 #include "mojo/edk/system/connection_manager.h" |
| 16 #include "mojo/edk/system/mutex.h" | 16 #include "mojo/edk/util/mutex.h" |
| 17 #include "mojo/edk/util/thread_annotations.h" |
| 17 #include "mojo/public/cpp/system/macros.h" | 18 #include "mojo/public/cpp/system/macros.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class TaskRunner; | 21 class TaskRunner; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace mojo { | 24 namespace mojo { |
| 24 | 25 |
| 25 namespace embedder { | 26 namespace embedder { |
| 26 class MasterProcessDelegate; | 27 class MasterProcessDelegate; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 // This is a private I/O thread on which this class does the bulk of its work. | 142 // This is a private I/O thread on which this class does the bulk of its work. |
| 142 // It is started in |Init()| and terminated in |Shutdown()|. | 143 // It is started in |Init()| and terminated in |Shutdown()|. |
| 143 base::Thread private_thread_; | 144 base::Thread private_thread_; |
| 144 | 145 |
| 145 // The following members are only accessed on |private_thread_|: | 146 // The following members are only accessed on |private_thread_|: |
| 146 std::unordered_map<ProcessIdentifier, Helper*> helpers_; // Owns its values. | 147 std::unordered_map<ProcessIdentifier, Helper*> helpers_; // Owns its values. |
| 147 | 148 |
| 148 // Note: |mutex_| is not needed in the constructor, |Init()|, | 149 // Note: |mutex_| is not needed in the constructor, |Init()|, |
| 149 // |Shutdown()|/|ShutdownOnPrivateThread()|, or the destructor | 150 // |Shutdown()|/|ShutdownOnPrivateThread()|, or the destructor |
| 150 Mutex mutex_; | 151 util::Mutex mutex_; |
| 151 | 152 |
| 152 ProcessIdentifier next_process_identifier_ MOJO_GUARDED_BY(mutex_); | 153 ProcessIdentifier next_process_identifier_ MOJO_GUARDED_BY(mutex_); |
| 153 | 154 |
| 154 // Stores information on pending calls to |AllowConnect()|/|Connect()| (or | 155 // Stores information on pending calls to |AllowConnect()|/|Connect()| (or |
| 155 // |CancelConnect()|, namely those for which at least one party has called | 156 // |CancelConnect()|, namely those for which at least one party has called |
| 156 // |AllowConnect()| but both have not yet called |Connect()| (or | 157 // |AllowConnect()| but both have not yet called |Connect()| (or |
| 157 // |CancelConnect()|). | 158 // |CancelConnect()|). |
| 158 struct PendingConnectInfo; | 159 struct PendingConnectInfo; |
| 159 std::unordered_map<ConnectionIdentifier, PendingConnectInfo*> | 160 std::unordered_map<ConnectionIdentifier, PendingConnectInfo*> |
| 160 pending_connects_ MOJO_GUARDED_BY(mutex_); // Owns its values. | 161 pending_connects_ MOJO_GUARDED_BY(mutex_); // Owns its values. |
| 161 | 162 |
| 162 // A |ProcessConnections| stores information about connections "from" a given | 163 // A |ProcessConnections| stores information about connections "from" a given |
| 163 // (fixed, implied) process "to" other processes. A connection may be not | 164 // (fixed, implied) process "to" other processes. A connection may be not |
| 164 // present, running (meaning that both sides have connected and been given | 165 // present, running (meaning that both sides have connected and been given |
| 165 // platform handles to a connected "pipe"), or pending (meaning that the | 166 // platform handles to a connected "pipe"), or pending (meaning that the |
| 166 // "from" side must still be given a platform handle). | 167 // "from" side must still be given a platform handle). |
| 167 class ProcessConnections; | 168 class ProcessConnections; |
| 168 // This is a map from "from" processes to its |ProcessConnections| (above). | 169 // This is a map from "from" processes to its |ProcessConnections| (above). |
| 169 std::unordered_map<ProcessIdentifier, ProcessConnections*> connections_ | 170 std::unordered_map<ProcessIdentifier, ProcessConnections*> connections_ |
| 170 MOJO_GUARDED_BY(mutex_); // Owns its values. | 171 MOJO_GUARDED_BY(mutex_); // Owns its values. |
| 171 | 172 |
| 172 MOJO_DISALLOW_COPY_AND_ASSIGN(MasterConnectionManager); | 173 MOJO_DISALLOW_COPY_AND_ASSIGN(MasterConnectionManager); |
| 173 }; | 174 }; |
| 174 | 175 |
| 175 } // namespace system | 176 } // namespace system |
| 176 } // namespace mojo | 177 } // namespace mojo |
| 177 | 178 |
| 178 #endif // MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ | 179 #endif // MOJO_EDK_SYSTEM_MASTER_CONNECTION_MANAGER_H_ |
| OLD | NEW |