| 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/channel.h" | 5 #include "mojo/edk/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" | |
| 11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 13 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 14 #include "mojo/edk/embedder/platform_handle_vector.h" | 13 #include "mojo/edk/embedder/platform_handle_vector.h" |
| 15 #include "mojo/edk/system/transport_data.h" | 14 #include "mojo/edk/system/transport_data.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace system { | 17 namespace system { |
| 19 | 18 |
| 20 Channel::Channel(embedder::PlatformSupport* platform_support) | 19 Channel::Channel(embedder::PlatformSupport* platform_support) |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 "Received a message for nonexistent local destination ID %u", | 323 "Received a message for nonexistent local destination ID %u", |
| 325 static_cast<unsigned>(local_id.value()))); | 324 static_cast<unsigned>(local_id.value()))); |
| 326 // This is strongly indicative of some problem. However, it's not a fatal | 325 // This is strongly indicative of some problem. However, it's not a fatal |
| 327 // error, since it may indicate a buggy (or hostile) remote process. Don't | 326 // error, since it may indicate a buggy (or hostile) remote process. Don't |
| 328 // die even for Debug builds, since handling this properly needs to be | 327 // die even for Debug builds, since handling this properly needs to be |
| 329 // tested (TODO(vtl)). | 328 // tested (TODO(vtl)). |
| 330 DLOG(ERROR) << "This should not happen under normal operation."; | 329 DLOG(ERROR) << "This should not happen under normal operation."; |
| 331 return; | 330 return; |
| 332 } | 331 } |
| 333 | 332 |
| 334 if (!endpoint->OnReadMessage(message_view, platform_handles.Pass())) { | 333 scoped_ptr<MessageInTransit> message(new MessageInTransit(message_view)); |
| 334 if (message_view.transport_data_buffer_size() > 0) { |
| 335 DCHECK(message_view.transport_data_buffer()); |
| 336 message->SetDispatchers(TransportData::DeserializeDispatchers( |
| 337 message_view.transport_data_buffer(), |
| 338 message_view.transport_data_buffer_size(), platform_handles.Pass(), |
| 339 this)); |
| 340 } |
| 341 |
| 342 if (!endpoint->OnReadMessage(message.Pass())) { |
| 335 HandleLocalError( | 343 HandleLocalError( |
| 336 base::StringPrintf("Failed to enqueue message to local ID %u", | 344 base::StringPrintf("Failed to enqueue message to local ID %u", |
| 337 static_cast<unsigned>(local_id.value()))); | 345 static_cast<unsigned>(local_id.value()))); |
| 338 return; | 346 return; |
| 339 } | 347 } |
| 340 } | 348 } |
| 341 | 349 |
| 342 void Channel::OnReadMessageForChannel( | 350 void Channel::OnReadMessageForChannel( |
| 343 const MessageInTransit::View& message_view, | 351 const MessageInTransit::View& message_view, |
| 344 embedder::ScopedPlatformHandleVectorPtr platform_handles) { | 352 embedder::ScopedPlatformHandleVectorPtr platform_handles) { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // TODO(vtl): Is this how we really want to handle this? | 527 // TODO(vtl): Is this how we really want to handle this? |
| 520 // Sometimes we'll want to propagate the error back to the message pipe | 528 // Sometimes we'll want to propagate the error back to the message pipe |
| 521 // (endpoint), and notify it that the remote is (effectively) closed. | 529 // (endpoint), and notify it that the remote is (effectively) closed. |
| 522 // Sometimes we'll want to kill the channel (and notify all the endpoints that | 530 // Sometimes we'll want to kill the channel (and notify all the endpoints that |
| 523 // their remotes are dead. | 531 // their remotes are dead. |
| 524 LOG(WARNING) << error_message; | 532 LOG(WARNING) << error_message; |
| 525 } | 533 } |
| 526 | 534 |
| 527 } // namespace system | 535 } // namespace system |
| 528 } // namespace mojo | 536 } // namespace mojo |
| OLD | NEW |