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