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_CONNECTION_MANAGER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CONNECTION_MANAGER_H_ |
6 #define MOJO_EDK_SYSTEM_CONNECTION_MANAGER_H_ | 6 #define MOJO_EDK_SYSTEM_CONNECTION_MANAGER_H_ |
7 | 7 |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "mojo/edk/system/connection_identifier.h" | 10 #include "mojo/edk/system/connection_identifier.h" |
11 #include "mojo/edk/system/process_identifier.h" | 11 #include "mojo/edk/system/process_identifier.h" |
12 #include "mojo/edk/system/system_impl_export.h" | |
13 #include "mojo/edk/system/thread_annotations.h" | 12 #include "mojo/edk/system/thread_annotations.h" |
14 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
15 | 14 |
16 namespace mojo { | 15 namespace mojo { |
17 | 16 |
18 namespace embedder { | 17 namespace embedder { |
19 class PlatformSupport; | 18 class PlatformSupport; |
20 class ScopedPlatformHandle; | 19 class ScopedPlatformHandle; |
21 } // namespace embedder | 20 } // namespace embedder |
22 | 21 |
(...skipping 30 matching lines...) Expand all Loading... |
53 // to track connection teardowns.) | 52 // to track connection teardowns.) |
54 // | 53 // |
55 // Implementation notes: We implement this using a "star topology", with a | 54 // Implementation notes: We implement this using a "star topology", with a |
56 // single trusted "master" (broker) process and an arbitrary number of untrusted | 55 // single trusted "master" (broker) process and an arbitrary number of untrusted |
57 // "slave" (client) processes. The former is implemented by | 56 // "slave" (client) processes. The former is implemented by |
58 // |MasterConnectionManager| (master_connection_manager.*) and the latter by | 57 // |MasterConnectionManager| (master_connection_manager.*) and the latter by |
59 // |SlaveConnectionManager| (slave_connection_manager.*). Each slave is | 58 // |SlaveConnectionManager| (slave_connection_manager.*). Each slave is |
60 // connected to the master by a special dedicated |RawChannel|, on which it does | 59 // connected to the master by a special dedicated |RawChannel|, on which it does |
61 // synchronous IPC (note, however, that the master should never block on any | 60 // synchronous IPC (note, however, that the master should never block on any |
62 // slave). | 61 // slave). |
63 class MOJO_SYSTEM_IMPL_EXPORT ConnectionManager { | 62 class ConnectionManager { |
64 public: | 63 public: |
65 enum class Result { | 64 enum class Result { |
66 FAILURE = 0, | 65 FAILURE = 0, |
67 SUCCESS, | 66 SUCCESS, |
68 // These results are used for |Connect()| (which also uses |FAILURE|, but | 67 // These results are used for |Connect()| (which also uses |FAILURE|, but |
69 // not |SUCCESS|). | 68 // not |SUCCESS|). |
70 SUCCESS_CONNECT_SAME_PROCESS, | 69 SUCCESS_CONNECT_SAME_PROCESS, |
71 SUCCESS_CONNECT_NEW_CONNECTION, | 70 SUCCESS_CONNECT_NEW_CONNECTION, |
72 SUCCESS_CONNECT_REUSE_CONNECTION | 71 SUCCESS_CONNECT_REUSE_CONNECTION |
73 }; | 72 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 explicit ConnectionManager(embedder::PlatformSupport* platform_support) | 114 explicit ConnectionManager(embedder::PlatformSupport* platform_support) |
116 : platform_support_(platform_support) {} | 115 : platform_support_(platform_support) {} |
117 | 116 |
118 private: | 117 private: |
119 embedder::PlatformSupport* const platform_support_; | 118 embedder::PlatformSupport* const platform_support_; |
120 | 119 |
121 MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectionManager); | 120 MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
122 }; | 121 }; |
123 | 122 |
124 // So logging macros and |DCHECK_EQ()|, etc. work. | 123 // So logging macros and |DCHECK_EQ()|, etc. work. |
125 MOJO_SYSTEM_IMPL_EXPORT inline std::ostream& operator<<( | 124 inline std::ostream& operator<<(std::ostream& out, |
126 std::ostream& out, | 125 ConnectionManager::Result result) { |
127 ConnectionManager::Result result) { | |
128 return out << static_cast<int>(result); | 126 return out << static_cast<int>(result); |
129 } | 127 } |
130 | 128 |
131 } // namespace system | 129 } // namespace system |
132 } // namespace mojo | 130 } // namespace mojo |
133 | 131 |
134 #endif // MOJO_EDK_SYSTEM_CONNECTION_MANAGER_H_ | 132 #endif // MOJO_EDK_SYSTEM_CONNECTION_MANAGER_H_ |
OLD | NEW |