OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/local_message_pipe_endpoint.h" | 5 #include "mojo/edk/system/local_message_pipe_endpoint.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
| 9 #include <utility> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "mojo/edk/system/dispatcher.h" | 12 #include "mojo/edk/system/dispatcher.h" |
11 #include "mojo/edk/system/message_in_transit.h" | 13 #include "mojo/edk/system/message_in_transit.h" |
12 | 14 |
13 namespace mojo { | 15 namespace mojo { |
14 namespace system { | 16 namespace system { |
15 | 17 |
16 LocalMessagePipeEndpoint::LocalMessagePipeEndpoint( | 18 LocalMessagePipeEndpoint::LocalMessagePipeEndpoint( |
17 MessageInTransitQueue* message_queue) | 19 MessageInTransitQueue* message_queue) |
18 : is_open_(true), is_peer_open_(true) { | 20 : is_open_(true), is_peer_open_(true) { |
(...skipping 18 matching lines...) Expand all Loading... |
37 is_peer_open_ = false; | 39 is_peer_open_ = false; |
38 HandleSignalsState new_state = GetHandleSignalsState(); | 40 HandleSignalsState new_state = GetHandleSignalsState(); |
39 | 41 |
40 if (!new_state.equals(old_state)) | 42 if (!new_state.equals(old_state)) |
41 awakable_list_.AwakeForStateChange(new_state); | 43 awakable_list_.AwakeForStateChange(new_state); |
42 | 44 |
43 return true; | 45 return true; |
44 } | 46 } |
45 | 47 |
46 void LocalMessagePipeEndpoint::EnqueueMessage( | 48 void LocalMessagePipeEndpoint::EnqueueMessage( |
47 scoped_ptr<MessageInTransit> message) { | 49 std::unique_ptr<MessageInTransit> message) { |
48 DCHECK(is_open_); | 50 DCHECK(is_open_); |
49 DCHECK(is_peer_open_); | 51 DCHECK(is_peer_open_); |
50 | 52 |
51 bool was_empty = message_queue_.IsEmpty(); | 53 bool was_empty = message_queue_.IsEmpty(); |
52 message_queue_.AddMessage(message.Pass()); | 54 message_queue_.AddMessage(std::move(message)); |
53 if (was_empty) | 55 if (was_empty) |
54 awakable_list_.AwakeForStateChange(GetHandleSignalsState()); | 56 awakable_list_.AwakeForStateChange(GetHandleSignalsState()); |
55 } | 57 } |
56 | 58 |
57 void LocalMessagePipeEndpoint::Close() { | 59 void LocalMessagePipeEndpoint::Close() { |
58 DCHECK(is_open_); | 60 DCHECK(is_open_); |
59 is_open_ = false; | 61 is_open_ = false; |
60 message_queue_.Clear(); | 62 message_queue_.Clear(); |
61 } | 63 } |
62 | 64 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 Awakable* awakable, | 176 Awakable* awakable, |
175 HandleSignalsState* signals_state) { | 177 HandleSignalsState* signals_state) { |
176 DCHECK(is_open_); | 178 DCHECK(is_open_); |
177 awakable_list_.Remove(awakable); | 179 awakable_list_.Remove(awakable); |
178 if (signals_state) | 180 if (signals_state) |
179 *signals_state = GetHandleSignalsState(); | 181 *signals_state = GetHandleSignalsState(); |
180 } | 182 } |
181 | 183 |
182 } // namespace system | 184 } // namespace system |
183 } // namespace mojo | 185 } // namespace mojo |
OLD | NEW |