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/public/cpp/bindings/lib/pipe_control_message_proxy.h" | 5 #include "mojo/public/cpp/bindings/lib/pipe_control_message_proxy.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
8 #include "mojo/public/cpp/bindings/lib/message_builder.h" | 10 #include "mojo/public/cpp/bindings/lib/message_builder.h" |
9 #include "mojo/public/cpp/bindings/message.h" | 11 #include "mojo/public/cpp/bindings/message.h" |
10 #include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h" | 12 #include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h" |
11 | 13 |
12 namespace mojo { | 14 namespace mojo { |
13 namespace internal { | 15 namespace internal { |
14 namespace { | 16 namespace { |
15 | 17 |
16 void SendRunOrClosePipeMessage(MessageReceiver* receiver, | 18 void SendRunOrClosePipeMessage(MessageReceiver* receiver, |
17 pipe_control::RunOrClosePipeInputPtr input) { | 19 pipe_control::RunOrClosePipeInputPtr input) { |
18 pipe_control::RunOrClosePipeMessageParamsPtr params_ptr( | 20 pipe_control::RunOrClosePipeMessageParamsPtr params_ptr( |
19 pipe_control::RunOrClosePipeMessageParams::New()); | 21 pipe_control::RunOrClosePipeMessageParams::New()); |
20 params_ptr->input = input.Pass(); | 22 params_ptr->input = std::move(input); |
21 | 23 |
22 size_t size = GetSerializedSize_(params_ptr); | 24 size_t size = GetSerializedSize_(params_ptr); |
23 MessageBuilder builder(pipe_control::kRunOrClosePipeMessageId, size); | 25 MessageBuilder builder(pipe_control::kRunOrClosePipeMessageId, size); |
24 | 26 |
25 pipe_control::internal::RunOrClosePipeMessageParams_Data* params = nullptr; | 27 pipe_control::internal::RunOrClosePipeMessageParams_Data* params = nullptr; |
26 Serialize_(params_ptr.Pass(), builder.buffer(), ¶ms); | 28 Serialize_(std::move(params_ptr), builder.buffer(), ¶ms); |
27 params->EncodePointersAndHandles(builder.message()->mutable_handles()); | 29 params->EncodePointersAndHandles(builder.message()->mutable_handles()); |
28 builder.message()->set_interface_id(kInvalidInterfaceId); | 30 builder.message()->set_interface_id(kInvalidInterfaceId); |
29 bool ok = receiver->Accept(builder.message()); | 31 bool ok = receiver->Accept(builder.message()); |
30 // This return value may be ignored as !ok implies the underlying message pipe | 32 // This return value may be ignored as !ok implies the underlying message pipe |
31 // has encountered an error, which will be visible through other means. | 33 // has encountered an error, which will be visible through other means. |
32 ALLOW_UNUSED_LOCAL(ok); | 34 ALLOW_UNUSED_LOCAL(ok); |
33 } | 35 } |
34 | 36 |
35 } // namespace | 37 } // namespace |
36 | 38 |
37 PipeControlMessageProxy::PipeControlMessageProxy(MessageReceiver* receiver) | 39 PipeControlMessageProxy::PipeControlMessageProxy(MessageReceiver* receiver) |
38 : receiver_(receiver) {} | 40 : receiver_(receiver) {} |
39 | 41 |
40 void PipeControlMessageProxy::NotifyPeerEndpointClosed(InterfaceId id) { | 42 void PipeControlMessageProxy::NotifyPeerEndpointClosed(InterfaceId id) { |
41 pipe_control::PeerAssociatedEndpointClosedEventPtr event( | 43 pipe_control::PeerAssociatedEndpointClosedEventPtr event( |
42 pipe_control::PeerAssociatedEndpointClosedEvent::New()); | 44 pipe_control::PeerAssociatedEndpointClosedEvent::New()); |
43 event->id = id; | 45 event->id = id; |
44 | 46 |
45 pipe_control::RunOrClosePipeInputPtr input( | 47 pipe_control::RunOrClosePipeInputPtr input( |
46 pipe_control::RunOrClosePipeInput::New()); | 48 pipe_control::RunOrClosePipeInput::New()); |
47 input->set_peer_associated_endpoint_closed_event(event.Pass()); | 49 input->set_peer_associated_endpoint_closed_event(std::move(event)); |
48 | 50 |
49 SendRunOrClosePipeMessage(receiver_, input.Pass()); | 51 SendRunOrClosePipeMessage(receiver_, std::move(input)); |
50 } | 52 } |
51 | 53 |
52 void PipeControlMessageProxy::NotifyEndpointClosedBeforeSent(InterfaceId id) { | 54 void PipeControlMessageProxy::NotifyEndpointClosedBeforeSent(InterfaceId id) { |
53 pipe_control::AssociatedEndpointClosedBeforeSentEventPtr event( | 55 pipe_control::AssociatedEndpointClosedBeforeSentEventPtr event( |
54 pipe_control::AssociatedEndpointClosedBeforeSentEvent::New()); | 56 pipe_control::AssociatedEndpointClosedBeforeSentEvent::New()); |
55 event->id = id; | 57 event->id = id; |
56 | 58 |
57 pipe_control::RunOrClosePipeInputPtr input( | 59 pipe_control::RunOrClosePipeInputPtr input( |
58 pipe_control::RunOrClosePipeInput::New()); | 60 pipe_control::RunOrClosePipeInput::New()); |
59 input->set_associated_endpoint_closed_before_sent_event(event.Pass()); | 61 input->set_associated_endpoint_closed_before_sent_event(std::move(event)); |
60 | 62 |
61 SendRunOrClosePipeMessage(receiver_, input.Pass()); | 63 SendRunOrClosePipeMessage(receiver_, std::move(input)); |
62 } | 64 } |
63 | 65 |
64 } // namespace internal | 66 } // namespace internal |
65 } // namespace mojo | 67 } // namespace mojo |
OLD | NEW |