OLD | NEW |
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 "mojo/public/cpp/system/macros.h" | 8 #include "mojo/public/cpp/system/macros.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 ValidationError last_warning() const { return last_warning_; } | 82 ValidationError last_warning() const { return last_warning_; } |
83 void set_last_warning(ValidationError error) { last_warning_ = error; } | 83 void set_last_warning(ValidationError error) { last_warning_ = error; } |
84 | 84 |
85 private: | 85 private: |
86 ValidationError last_warning_; | 86 ValidationError last_warning_; |
87 | 87 |
88 MOJO_DISALLOW_COPY_AND_ASSIGN(SerializationWarningObserverForTesting); | 88 MOJO_DISALLOW_COPY_AND_ASSIGN(SerializationWarningObserverForTesting); |
89 }; | 89 }; |
90 | 90 |
91 // Currently it only returns true during validation and serialization tests. | |
92 // | |
93 // TODO(yzshen): Remove this function and enable non-nullable validation by | |
94 // default. | |
95 bool IsNonNullableValidationEnabled(); | |
96 | |
97 } // namespace internal | 91 } // namespace internal |
98 } // namespace mojo | 92 } // namespace mojo |
99 | 93 |
100 // In debug build, logs a serialization warning if |condition| evaluates to | 94 // In debug build, logs a serialization warning if |condition| evaluates to |
101 // true: | 95 // true: |
102 // - if there is a SerializationWarningObserverForTesting object alive, | 96 // - if there is a SerializationWarningObserverForTesting object alive, |
103 // records |error| in it; | 97 // records |error| in it; |
104 // - otherwise, logs a fatal-level message. | 98 // - otherwise, logs a fatal-level message. |
105 // |error| is the validation error that will be triggered by the receiver | 99 // |error| is the validation error that will be triggered by the receiver |
106 // of the serialzation result. | 100 // of the serialzation result. |
107 // | 101 // |
108 // In non-debug build, does nothing (not even compiling |condition|). | 102 // In non-debug build, does nothing (not even compiling |condition|). |
109 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(condition, error) \ | 103 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(condition, error) \ |
110 MOJO_DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \ | 104 MOJO_DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \ |
111 << "The outgoing message will trigger " \ | 105 << "The outgoing message will trigger " \ |
112 << ValidationErrorToString(error) << " at the receiving side."; | 106 << ValidationErrorToString(error) << " at the receiving side."; |
113 | 107 |
114 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ | 108 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ |
OLD | NEW |