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

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

Issue 2080083002: Revert of Deletes mojo::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 "base/callback.h"
9 #include "base/logging.h" 8 #include "base/logging.h"
10 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "mojo/public/cpp/bindings/callback.h"
11 #include "mojo/public/cpp/bindings/lib/validation_context.h" 11 #include "mojo/public/cpp/bindings/lib/validation_context.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace internal { 14 namespace internal {
15 15
16 enum ValidationError { 16 enum ValidationError {
17 // There is no validation error. 17 // There is no validation error.
18 VALIDATION_ERROR_NONE, 18 VALIDATION_ERROR_NONE,
19 // An object (struct or array) is not 8-byte aligned. 19 // An object (struct or array) is not 8-byte aligned.
20 VALIDATION_ERROR_MISALIGNED_OBJECT, 20 VALIDATION_ERROR_MISALIGNED_OBJECT,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const char* ValidationErrorToString(ValidationError error); 72 const char* ValidationErrorToString(ValidationError error);
73 73
74 void ReportValidationError(ValidationContext* context, 74 void ReportValidationError(ValidationContext* context,
75 ValidationError error, 75 ValidationError error,
76 const char* description = nullptr); 76 const char* description = nullptr);
77 77
78 // Only used by validation tests and when there is only one thread doing message 78 // Only used by validation tests and when there is only one thread doing message
79 // validation. 79 // validation.
80 class ValidationErrorObserverForTesting { 80 class ValidationErrorObserverForTesting {
81 public: 81 public:
82 explicit ValidationErrorObserverForTesting(const base::Closure& callback); 82 explicit ValidationErrorObserverForTesting(const Callback<void()>& callback);
83 ~ValidationErrorObserverForTesting(); 83 ~ValidationErrorObserverForTesting();
84 84
85 ValidationError last_error() const { return last_error_; } 85 ValidationError last_error() const { return last_error_; }
86 void set_last_error(ValidationError error) { 86 void set_last_error(ValidationError error) {
87 last_error_ = error; 87 last_error_ = error;
88 callback_.Run(); 88 callback_.Run();
89 } 89 }
90 90
91 private: 91 private:
92 ValidationError last_error_; 92 ValidationError last_error_;
93 base::Closure callback_; 93 Callback<void()> callback_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(ValidationErrorObserverForTesting); 95 DISALLOW_COPY_AND_ASSIGN(ValidationErrorObserverForTesting);
96 }; 96 };
97 97
98 // Used only by MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING. Don't use it directly. 98 // Used only by MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING. Don't use it directly.
99 // 99 //
100 // The function returns true if the error is recorded (by a 100 // The function returns true if the error is recorded (by a
101 // SerializationWarningObserverForTesting object), false otherwise. 101 // SerializationWarningObserverForTesting object), false otherwise.
102 bool ReportSerializationWarning(ValidationError error); 102 bool ReportSerializationWarning(ValidationError error);
103 103
(...skipping 26 matching lines...) Expand all
130 // 130 //
131 // In non-debug build, does nothing (not even compiling |condition|). 131 // In non-debug build, does nothing (not even compiling |condition|).
132 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(condition, error, \ 132 #define MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING(condition, error, \
133 description) \ 133 description) \
134 DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \ 134 DLOG_IF(FATAL, (condition) && !ReportSerializationWarning(error)) \
135 << "The outgoing message will trigger " \ 135 << "The outgoing message will trigger " \
136 << ValidationErrorToString(error) << " at the receiving side (" \ 136 << ValidationErrorToString(error) << " at the receiving side (" \
137 << description << ")."; 137 << description << ").";
138 138
139 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_ 139 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_ERRORS_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.h ('k') | mojo/public/cpp/bindings/lib/validation_errors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698