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

Side by Side Diff: mojo/public/cpp/bindings/message_validator.h

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « mojo/public/cpp/bindings/message.h ('k') | mojo/public/cpp/bindings/no_interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_VALIDATOR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_VALIDATOR_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
12 #include "mojo/public/cpp/bindings/message.h"
13 #include "mojo/public/cpp/system/macros.h"
14
15 namespace mojo {
16 namespace internal {
17
18 // This class is the base class for message validators. Subclasses should
19 // implement the pure virtual method Validate() to validate messages.
20 class MessageValidator {
21 public:
22 virtual ~MessageValidator() {}
23 // Validates the message and returns ValidationError::NONE if valid.
24 // Otherwise returns a different value, and sets the |err| string if it is not
25 // null.
26 virtual ValidationError Validate(const Message* message,
27 std::string* err) = 0;
28 };
29
30 // A message validator that does nothing, and always returns a non-error.
31 class PassThroughValidator final : public MessageValidator {
32 public:
33 ValidationError Validate(const Message* message, std::string* err) override;
34 };
35
36 using MessageValidatorList = std::vector<std::unique_ptr<MessageValidator>>;
37
38 // Iterates through |validators| and tries to validate the given |message| until
39 // a validator fails. If a validator fails, a |ValidationError| is returned and
40 // the supplied |err| is set if it is not null. |ValidationError::NONE| is
41 // returned if the supplied |message| passes all the |validators|.
42 ValidationError RunValidatorsOnMessage(const MessageValidatorList& validators,
43 const Message* message,
44 std::string* err);
45
46 } // namespace internal
47 } // namespace mojo
48
49 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_VALIDATOR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/message.h ('k') | mojo/public/cpp/bindings/no_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698