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_ENDPOINT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ |
6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ | 6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "mojo/edk/system/channel_endpoint_id.h" | 10 #include "mojo/edk/system/channel_endpoint_id.h" |
11 #include "mojo/edk/system/message_in_transit_queue.h" | 11 #include "mojo/edk/system/message_in_transit_queue.h" |
12 #include "mojo/edk/system/mutex.h" | 12 #include "mojo/edk/util/mutex.h" |
13 #include "mojo/edk/util/ref_counted.h" | 13 #include "mojo/edk/util/ref_counted.h" |
14 #include "mojo/edk/util/ref_ptr.h" | 14 #include "mojo/edk/util/ref_ptr.h" |
| 15 #include "mojo/edk/util/thread_annotations.h" |
15 #include "mojo/public/cpp/system/macros.h" | 16 #include "mojo/public/cpp/system/macros.h" |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 namespace system { | 19 namespace system { |
19 | 20 |
20 class Channel; | 21 class Channel; |
21 class ChannelEndpointClient; | 22 class ChannelEndpointClient; |
22 class MessageInTransit; | 23 class MessageInTransit; |
23 | 24 |
24 // TODO(vtl): The plan: | 25 // TODO(vtl): The plan: |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 bool WriteMessageNoLock(std::unique_ptr<MessageInTransit> message) | 172 bool WriteMessageNoLock(std::unique_ptr<MessageInTransit> message) |
172 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 173 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
173 | 174 |
174 // Helper for |OnReadMessage()|, handling messages for the client. | 175 // Helper for |OnReadMessage()|, handling messages for the client. |
175 void OnReadMessageForClient(std::unique_ptr<MessageInTransit> message); | 176 void OnReadMessageForClient(std::unique_ptr<MessageInTransit> message); |
176 | 177 |
177 // Moves |state_| from |RUNNING| to |DEAD|. |channel_| must be non-null, but | 178 // Moves |state_| from |RUNNING| to |DEAD|. |channel_| must be non-null, but |
178 // this does not call |channel_->DetachEndpoint()|. | 179 // this does not call |channel_->DetachEndpoint()|. |
179 void DieNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 180 void DieNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
180 | 181 |
181 Mutex mutex_; | 182 util::Mutex mutex_; |
182 | 183 |
183 enum class State { | 184 enum class State { |
184 // |AttachAndRun()| has not been called yet (|channel_| is null). | 185 // |AttachAndRun()| has not been called yet (|channel_| is null). |
185 PAUSED, | 186 PAUSED, |
186 // |AttachAndRun()| has been called, but not |DetachFromChannel()| | 187 // |AttachAndRun()| has been called, but not |DetachFromChannel()| |
187 // (|channel_| is non-null and valid). | 188 // (|channel_| is non-null and valid). |
188 RUNNING, | 189 RUNNING, |
189 // |DetachFromChannel()| has been called (|channel_| is null). | 190 // |DetachFromChannel()| has been called (|channel_| is null). |
190 DEAD | 191 DEAD |
191 }; | 192 }; |
(...skipping 27 matching lines...) Expand all Loading... |
219 // messages to the channel. | 220 // messages to the channel. |
220 MessageInTransitQueue channel_message_queue_ MOJO_GUARDED_BY(mutex_); | 221 MessageInTransitQueue channel_message_queue_ MOJO_GUARDED_BY(mutex_); |
221 | 222 |
222 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); | 223 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); |
223 }; | 224 }; |
224 | 225 |
225 } // namespace system | 226 } // namespace system |
226 } // namespace mojo | 227 } // namespace mojo |
227 | 228 |
228 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ | 229 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_H_ |
OLD | NEW |