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

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

Powered by Google App Engine
This is Rietveld 408576698