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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return; | 179 return; |
180 } | 180 } |
181 endpoint_info = it->second; | 181 endpoint_info = it->second; |
182 } | 182 } |
183 | 183 |
184 // We need to duplicate the message, because |EnqueueMessage()| will take | 184 // We need to duplicate the message, because |EnqueueMessage()| will take |
185 // ownership of it. | 185 // ownership of it. |
186 MessageInTransit* own_message = MessageInTransit::Create( | 186 MessageInTransit* own_message = MessageInTransit::Create( |
187 message.type(), message.subtype(), message.data(), message.data_size()); | 187 message.type(), message.subtype(), message.data(), message.data_size()); |
188 if (endpoint_info.message_pipe->EnqueueMessage( | 188 if (endpoint_info.message_pipe->EnqueueMessage( |
189 MessagePipe::GetPeerPort(endpoint_info.port), | 189 MessagePipe::GetPeerPort(endpoint_info.port), own_message, NULL) != |
190 own_message) != MOJO_RESULT_OK) { | 190 MOJO_RESULT_OK) { |
191 HandleLocalError(base::StringPrintf( | 191 HandleLocalError(base::StringPrintf( |
192 "Failed to enqueue message to local destination ID %u", | 192 "Failed to enqueue message to local destination ID %u", |
193 static_cast<unsigned>(local_id))); | 193 static_cast<unsigned>(local_id))); |
194 return; | 194 return; |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 void Channel::OnReadMessageForChannel(const MessageInTransit& message) { | 198 void Channel::OnReadMessageForChannel(const MessageInTransit& message) { |
199 // TODO(vtl): Currently no channel-only messages yet. | 199 // TODO(vtl): Currently no channel-only messages yet. |
200 HandleRemoteError("Received invalid channel message"); | 200 HandleRemoteError("Received invalid channel message"); |
201 NOTREACHED(); | 201 NOTREACHED(); |
202 } | 202 } |
203 | 203 |
204 void Channel::HandleRemoteError(const base::StringPiece& error_message) { | 204 void Channel::HandleRemoteError(const base::StringPiece& error_message) { |
205 // TODO(vtl): Is this how we really want to handle this? | 205 // TODO(vtl): Is this how we really want to handle this? |
206 LOG(INFO) << error_message; | 206 LOG(INFO) << error_message; |
207 } | 207 } |
208 | 208 |
209 void Channel::HandleLocalError(const base::StringPiece& error_message) { | 209 void Channel::HandleLocalError(const base::StringPiece& error_message) { |
210 // TODO(vtl): Is this how we really want to handle this? | 210 // TODO(vtl): Is this how we really want to handle this? |
211 LOG(FATAL) << error_message; | 211 LOG(FATAL) << error_message; |
212 } | 212 } |
213 | 213 |
214 } // namespace system | 214 } // namespace system |
215 } // namespace mojo | 215 } // namespace mojo |
OLD | NEW |