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

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

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h"
12 #include "mojo/public/cpp/bindings/lib/message_builder.h" 13 #include "mojo/public/cpp/bindings/lib/message_builder.h"
13 #include "mojo/public/cpp/bindings/lib/serialization.h" 14 #include "mojo/public/cpp/bindings/lib/serialization.h"
14 #include "mojo/public/cpp/bindings/message.h" 15 #include "mojo/public/cpp/bindings/message.h"
15 #include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h" 16 #include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace internal { 19 namespace internal {
19 namespace { 20 namespace {
20 21
21 void SendRunOrClosePipeMessage(MessageReceiver* receiver, 22 void SendRunOrClosePipeMessage(MessageReceiver* receiver,
22 pipe_control::RunOrClosePipeInputPtr input, 23 pipe_control::RunOrClosePipeInputPtr input,
23 SerializationContext* context) { 24 SerializationContext* context) {
24 pipe_control::RunOrClosePipeMessageParamsPtr params_ptr( 25 pipe_control::RunOrClosePipeMessageParamsPtr params_ptr(
25 pipe_control::RunOrClosePipeMessageParams::New()); 26 pipe_control::RunOrClosePipeMessageParams::New());
26 params_ptr->input = std::move(input); 27 params_ptr->input = std::move(input);
27 28
28 size_t size = 29 size_t size =
29 PrepareToSerialize<pipe_control::RunOrClosePipeMessageParamsPtr>( 30 PrepareToSerialize<pipe_control::RunOrClosePipeMessageParamsPtr>(
30 params_ptr, context); 31 params_ptr, context);
31 MessageBuilder builder(pipe_control::kRunOrClosePipeMessageId, size); 32 MessageBuilder builder(pipe_control::kRunOrClosePipeMessageId, size);
32 33
33 pipe_control::internal::RunOrClosePipeMessageParams_Data* params = nullptr; 34 pipe_control::internal::RunOrClosePipeMessageParams_Data* params = nullptr;
34 Serialize<pipe_control::RunOrClosePipeMessageParamsPtr>( 35 Serialize<pipe_control::RunOrClosePipeMessageParamsPtr>(
35 params_ptr, builder.buffer(), &params, context); 36 params_ptr, builder.buffer(), &params, context);
36 params->EncodePointers(); 37 params->EncodePointers();
37 builder.message()->set_interface_id(kInvalidInterfaceId); 38 builder.message()->set_interface_id(kInvalidInterfaceId);
38 bool ok = receiver->Accept(builder.message()); 39 // This return value may be ignored as failure implies the underlying message
39 // This return value may be ignored as !ok implies the underlying message pipe 40 // pipe has encountered an error, which will be visible through other means.
40 // has encountered an error, which will be visible through other means. 41 ignore_result(receiver->Accept(builder.message()));
41 ALLOW_UNUSED_LOCAL(ok);
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 PipeControlMessageProxy::PipeControlMessageProxy(MessageReceiver* receiver) 46 PipeControlMessageProxy::PipeControlMessageProxy(MessageReceiver* receiver)
47 : receiver_(receiver) {} 47 : receiver_(receiver) {}
48 48
49 void PipeControlMessageProxy::NotifyPeerEndpointClosed(InterfaceId id) { 49 void PipeControlMessageProxy::NotifyPeerEndpointClosed(InterfaceId id) {
50 DCHECK(!IsMasterInterfaceId(id)); 50 DCHECK(!IsMasterInterfaceId(id));
51 pipe_control::PeerAssociatedEndpointClosedEventPtr event( 51 pipe_control::PeerAssociatedEndpointClosedEventPtr event(
(...skipping 15 matching lines...) Expand all
67 67
68 pipe_control::RunOrClosePipeInputPtr input( 68 pipe_control::RunOrClosePipeInputPtr input(
69 pipe_control::RunOrClosePipeInput::New()); 69 pipe_control::RunOrClosePipeInput::New());
70 input->set_associated_endpoint_closed_before_sent_event(std::move(event)); 70 input->set_associated_endpoint_closed_before_sent_event(std::move(event));
71 71
72 SendRunOrClosePipeMessage(receiver_, std::move(input), &context_); 72 SendRunOrClosePipeMessage(receiver_, std::move(input), &context_);
73 } 73 }
74 74
75 } // namespace internal 75 } // namespace internal
76 } // namespace mojo 76 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698