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

Side by Side Diff: mojo/public/cpp/bindings/lib/pipe_control_message_handler.h

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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_PIPE_CONTROL_MESSAGE_HANDLER_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_PIPE_CONTROL_MESSAGE_HANDLER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_PIPE_CONTROL_MESSAGE_HANDLER_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_PIPE_CONTROL_MESSAGE_HANDLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "mojo/public/cpp/bindings/lib/interface_id.h" 9 #include "mojo/public/cpp/bindings/lib/interface_id.h"
10 #include "mojo/public/cpp/bindings/lib/serialization_context.h" 10 #include "mojo/public/cpp/bindings/lib/serialization_context.h"
11 #include "mojo/public/cpp/bindings/message.h" 11 #include "mojo/public/cpp/bindings/message.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace internal { 14 namespace internal {
15 15
16 class PipeControlMessageHandlerDelegate; 16 class PipeControlMessageHandlerDelegate;
17 17
18 // Handler for messages defined in pipe_control_messages.mojom. 18 // Handler for messages defined in pipe_control_messages.mojom.
19 class PipeControlMessageHandler : public MessageReceiver { 19 class PipeControlMessageHandler : public MessageReceiver {
20 public: 20 public:
21 explicit PipeControlMessageHandler( 21 explicit PipeControlMessageHandler(
22 PipeControlMessageHandlerDelegate* delegate); 22 PipeControlMessageHandlerDelegate* delegate);
23 ~PipeControlMessageHandler() override; 23 ~PipeControlMessageHandler() override;
24 24
25 // Sets the description for this handler. Used only when reporting validation
26 // errors.
27 void SetDescription(const std::string& description);
28
25 // NOTE: |message| must have passed message header validation. 29 // NOTE: |message| must have passed message header validation.
26 static bool IsPipeControlMessage(const Message* message); 30 static bool IsPipeControlMessage(const Message* message);
27 31
28 // MessageReceiver implementation: 32 // MessageReceiver implementation:
29 33
30 // NOTE: |message| must: 34 // NOTE: |message| must:
31 // - have passed message header validation; and 35 // - have passed message header validation; and
32 // - be a pipe control message (i.e., IsPipeControlMessage() returns true). 36 // - be a pipe control message (i.e., IsPipeControlMessage() returns true).
33 // If the method returns false, the message pipe should be closed. 37 // If the method returns false, the message pipe should be closed.
34 bool Accept(Message* message) override; 38 bool Accept(Message* message) override;
35 39
36 private: 40 private:
37 // |message| must have passed message header validation. 41 // |message| must have passed message header validation.
38 bool Validate(const Message* message); 42 bool Validate(Message* message);
39 bool RunOrClosePipe(Message* message); 43 bool RunOrClosePipe(Message* message);
40 44
45 std::string description_;
41 PipeControlMessageHandlerDelegate* const delegate_; 46 PipeControlMessageHandlerDelegate* const delegate_;
42 SerializationContext context_; 47 SerializationContext context_;
43 48
44 DISALLOW_COPY_AND_ASSIGN(PipeControlMessageHandler); 49 DISALLOW_COPY_AND_ASSIGN(PipeControlMessageHandler);
45 }; 50 };
46 51
47 } // namespace internal 52 } // namespace internal
48 } // namespace mojo 53 } // namespace mojo
49 54
50 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_PIPE_CONTROL_MESSAGE_HANDLER_H_ 55 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_PIPE_CONTROL_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/native_struct_data.cc ('k') | mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698