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

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

Issue 2448203002: Mojo: Suppress validation error logging in some tests (Closed)
Patch Set: . Created 4 years, 1 month 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
« no previous file with comments | « mojo/edk/js/tests/js_to_cpp_tests.cc ('k') | mojo/public/cpp/bindings/lib/validation_errors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MOJO_CPP_BINDINGS_EXPORT void ReportValidationError( 82 MOJO_CPP_BINDINGS_EXPORT void ReportValidationError(
83 ValidationContext* context, 83 ValidationContext* context,
84 ValidationError error, 84 ValidationError error,
85 const char* description = nullptr); 85 const char* description = nullptr);
86 86
87 MOJO_CPP_BINDINGS_EXPORT void ReportValidationErrorForMessage( 87 MOJO_CPP_BINDINGS_EXPORT void ReportValidationErrorForMessage(
88 mojo::Message* message, 88 mojo::Message* message,
89 ValidationError error, 89 ValidationError error,
90 const char* description = nullptr); 90 const char* description = nullptr);
91 91
92 // This class may be used by tests to suppress validation error logging. This is
93 // not thread-safe and must only be instantiated on the main thread with no
94 // other threads using Mojo bindings at the time of construction or destruction.
95 class MOJO_CPP_BINDINGS_EXPORT ScopedSuppressValidationErrorLoggingForTests {
96 public:
97 ScopedSuppressValidationErrorLoggingForTests();
98 ~ScopedSuppressValidationErrorLoggingForTests();
99
100 private:
101 const bool was_suppressed_;
102
103 DISALLOW_COPY_AND_ASSIGN(ScopedSuppressValidationErrorLoggingForTests);
104 };
105
92 // Only used by validation tests and when there is only one thread doing message 106 // Only used by validation tests and when there is only one thread doing message
93 // validation. 107 // validation.
94 class MOJO_CPP_BINDINGS_EXPORT ValidationErrorObserverForTesting { 108 class MOJO_CPP_BINDINGS_EXPORT ValidationErrorObserverForTesting {
95 public: 109 public:
96 explicit ValidationErrorObserverForTesting(const base::Closure& callback); 110 explicit ValidationErrorObserverForTesting(const base::Closure& callback);
97 ~ValidationErrorObserverForTesting(); 111 ~ValidationErrorObserverForTesting();
98 112
99 ValidationError last_error() const { return last_error_; } 113 ValidationError last_error() const { return last_error_; }
100 void set_last_error(ValidationError error) { 114 void set_last_error(ValidationError error) {
101 last_error_ = error; 115 last_error_ = error;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // 158 //
145 // In non-debug build, does nothing (not even compiling |condition|). 159 // In non-debug build, does nothing (not even compiling |condition|).
146 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(condition, error, \ 160 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(condition, error, \
147 description) \ 161 description) \
148 DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \ 162 DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \
149 << "The outgoing message will trigger " \ 163 << "The outgoing message will trigger " \
150 << ValidationErrorToString(error) << " at the receiving side (" \ 164 << ValidationErrorToString(error) << " at the receiving side (" \
151 << description << ")."; 165 << description << ").";
152 166
153 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ 167 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_
OLDNEW
« no previous file with comments | « mojo/edk/js/tests/js_to_cpp_tests.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