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/proxy_message_pipe_endpoint.h" | 5 #include "mojo/edk/system/proxy_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/channel_endpoint.h" | 12 #include "mojo/edk/system/channel_endpoint.h" |
11 #include "mojo/edk/system/local_message_pipe_endpoint.h" | 13 #include "mojo/edk/system/local_message_pipe_endpoint.h" |
12 #include "mojo/edk/system/message_pipe_dispatcher.h" | 14 #include "mojo/edk/system/message_pipe_dispatcher.h" |
13 | 15 |
14 namespace mojo { | 16 namespace mojo { |
15 namespace system { | 17 namespace system { |
16 | 18 |
17 ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint( | 19 ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint( |
18 ChannelEndpoint* channel_endpoint) | 20 ChannelEndpoint* channel_endpoint) |
(...skipping 18 matching lines...) Expand all Loading... |
37 | 39 |
38 bool ProxyMessagePipeEndpoint::OnPeerClose() { | 40 bool ProxyMessagePipeEndpoint::OnPeerClose() { |
39 DetachIfNecessary(); | 41 DetachIfNecessary(); |
40 return false; | 42 return false; |
41 } | 43 } |
42 | 44 |
43 // Note: We may have to enqueue messages even when our (local) peer isn't open | 45 // Note: We may have to enqueue messages even when our (local) peer isn't open |
44 // -- it may have been written to and closed immediately, before we were ready. | 46 // -- it may have been written to and closed immediately, before we were ready. |
45 // This case is handled in |Run()| (which will call us). | 47 // This case is handled in |Run()| (which will call us). |
46 void ProxyMessagePipeEndpoint::EnqueueMessage( | 48 void ProxyMessagePipeEndpoint::EnqueueMessage( |
47 scoped_ptr<MessageInTransit> message) { | 49 std::unique_ptr<MessageInTransit> message) { |
48 DCHECK(channel_endpoint_); | 50 DCHECK(channel_endpoint_); |
49 bool ok = channel_endpoint_->EnqueueMessage(message.Pass()); | 51 bool ok = channel_endpoint_->EnqueueMessage(std::move(message)); |
50 LOG_IF(WARNING, !ok) << "Failed to write enqueue message to channel"; | 52 LOG_IF(WARNING, !ok) << "Failed to write enqueue message to channel"; |
51 } | 53 } |
52 | 54 |
53 void ProxyMessagePipeEndpoint::Close() { | 55 void ProxyMessagePipeEndpoint::Close() { |
54 DetachIfNecessary(); | 56 DetachIfNecessary(); |
55 } | 57 } |
56 | 58 |
57 void ProxyMessagePipeEndpoint::DetachIfNecessary() { | 59 void ProxyMessagePipeEndpoint::DetachIfNecessary() { |
58 if (channel_endpoint_) { | 60 if (channel_endpoint_) { |
59 channel_endpoint_->DetachFromClient(); | 61 channel_endpoint_->DetachFromClient(); |
60 channel_endpoint_ = nullptr; | 62 channel_endpoint_ = nullptr; |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
64 } // namespace system | 66 } // namespace system |
65 } // namespace mojo | 67 } // namespace mojo |
OLD | NEW |