OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ARRAY_INTERNAL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
7 | 7 |
8 #include <new> | 8 #include <new> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 template <bool element_is_nullable, typename ElementValidateParams> | 200 template <bool element_is_nullable, typename ElementValidateParams> |
201 static bool ValidateElements(const ArrayHeader* header, | 201 static bool ValidateElements(const ArrayHeader* header, |
202 const ElementType* elements, | 202 const ElementType* elements, |
203 BoundsChecker* bounds_checker) { | 203 BoundsChecker* bounds_checker) { |
204 MOJO_COMPILE_ASSERT( | 204 MOJO_COMPILE_ASSERT( |
205 (IsSame<ElementValidateParams, NoValidateParams>::value), | 205 (IsSame<ElementValidateParams, NoValidateParams>::value), |
206 Handle_type_should_not_have_array_validate_params); | 206 Handle_type_should_not_have_array_validate_params); |
207 | 207 |
208 for (uint32_t i = 0; i < header->num_elements; ++i) { | 208 for (uint32_t i = 0; i < header->num_elements; ++i) { |
209 if (IsNonNullableValidationEnabled() && !element_is_nullable && | 209 if (!element_is_nullable && |
210 elements[i].value() == kEncodedInvalidHandleValue) { | 210 elements[i].value() == kEncodedInvalidHandleValue) { |
211 ReportValidationError(VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE); | 211 ReportValidationError(VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE); |
212 return false; | 212 return false; |
213 } | 213 } |
214 if (!bounds_checker->ClaimHandle(elements[i])) { | 214 if (!bounds_checker->ClaimHandle(elements[i])) { |
215 ReportValidationError(VALIDATION_ERROR_ILLEGAL_HANDLE); | 215 ReportValidationError(VALIDATION_ERROR_ILLEGAL_HANDLE); |
216 return false; | 216 return false; |
217 } | 217 } |
218 } | 218 } |
219 return true; | 219 return true; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 std::vector<Handle>* handles) { | 264 std::vector<Handle>* handles) { |
265 for (uint32_t i = 0; i < header->num_elements; ++i) | 265 for (uint32_t i = 0; i < header->num_elements; ++i) |
266 Decode(&elements[i], handles); | 266 Decode(&elements[i], handles); |
267 } | 267 } |
268 | 268 |
269 template <bool element_is_nullable, typename ElementValidateParams> | 269 template <bool element_is_nullable, typename ElementValidateParams> |
270 static bool ValidateElements(const ArrayHeader* header, | 270 static bool ValidateElements(const ArrayHeader* header, |
271 const ElementType* elements, | 271 const ElementType* elements, |
272 BoundsChecker* bounds_checker) { | 272 BoundsChecker* bounds_checker) { |
273 for (uint32_t i = 0; i < header->num_elements; ++i) { | 273 for (uint32_t i = 0; i < header->num_elements; ++i) { |
274 if (IsNonNullableValidationEnabled() && !element_is_nullable && | 274 if (!element_is_nullable && !elements[i].offset) { |
275 !elements[i].offset) { | |
276 ReportValidationError(VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); | 275 ReportValidationError(VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); |
277 return false; | 276 return false; |
278 } | 277 } |
279 if (!ValidateEncodedPointer(&elements[i].offset)) { | 278 if (!ValidateEncodedPointer(&elements[i].offset)) { |
280 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER); | 279 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER); |
281 return false; | 280 return false; |
282 } | 281 } |
283 if (!ValidateCaller<P, ElementValidateParams>::Run( | 282 if (!ValidateCaller<P, ElementValidateParams>::Run( |
284 DecodePointerRaw(&elements[i].offset), bounds_checker)) { | 283 DecodePointerRaw(&elements[i].offset), bounds_checker)) { |
285 return false; | 284 return false; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 }; | 482 }; |
484 | 483 |
485 template <> struct WrapperTraits<String, false> { | 484 template <> struct WrapperTraits<String, false> { |
486 typedef String_Data* DataType; | 485 typedef String_Data* DataType; |
487 }; | 486 }; |
488 | 487 |
489 } // namespace internal | 488 } // namespace internal |
490 } // namespace mojo | 489 } // namespace mojo |
491 | 490 |
492 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 491 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
OLD | NEW |