Home | History | Annotate | Download | only in system
      1 // Copyright 2016 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "mojo/edk/system/data_pipe_control_message.h"
      6 
      7 #include "mojo/edk/embedder/platform_handle_vector.h"
      8 #include "mojo/edk/system/node_controller.h"
      9 #include "mojo/edk/system/ports_message.h"
     10 
     11 namespace mojo {
     12 namespace edk {
     13 
     14 void SendDataPipeControlMessage(NodeController* node_controller,
     15                                 const ports::PortRef& port,
     16                                 DataPipeCommand command,
     17                                 uint32_t num_bytes) {
     18   std::unique_ptr<PortsMessage> message =
     19       PortsMessage::NewUserMessage(sizeof(DataPipeControlMessage), 0, 0);
     20   CHECK(message);
     21 
     22   DataPipeControlMessage* data =
     23       static_cast<DataPipeControlMessage*>(message->mutable_payload_bytes());
     24   data->command = command;
     25   data->num_bytes = num_bytes;
     26 
     27   int rv = node_controller->SendMessage(port, std::move(message));
     28   if (rv != ports::OK && rv != ports::ERROR_PORT_PEER_CLOSED) {
     29     DLOG(ERROR) << "Unexpected failure sending data pipe control message: "
     30                 << rv;
     31   }
     32 }
     33 
     34 }  // namespace edk
     35 }  // namespace mojo
     36