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

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

Issue 1800753005: C++ bindings: A struct's Deserialize() now does validation before deserializing. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fix char* - >char bug in unittest. FixedBuffer can accept sizes that aren't 8 byte multiples. Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ERRORS_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_
7 7
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 MESSAGE_HEADER_UNKNOWN_METHOD, 56 MESSAGE_HEADER_UNKNOWN_METHOD,
57 // Two parallel arrays which are supposed to represent a map have different 57 // Two parallel arrays which are supposed to represent a map have different
58 // lengths. 58 // lengths.
59 DIFFERENT_SIZED_ARRAYS_IN_MAP, 59 DIFFERENT_SIZED_ARRAYS_IN_MAP,
60 // A non-nullable union is set to null. (Has size 0) 60 // A non-nullable union is set to null. (Has size 0)
61 UNEXPECTED_NULL_UNION, 61 UNEXPECTED_NULL_UNION,
62 }; 62 };
63 63
64 const char* ValidationErrorToString(ValidationError error); 64 const char* ValidationErrorToString(ValidationError error);
65 65
66 // TODO(vardhan): This can die, along with |ValidationErrorObserverForTesting|.
66 void ReportValidationError(ValidationError error, 67 void ReportValidationError(ValidationError error,
67 std::string* description = nullptr); 68 std::string* description = nullptr);
68 69
69 // Only used by validation tests and when there is only one thread doing message 70 // Only used by validation tests and when there is only one thread doing message
70 // validation. 71 // validation.
71 class ValidationErrorObserverForTesting { 72 class ValidationErrorObserverForTesting {
72 public: 73 public:
73 ValidationErrorObserverForTesting(); 74 ValidationErrorObserverForTesting();
74 ~ValidationErrorObserverForTesting(); 75 ~ValidationErrorObserverForTesting();
75 76
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 #define MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err_msg) \ 119 #define MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err_msg) \
119 true ? (void)0 \ 120 true ? (void)0 \
120 : ::mojo::internal::VoidifyOstream() & \ 121 : ::mojo::internal::VoidifyOstream() & \
121 ::mojo::internal::ValidationErrorStringStream(err_msg).stream() 122 ::mojo::internal::ValidationErrorStringStream(err_msg).stream()
122 #else 123 #else
123 #define MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err_msg) \ 124 #define MOJO_INTERNAL_DEBUG_SET_ERROR_MSG(err_msg) \
124 ::mojo::internal::ValidationErrorStringStream(err_msg).stream() 125 ::mojo::internal::ValidationErrorStringStream(err_msg).stream()
125 #endif // NDEBUG 126 #endif // NDEBUG
126 127
127 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ 128 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/fixed_buffer.cc ('k') | mojo/public/cpp/bindings/tests/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698