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/system/channel.h" | 5 #include "mojo/system/channel.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 endpoint->AttachToChannel(this, local_id); | 120 endpoint->AttachToChannel(this, local_id); |
121 return local_id; | 121 return local_id; |
122 } | 122 } |
123 | 123 |
124 bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id, | 124 bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id, |
125 MessageInTransit::EndpointId remote_id) { | 125 MessageInTransit::EndpointId remote_id) { |
126 scoped_refptr<ChannelEndpoint> endpoint; | 126 scoped_refptr<ChannelEndpoint> endpoint; |
127 ChannelEndpoint::State state; | 127 ChannelEndpoint::State state; |
128 scoped_refptr<MessagePipe> message_pipe; | |
129 unsigned port; | |
130 { | 128 { |
131 base::AutoLock locker(lock_); | 129 base::AutoLock locker(lock_); |
132 | 130 |
133 DLOG_IF(WARNING, is_shutting_down_) | 131 DLOG_IF(WARNING, is_shutting_down_) |
134 << "RunMessagePipeEndpoint() while shutting down"; | 132 << "RunMessagePipeEndpoint() while shutting down"; |
135 | 133 |
136 IdToEndpointMap::const_iterator it = | 134 IdToEndpointMap::const_iterator it = |
137 local_id_to_endpoint_map_.find(local_id); | 135 local_id_to_endpoint_map_.find(local_id); |
138 if (it == local_id_to_endpoint_map_.end()) | 136 if (it == local_id_to_endpoint_map_.end()) |
139 return false; | 137 return false; |
140 endpoint = it->second; | 138 endpoint = it->second; |
141 state = it->second->state_; | 139 state = it->second->state_; |
142 message_pipe = it->second->message_pipe_; | |
143 port = it->second->port_; | |
144 } | 140 } |
145 | 141 |
146 // Assume that this was in response to |kSubtypeChannelRunMessagePipeEndpoint| | 142 // Assume that this was in response to |kSubtypeChannelRunMessagePipeEndpoint| |
147 // and ignore it. | 143 // and ignore it. |
148 if (state != ChannelEndpoint::STATE_NORMAL) { | 144 if (state != ChannelEndpoint::STATE_NORMAL) { |
149 DVLOG(2) << "Ignoring run message pipe endpoint for zombie endpoint " | 145 DVLOG(2) << "Ignoring run message pipe endpoint for zombie endpoint " |
150 "(local ID " << local_id << ", remote ID " << remote_id << ")"; | 146 "(local ID " << local_id << ", remote ID " << remote_id << ")"; |
151 return true; | 147 return true; |
152 } | 148 } |
153 | 149 |
154 // TODO(vtl): FIXME -- We need to handle the case that message pipe is already | 150 // TODO(vtl): FIXME -- We need to handle the case that message pipe is already |
155 // running when we're here due to |kSubtypeChannelRunMessagePipeEndpoint|). | 151 // running when we're here due to |kSubtypeChannelRunMessagePipeEndpoint|). |
156 endpoint->Run(remote_id); | 152 endpoint->Run(remote_id); |
157 // TODO(vtl): Get rid of this. | |
158 message_pipe->Run(port); | |
159 return true; | 153 return true; |
160 } | 154 } |
161 | 155 |
162 void Channel::RunRemoteMessagePipeEndpoint( | 156 void Channel::RunRemoteMessagePipeEndpoint( |
163 MessageInTransit::EndpointId local_id, | 157 MessageInTransit::EndpointId local_id, |
164 MessageInTransit::EndpointId remote_id) { | 158 MessageInTransit::EndpointId remote_id) { |
165 #if DCHECK_IS_ON | 159 #if DCHECK_IS_ON |
166 { | 160 { |
167 base::AutoLock locker(lock_); | 161 base::AutoLock locker(lock_); |
168 DCHECK(local_id_to_endpoint_map_.find(local_id) != | 162 DCHECK(local_id_to_endpoint_map_.find(local_id) != |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // TODO(vtl): Is this how we really want to handle this? | 520 // TODO(vtl): Is this how we really want to handle this? |
527 // Sometimes we'll want to propagate the error back to the message pipe | 521 // Sometimes we'll want to propagate the error back to the message pipe |
528 // (endpoint), and notify it that the remote is (effectively) closed. | 522 // (endpoint), and notify it that the remote is (effectively) closed. |
529 // Sometimes we'll want to kill the channel (and notify all the endpoints that | 523 // Sometimes we'll want to kill the channel (and notify all the endpoints that |
530 // their remotes are dead. | 524 // their remotes are dead. |
531 LOG(WARNING) << error_message; | 525 LOG(WARNING) << error_message; |
532 } | 526 } |
533 | 527 |
534 } // namespace system | 528 } // namespace system |
535 } // namespace mojo | 529 } // namespace mojo |
OLD | NEW |