Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: mojo/public/cpp/bindings/lib/pipe_control_message_proxy.cc

Issue 1955123003: Mojo C++ bindings: switch the remaining callsites of the old serialization interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@24_union_and_others
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "mojo/public/cpp/bindings/lib/message_builder.h" 11 #include "mojo/public/cpp/bindings/lib/message_builder.h"
12 #include "mojo/public/cpp/bindings/lib/serialization.h"
12 #include "mojo/public/cpp/bindings/message.h" 13 #include "mojo/public/cpp/bindings/message.h"
13 #include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h" 14 #include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h"
14 15
15 namespace mojo { 16 namespace mojo {
16 namespace internal { 17 namespace internal {
17 namespace { 18 namespace {
18 19
19 void SendRunOrClosePipeMessage(MessageReceiver* receiver, 20 void SendRunOrClosePipeMessage(MessageReceiver* receiver,
20 pipe_control::RunOrClosePipeInputPtr input) { 21 pipe_control::RunOrClosePipeInputPtr input,
22 SerializationContext* context) {
21 pipe_control::RunOrClosePipeMessageParamsPtr params_ptr( 23 pipe_control::RunOrClosePipeMessageParamsPtr params_ptr(
22 pipe_control::RunOrClosePipeMessageParams::New()); 24 pipe_control::RunOrClosePipeMessageParams::New());
23 params_ptr->input = std::move(input); 25 params_ptr->input = std::move(input);
24 26
25 size_t size = GetSerializedSize_(params_ptr, nullptr); 27 size_t size =
28 PrepareToSerialize<pipe_control::RunOrClosePipeMessageParamsPtr>(
29 params_ptr, context);
26 MessageBuilder builder(pipe_control::kRunOrClosePipeMessageId, size); 30 MessageBuilder builder(pipe_control::kRunOrClosePipeMessageId, size);
27 31
28 pipe_control::internal::RunOrClosePipeMessageParams_Data* params = nullptr; 32 pipe_control::internal::RunOrClosePipeMessageParams_Data* params = nullptr;
29 Serialize_(std::move(params_ptr), builder.buffer(), &params, nullptr); 33 Serialize<pipe_control::RunOrClosePipeMessageParamsPtr>(
34 params_ptr, builder.buffer(), &params, context);
30 params->EncodePointers(); 35 params->EncodePointers();
31 builder.message()->set_interface_id(kInvalidInterfaceId); 36 builder.message()->set_interface_id(kInvalidInterfaceId);
32 bool ok = receiver->Accept(builder.message()); 37 bool ok = receiver->Accept(builder.message());
33 // This return value may be ignored as !ok implies the underlying message pipe 38 // This return value may be ignored as !ok implies the underlying message pipe
34 // has encountered an error, which will be visible through other means. 39 // has encountered an error, which will be visible through other means.
35 ALLOW_UNUSED_LOCAL(ok); 40 ALLOW_UNUSED_LOCAL(ok);
36 } 41 }
37 42
38 } // namespace 43 } // namespace
39 44
40 PipeControlMessageProxy::PipeControlMessageProxy(MessageReceiver* receiver) 45 PipeControlMessageProxy::PipeControlMessageProxy(MessageReceiver* receiver)
41 : receiver_(receiver) {} 46 : receiver_(receiver) {}
42 47
43 void PipeControlMessageProxy::NotifyPeerEndpointClosed(InterfaceId id) { 48 void PipeControlMessageProxy::NotifyPeerEndpointClosed(InterfaceId id) {
44 pipe_control::PeerAssociatedEndpointClosedEventPtr event( 49 pipe_control::PeerAssociatedEndpointClosedEventPtr event(
45 pipe_control::PeerAssociatedEndpointClosedEvent::New()); 50 pipe_control::PeerAssociatedEndpointClosedEvent::New());
46 event->id = id; 51 event->id = id;
47 52
48 pipe_control::RunOrClosePipeInputPtr input( 53 pipe_control::RunOrClosePipeInputPtr input(
49 pipe_control::RunOrClosePipeInput::New()); 54 pipe_control::RunOrClosePipeInput::New());
50 input->set_peer_associated_endpoint_closed_event(std::move(event)); 55 input->set_peer_associated_endpoint_closed_event(std::move(event));
51 56
52 SendRunOrClosePipeMessage(receiver_, std::move(input)); 57 SendRunOrClosePipeMessage(receiver_, std::move(input), &context_);
53 } 58 }
54 59
55 void PipeControlMessageProxy::NotifyEndpointClosedBeforeSent(InterfaceId id) { 60 void PipeControlMessageProxy::NotifyEndpointClosedBeforeSent(InterfaceId id) {
56 pipe_control::AssociatedEndpointClosedBeforeSentEventPtr event( 61 pipe_control::AssociatedEndpointClosedBeforeSentEventPtr event(
57 pipe_control::AssociatedEndpointClosedBeforeSentEvent::New()); 62 pipe_control::AssociatedEndpointClosedBeforeSentEvent::New());
58 event->id = id; 63 event->id = id;
59 64
60 pipe_control::RunOrClosePipeInputPtr input( 65 pipe_control::RunOrClosePipeInputPtr input(
61 pipe_control::RunOrClosePipeInput::New()); 66 pipe_control::RunOrClosePipeInput::New());
62 input->set_associated_endpoint_closed_before_sent_event(std::move(event)); 67 input->set_associated_endpoint_closed_before_sent_event(std::move(event));
63 68
64 SendRunOrClosePipeMessage(receiver_, std::move(input)); 69 SendRunOrClosePipeMessage(receiver_, std::move(input), &context_);
65 } 70 }
66 71
67 } // namespace internal 72 } // namespace internal
68 } // namespace mojo 73 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/pipe_control_message_proxy.h ('k') | mojo/public/cpp/bindings/lib/serialization_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698