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 #include "mojo/system/channel_endpoint.h" | 5 #include "mojo/system/channel_endpoint.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/system/channel.h" | 8 #include "mojo/system/channel.h" |
9 #include "mojo/system/message_pipe.h" | 9 #include "mojo/system/message_pipe.h" |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId); | 78 DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId); |
79 remote_id_ = remote_id; | 79 remote_id_ = remote_id; |
80 } | 80 } |
81 | 81 |
82 void ChannelEndpoint::DetachFromChannel() { | 82 void ChannelEndpoint::DetachFromChannel() { |
83 base::AutoLock locker(lock_); | 83 base::AutoLock locker(lock_); |
84 DCHECK(channel_); | 84 DCHECK(channel_); |
85 DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId); | 85 DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId); |
86 // TODO(vtl): Once we combine "run" into "attach", |remote_id_| should valid | 86 // TODO(vtl): Once we combine "run" into "attach", |remote_id_| should valid |
87 // here as well. | 87 // here as well. |
88 channel_ = NULL; | 88 channel_ = nullptr; |
89 local_id_ = MessageInTransit::kInvalidEndpointId; | 89 local_id_ = MessageInTransit::kInvalidEndpointId; |
90 remote_id_ = MessageInTransit::kInvalidEndpointId; | 90 remote_id_ = MessageInTransit::kInvalidEndpointId; |
91 } | 91 } |
92 | 92 |
93 ChannelEndpoint::~ChannelEndpoint() { | 93 ChannelEndpoint::~ChannelEndpoint() { |
94 DCHECK(!channel_); | 94 DCHECK(!channel_); |
95 DCHECK_EQ(local_id_, MessageInTransit::kInvalidEndpointId); | 95 DCHECK_EQ(local_id_, MessageInTransit::kInvalidEndpointId); |
96 DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId); | 96 DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId); |
97 } | 97 } |
98 | 98 |
99 bool ChannelEndpoint::WriteMessageNoLock(scoped_ptr<MessageInTransit> message) { | 99 bool ChannelEndpoint::WriteMessageNoLock(scoped_ptr<MessageInTransit> message) { |
100 DCHECK(message); | 100 DCHECK(message); |
101 | 101 |
102 lock_.AssertAcquired(); | 102 lock_.AssertAcquired(); |
103 | 103 |
104 DCHECK(channel_); | 104 DCHECK(channel_); |
105 DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId); | 105 DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId); |
106 DCHECK_NE(remote_id_, MessageInTransit::kInvalidEndpointId); | 106 DCHECK_NE(remote_id_, MessageInTransit::kInvalidEndpointId); |
107 | 107 |
108 message->SerializeAndCloseDispatchers(channel_); | 108 message->SerializeAndCloseDispatchers(channel_); |
109 message->set_source_id(local_id_); | 109 message->set_source_id(local_id_); |
110 message->set_destination_id(remote_id_); | 110 message->set_destination_id(remote_id_); |
111 return channel_->WriteMessage(message.Pass()); | 111 return channel_->WriteMessage(message.Pass()); |
112 } | 112 } |
113 | 113 |
114 } // namespace system | 114 } // namespace system |
115 } // namespace mojo | 115 } // namespace mojo |
OLD | NEW |