| 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 #include "mojo/edk/system/master_connection_manager.h" | 5 #include "mojo/edk/system/master_connection_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 NOTREACHED(); | 59 NOTREACHED(); |
| 60 return MessageInTransit::Subtype::CONNECTION_MANAGER_ACK_FAILURE; | 60 return MessageInTransit::Subtype::CONNECTION_MANAGER_ACK_FAILURE; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace | 63 } // namespace |
| 64 | 64 |
| 65 // MasterConnectionManager::Helper --------------------------------------------- | 65 // MasterConnectionManager::Helper --------------------------------------------- |
| 66 | 66 |
| 67 // |MasterConnectionManager::Helper| is not thread-safe, and must only be used | 67 // |MasterConnectionManager::Helper| is not thread-safe, and must only be used |
| 68 // on its |owner_|'s private thread. | 68 // on its |owner_|'s private thread. |
| 69 class MOJO_SYSTEM_IMPL_EXPORT MasterConnectionManager::Helper final | 69 class MasterConnectionManager::Helper final : public RawChannel::Delegate { |
| 70 : public RawChannel::Delegate { | |
| 71 public: | 70 public: |
| 72 Helper(MasterConnectionManager* owner, | 71 Helper(MasterConnectionManager* owner, |
| 73 ProcessIdentifier process_identifier, | 72 ProcessIdentifier process_identifier, |
| 74 embedder::SlaveInfo slave_info, | 73 embedder::SlaveInfo slave_info, |
| 75 embedder::ScopedPlatformHandle platform_handle); | 74 embedder::ScopedPlatformHandle platform_handle); |
| 76 ~Helper() override; | 75 ~Helper() override; |
| 77 | 76 |
| 78 void Init(); | 77 void Init(); |
| 79 embedder::SlaveInfo Shutdown(); | 78 embedder::SlaveInfo Shutdown(); |
| 80 | 79 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // responses. | 218 // responses. |
| 220 FatalError(); // WARNING: This destroys us. | 219 FatalError(); // WARNING: This destroys us. |
| 221 } | 220 } |
| 222 | 221 |
| 223 void MasterConnectionManager::Helper::FatalError() { | 222 void MasterConnectionManager::Helper::FatalError() { |
| 224 owner_->OnError(process_identifier_); // WARNING: This destroys us. | 223 owner_->OnError(process_identifier_); // WARNING: This destroys us. |
| 225 } | 224 } |
| 226 | 225 |
| 227 // MasterConnectionManager::PendingConnectInfo --------------------------------- | 226 // MasterConnectionManager::PendingConnectInfo --------------------------------- |
| 228 | 227 |
| 229 struct MOJO_SYSTEM_IMPL_EXPORT MasterConnectionManager::PendingConnectInfo { | 228 struct MasterConnectionManager::PendingConnectInfo { |
| 230 // States: | 229 // States: |
| 231 // - This is created upon a first "allow connect" (with |first| set | 230 // - This is created upon a first "allow connect" (with |first| set |
| 232 // immediately). We then wait for a second "allow connect". | 231 // immediately). We then wait for a second "allow connect". |
| 233 // - After the second "allow connect" (and |second| is set), we wait for | 232 // - After the second "allow connect" (and |second| is set), we wait for |
| 234 // "connects" from both |first| and |second|. | 233 // "connects" from both |first| and |second|. |
| 235 // - We may then receive "connect" from either |first| or |second|, at which | 234 // - We may then receive "connect" from either |first| or |second|, at which |
| 236 // which point it remains to wait for "connect" from the other. | 235 // which point it remains to wait for "connect" from the other. |
| 237 // I.e., the valid state transitions are: | 236 // I.e., the valid state transitions are: |
| 238 // AWAITING_SECOND_ALLOW_CONNECT -> AWAITING_CONNECTS_FROM_BOTH | 237 // AWAITING_SECOND_ALLOW_CONNECT -> AWAITING_CONNECTS_FROM_BOTH |
| 239 // -> {AWAITING_CONNECT_FROM_FIRST,AWAITING_CONNECT_FROM_SECOND} | 238 // -> {AWAITING_CONNECT_FROM_FIRST,AWAITING_CONNECT_FROM_SECOND} |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 } | 737 } |
| 739 | 738 |
| 740 void MasterConnectionManager::AssertOnPrivateThread() const { | 739 void MasterConnectionManager::AssertOnPrivateThread() const { |
| 741 // This should only be called after |Init()| and before |Shutdown()|. | 740 // This should only be called after |Init()| and before |Shutdown()|. |
| 742 DCHECK(private_thread_.message_loop()); | 741 DCHECK(private_thread_.message_loop()); |
| 743 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); | 742 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); |
| 744 } | 743 } |
| 745 | 744 |
| 746 } // namespace system | 745 } // namespace system |
| 747 } // namespace mojo | 746 } // namespace mojo |
| OLD | NEW |