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

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

Issue 1552983003: Fix a bunch of mojo_public_*_unittests with the new EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 11 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 "mojo/public/cpp/bindings/callback.h"
8 #include "mojo/public/cpp/system/macros.h" 9 #include "mojo/public/cpp/system/macros.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 namespace internal { 12 namespace internal {
12 13
13 enum ValidationError { 14 enum ValidationError {
14 // There is no validation error. 15 // There is no validation error.
15 VALIDATION_ERROR_NONE, 16 VALIDATION_ERROR_NONE,
16 // An object (struct or array) is not 8-byte aligned. 17 // An object (struct or array) is not 8-byte aligned.
17 VALIDATION_ERROR_MISALIGNED_OBJECT, 18 VALIDATION_ERROR_MISALIGNED_OBJECT,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 const char* ValidationErrorToString(ValidationError error); 65 const char* ValidationErrorToString(ValidationError error);
65 66
66 void ReportValidationError(ValidationError error, 67 void ReportValidationError(ValidationError error,
67 const char* description = nullptr); 68 const char* 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 explicit ValidationErrorObserverForTesting(const Callback<void()>& callback);
74 ~ValidationErrorObserverForTesting(); 75 ~ValidationErrorObserverForTesting();
75 76
76 ValidationError last_error() const { return last_error_; } 77 ValidationError last_error() const { return last_error_; }
77 void set_last_error(ValidationError error) { last_error_ = error; } 78 void set_last_error(ValidationError error) {
79 last_error_ = error;
80 callback_.Run();
81 }
78 82
79 private: 83 private:
80 ValidationError last_error_; 84 ValidationError last_error_;
85 Callback<void()> callback_;
81 86
82 MOJO_DISALLOW_COPY_AND_ASSIGN(ValidationErrorObserverForTesting); 87 MOJO_DISALLOW_COPY_AND_ASSIGN(ValidationErrorObserverForTesting);
83 }; 88 };
84 89
85 // Used only by MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING. Don't use it directly. 90 // Used only by MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING. Don't use it directly.
86 // 91 //
87 // The function returns true if the error is recorded (by a 92 // The function returns true if the error is recorded (by a
88 // SerializationWarningObserverForTesting object), false otherwise. 93 // SerializationWarningObserverForTesting object), false otherwise.
89 bool ReportSerializationWarning(ValidationError error); 94 bool ReportSerializationWarning(ValidationError error);
90 95
(...skipping 26 matching lines...) Expand all
117 // 122 //
118 // In non-debug build, does nothing (not even compiling |condition|). 123 // In non-debug build, does nothing (not even compiling |condition|).
119 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( \ 124 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( \
120 condition, error, description) \ 125 condition, error, description) \
121 MOJO_DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \ 126 MOJO_DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \
122 << "The outgoing message will trigger " \ 127 << "The outgoing message will trigger " \
123 << ValidationErrorToString(error) << " at the receiving side (" \ 128 << ValidationErrorToString(error) << " at the receiving side (" \
124 << description << ")."; 129 << description << ").";
125 130
126 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ 131 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_
OLDNEW
« no previous file with comments | « mojo/public/c/system/tests/core_unittest.cc ('k') | mojo/public/cpp/bindings/lib/validation_errors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698