| OLD | NEW |
| 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_VALIDATION_UTIL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 bool ValidateMessageIsResponse(const Message* message, | 71 bool ValidateMessageIsResponse(const Message* message, |
| 72 ValidationContext* validation_context); | 72 ValidationContext* validation_context); |
| 73 | 73 |
| 74 // Validates that the message payload is a valid struct of type ParamsType. | 74 // Validates that the message payload is a valid struct of type ParamsType. |
| 75 template <typename ParamsType> | 75 template <typename ParamsType> |
| 76 bool ValidateMessagePayload(const Message* message, | 76 bool ValidateMessagePayload(const Message* message, |
| 77 ValidationContext* validation_context) { | 77 ValidationContext* validation_context) { |
| 78 return ParamsType::Validate(message->payload(), validation_context); | 78 return ParamsType::Validate(message->payload(), validation_context); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // The following methods validate control messages defined in | |
| 82 // interface_control_messages.mojom. | |
| 83 bool ValidateControlRequest(const Message* message, | |
| 84 ValidationContext* validation_context); | |
| 85 bool ValidateControlResponse(const Message* message, | |
| 86 ValidationContext* validation_context); | |
| 87 | |
| 88 // The following Validate.*NonNullable() functions validate that the given | 81 // The following Validate.*NonNullable() functions validate that the given |
| 89 // |input| is not null/invalid. | 82 // |input| is not null/invalid. |
| 90 template <typename T> | 83 template <typename T> |
| 91 bool ValidatePointerNonNullable(const T& input, | 84 bool ValidatePointerNonNullable(const T& input, |
| 92 const char* error_message, | 85 const char* error_message, |
| 93 ValidationContext* validation_context) { | 86 ValidationContext* validation_context) { |
| 94 if (input.offset) | 87 if (input.offset) |
| 95 return true; | 88 return true; |
| 96 | 89 |
| 97 ReportValidationError(validation_context, | 90 ReportValidationError(validation_context, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 ValidationContext* validation_context); | 162 ValidationContext* validation_context); |
| 170 bool ValidateHandleOrInterface(const Interface_Data& input, | 163 bool ValidateHandleOrInterface(const Interface_Data& input, |
| 171 ValidationContext* validation_context); | 164 ValidationContext* validation_context); |
| 172 bool ValidateHandleOrInterface(const Handle_Data& input, | 165 bool ValidateHandleOrInterface(const Handle_Data& input, |
| 173 ValidationContext* validation_context); | 166 ValidationContext* validation_context); |
| 174 | 167 |
| 175 } // namespace internal | 168 } // namespace internal |
| 176 } // namespace mojo | 169 } // namespace mojo |
| 177 | 170 |
| 178 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ | 171 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ |
| OLD | NEW |