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 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 5 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "mojo/public/cpp/bindings/message.h" | 8 #include "mojo/public/cpp/bindings/message.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); | 81 LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); |
82 if (context->message()) { | 82 if (context->message()) { |
83 context->message()->NotifyBadMessage( | 83 context->message()->NotifyBadMessage( |
84 base::StringPrintf("Validation failed for %s [%s]", | 84 base::StringPrintf("Validation failed for %s [%s]", |
85 context->description().data(), | 85 context->description().data(), |
86 ValidationErrorToString(error))); | 86 ValidationErrorToString(error))); |
87 } | 87 } |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
| 91 void ReportValidationErrorForMessage( |
| 92 mojo::Message* message, |
| 93 ValidationError error, |
| 94 const char* description) { |
| 95 ValidationContext validation_context( |
| 96 message->data(), message->data_num_bytes(), |
| 97 message->handles()->size(), message, |
| 98 description); |
| 99 ReportValidationError(&validation_context, error); |
| 100 } |
| 101 |
91 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting( | 102 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting( |
92 const base::Closure& callback) | 103 const base::Closure& callback) |
93 : last_error_(VALIDATION_ERROR_NONE), callback_(callback) { | 104 : last_error_(VALIDATION_ERROR_NONE), callback_(callback) { |
94 DCHECK(!g_validation_error_observer); | 105 DCHECK(!g_validation_error_observer); |
95 g_validation_error_observer = this; | 106 g_validation_error_observer = this; |
96 } | 107 } |
97 | 108 |
98 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { | 109 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { |
99 DCHECK(g_validation_error_observer == this); | 110 DCHECK(g_validation_error_observer == this); |
100 g_validation_error_observer = nullptr; | 111 g_validation_error_observer = nullptr; |
(...skipping 15 matching lines...) Expand all Loading... |
116 } | 127 } |
117 | 128 |
118 SerializationWarningObserverForTesting:: | 129 SerializationWarningObserverForTesting:: |
119 ~SerializationWarningObserverForTesting() { | 130 ~SerializationWarningObserverForTesting() { |
120 DCHECK(g_serialization_warning_observer == this); | 131 DCHECK(g_serialization_warning_observer == this); |
121 g_serialization_warning_observer = nullptr; | 132 g_serialization_warning_observer = nullptr; |
122 } | 133 } |
123 | 134 |
124 } // namespace internal | 135 } // namespace internal |
125 } // namespace mojo | 136 } // namespace mojo |
OLD | NEW |