| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/message_pipe_dispatcher.h" | 5 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 MojoResult MessagePipeDispatcher::WriteMessage( | 135 MojoResult MessagePipeDispatcher::WriteMessage( |
| 136 std::unique_ptr<MessageForTransit> message, | 136 std::unique_ptr<MessageForTransit> message, |
| 137 MojoWriteMessageFlags flags) { | 137 MojoWriteMessageFlags flags) { |
| 138 if (port_closed_ || in_transit_) | 138 if (port_closed_ || in_transit_) |
| 139 return MOJO_RESULT_INVALID_ARGUMENT; | 139 return MOJO_RESULT_INVALID_ARGUMENT; |
| 140 | 140 |
| 141 size_t num_bytes = message->num_bytes(); | 141 size_t num_bytes = message->num_bytes(); |
| 142 int rv = node_controller_->SendMessage(port_, message->TakePortsMessage()); | 142 int rv = node_controller_->SendMessage(port_, message->TakePortsMessage()); |
| 143 | 143 |
| 144 DVLOG(2) << "Sent message on pipe " << pipe_id_ << " endpoint " << endpoint_ | 144 DVLOG(4) << "Sent message on pipe " << pipe_id_ << " endpoint " << endpoint_ |
| 145 << " [port=" << port_.name() << "; rv=" << rv | 145 << " [port=" << port_.name() << "; rv=" << rv |
| 146 << "; num_bytes=" << num_bytes << "]"; | 146 << "; num_bytes=" << num_bytes << "]"; |
| 147 | 147 |
| 148 if (rv != ports::OK) { | 148 if (rv != ports::OK) { |
| 149 if (rv == ports::ERROR_PORT_UNKNOWN || | 149 if (rv == ports::ERROR_PORT_UNKNOWN || |
| 150 rv == ports::ERROR_PORT_STATE_UNEXPECTED || | 150 rv == ports::ERROR_PORT_STATE_UNEXPECTED || |
| 151 rv == ports::ERROR_PORT_CANNOT_SEND_PEER) { | 151 rv == ports::ERROR_PORT_CANNOT_SEND_PEER) { |
| 152 return MOJO_RESULT_INVALID_ARGUMENT; | 152 return MOJO_RESULT_INVALID_ARGUMENT; |
| 153 } else if (rv == ports::ERROR_PORT_PEER_CLOSED) { | 153 } else if (rv == ports::ERROR_PORT_PEER_CLOSED) { |
| 154 base::AutoLock lock(signal_lock_); | 154 base::AutoLock lock(signal_lock_); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 ports::PortStatus port_status; | 529 ports::PortStatus port_status; |
| 530 if (node_controller_->node()->GetStatus(port_, &port_status) == ports::OK) { | 530 if (node_controller_->node()->GetStatus(port_, &port_status) == ports::OK) { |
| 531 if (port_status.has_messages) { | 531 if (port_status.has_messages) { |
| 532 ports::ScopedMessage unused; | 532 ports::ScopedMessage unused; |
| 533 size_t message_size = 0; | 533 size_t message_size = 0; |
| 534 node_controller_->node()->GetMessageIf( | 534 node_controller_->node()->GetMessageIf( |
| 535 port_, [&message_size](const ports::Message& message) { | 535 port_, [&message_size](const ports::Message& message) { |
| 536 message_size = message.num_payload_bytes(); | 536 message_size = message.num_payload_bytes(); |
| 537 return false; | 537 return false; |
| 538 }, &unused); | 538 }, &unused); |
| 539 DVLOG(2) << "New message detected on message pipe " << pipe_id_ | 539 DVLOG(4) << "New message detected on message pipe " << pipe_id_ |
| 540 << " endpoint " << endpoint_ << " [port=" << port_.name() | 540 << " endpoint " << endpoint_ << " [port=" << port_.name() |
| 541 << "; size=" << message_size << "]"; | 541 << "; size=" << message_size << "]"; |
| 542 } | 542 } |
| 543 if (port_status.peer_closed) { | 543 if (port_status.peer_closed) { |
| 544 DVLOG(2) << "Peer closure detected on message pipe " << pipe_id_ | 544 DVLOG(2) << "Peer closure detected on message pipe " << pipe_id_ |
| 545 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; | 545 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 #endif | 548 #endif |
| 549 | 549 |
| 550 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | 550 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); |
| 551 } | 551 } |
| 552 | 552 |
| 553 } // namespace edk | 553 } // namespace edk |
| 554 } // namespace mojo | 554 } // namespace mojo |
| OLD | NEW |