OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHANNEL_MANAGER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ |
6 #define MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ | 6 #define MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // TODO(vtl): Consider if this is really necessary, since it only has one use | 63 // TODO(vtl): Consider if this is really necessary, since it only has one use |
64 // (in tests). | 64 // (in tests). |
65 void Shutdown(const base::Closure& callback, | 65 void Shutdown(const base::Closure& callback, |
66 scoped_refptr<base::TaskRunner> callback_thread_task_runner); | 66 scoped_refptr<base::TaskRunner> callback_thread_task_runner); |
67 | 67 |
68 // Creates a |Channel| and adds it to the set of channels managed by this | 68 // Creates a |Channel| and adds it to the set of channels managed by this |
69 // |ChannelManager|. This must be called from the I/O thread (given to the | 69 // |ChannelManager|. This must be called from the I/O thread (given to the |
70 // constructor). |channel_id| should be a valid |ChannelId| (i.e., nonzero) | 70 // constructor). |channel_id| should be a valid |ChannelId| (i.e., nonzero) |
71 // not "assigned" to any other |Channel| being managed by this | 71 // not "assigned" to any other |Channel| being managed by this |
72 // |ChannelManager|. | 72 // |ChannelManager|. |
73 scoped_refptr<MessagePipeDispatcher> CreateChannelOnIOThread( | 73 RefPtr<MessagePipeDispatcher> CreateChannelOnIOThread( |
74 ChannelId channel_id, | 74 ChannelId channel_id, |
75 embedder::ScopedPlatformHandle platform_handle); | 75 embedder::ScopedPlatformHandle platform_handle); |
76 | 76 |
77 // Like |CreateChannelOnIOThread()|, but doesn't create a bootstrap message | 77 // Like |CreateChannelOnIOThread()|, but doesn't create a bootstrap message |
78 // pipe. Returns the newly-created |Channel|. | 78 // pipe. Returns the newly-created |Channel|. |
79 // TODO(vtl): Maybe get rid of the others (and bootstrap message pipes in | 79 // TODO(vtl): Maybe get rid of the others (and bootstrap message pipes in |
80 // general). | 80 // general). |
81 RefPtr<Channel> CreateChannelWithoutBootstrapOnIOThread( | 81 RefPtr<Channel> CreateChannelWithoutBootstrapOnIOThread( |
82 ChannelId channel_id, | 82 ChannelId channel_id, |
83 embedder::ScopedPlatformHandle platform_handle); | 83 embedder::ScopedPlatformHandle platform_handle); |
84 | 84 |
85 // Like |CreateChannelOnIOThread()|, but may be called from any thread. On | 85 // Like |CreateChannelOnIOThread()|, but may be called from any thread. On |
86 // completion, will call |callback| (using |callback_thread_task_runner| if it | 86 // completion, will call |callback| (using |callback_thread_task_runner| if it |
87 // is non-null, else on the I/O thread). Note: This will always post a task to | 87 // is non-null, else on the I/O thread). Note: This will always post a task to |
88 // the I/O thread, even if called from that thread. | 88 // the I/O thread, even if called from that thread. |
89 scoped_refptr<MessagePipeDispatcher> CreateChannel( | 89 RefPtr<MessagePipeDispatcher> CreateChannel( |
90 ChannelId channel_id, | 90 ChannelId channel_id, |
91 embedder::ScopedPlatformHandle platform_handle, | 91 embedder::ScopedPlatformHandle platform_handle, |
92 const base::Closure& callback, | 92 const base::Closure& callback, |
93 scoped_refptr<base::TaskRunner> callback_thread_task_runner); | 93 scoped_refptr<base::TaskRunner> callback_thread_task_runner); |
94 | 94 |
95 // Gets the |Channel| with the given ID (which must exist). | 95 // Gets the |Channel| with the given ID (which must exist). |
96 RefPtr<Channel> GetChannel(ChannelId channel_id) const; | 96 RefPtr<Channel> GetChannel(ChannelId channel_id) const; |
97 | 97 |
98 // Informs the channel manager (and thus channel) that it will be shutdown | 98 // Informs the channel manager (and thus channel) that it will be shutdown |
99 // soon (by calling |ShutdownChannel()|). Calling this is optional (and may in | 99 // soon (by calling |ShutdownChannel()|). Calling this is optional (and may in |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 using ChannelIdToChannelMap = std::unordered_map<ChannelId, RefPtr<Channel>>; | 157 using ChannelIdToChannelMap = std::unordered_map<ChannelId, RefPtr<Channel>>; |
158 ChannelIdToChannelMap channels_ MOJO_GUARDED_BY(mutex_); | 158 ChannelIdToChannelMap channels_ MOJO_GUARDED_BY(mutex_); |
159 | 159 |
160 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelManager); | 160 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelManager); |
161 }; | 161 }; |
162 | 162 |
163 } // namespace system | 163 } // namespace system |
164 } // namespace mojo | 164 } // namespace mojo |
165 | 165 |
166 #endif // MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ | 166 #endif // MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ |
OLD | NEW |