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

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

Issue 1518293002: [mojo] Add Mojo bindings support for IPC::ParamTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pickle4
Patch Set: Created 5 years 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_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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 BoundsChecker* bounds_checker) { 109 BoundsChecker* bounds_checker) {
110 if (!ValidateEncodedPointer(&input.offset)) { 110 if (!ValidateEncodedPointer(&input.offset)) {
111 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER); 111 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER);
112 return false; 112 return false;
113 } 113 }
114 114
115 return T::Validate(DecodePointerRaw(&input.offset), bounds_checker); 115 return T::Validate(DecodePointerRaw(&input.offset), bounds_checker);
116 } 116 }
117 117
118 template <typename T> 118 template <typename T>
119 bool ValidateNative(const NativePointer<T>& input,
120 BoundsChecker* bounds_checker) {
121 if (!ValidateEncodedPointer(&input.offset)) {
122 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER);
123 return false;
124 }
125
126 // Native types perform validation during deserialization.
127 DecodePointerRaw(&input.offset);
128 return true;
129 }
130
131 template <typename T>
119 bool ValidateInlinedUnion(const T& input, BoundsChecker* bounds_checker) { 132 bool ValidateInlinedUnion(const T& input, BoundsChecker* bounds_checker) {
120 return T::Validate(&input, bounds_checker, true); 133 return T::Validate(&input, bounds_checker, true);
121 } 134 }
122 135
123 bool ValidateHandle(const Handle& input, BoundsChecker* bounds_checker); 136 bool ValidateHandle(const Handle& input, BoundsChecker* bounds_checker);
124 137
125 bool ValidateAssociatedInterfaceId(InterfaceId input); 138 bool ValidateAssociatedInterfaceId(InterfaceId input);
126 139
127 } // namespace internal 140 } // namespace internal
128 } // namespace mojo 141 } // namespace mojo
129 142
130 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ 143 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/string_serialization.cc ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698