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 <assert.h> | |
8 | |
9 #include "mojo/public/cpp/environment/logging.h" | 7 #include "mojo/public/cpp/environment/logging.h" |
10 | 8 |
11 namespace mojo { | 9 namespace mojo { |
12 namespace internal { | 10 namespace internal { |
13 namespace { | 11 namespace { |
14 | 12 |
15 ValidationErrorObserverForTesting* g_validation_error_observer = NULL; | 13 ValidationErrorObserverForTesting* g_validation_error_observer = NULL; |
16 | 14 |
17 } // namespace | 15 } // namespace |
18 | 16 |
(...skipping 24 matching lines...) Expand all Loading... |
43 | 41 |
44 void ReportValidationError(ValidationError error) { | 42 void ReportValidationError(ValidationError error) { |
45 if (g_validation_error_observer) | 43 if (g_validation_error_observer) |
46 g_validation_error_observer->set_last_error(error); | 44 g_validation_error_observer->set_last_error(error); |
47 else | 45 else |
48 MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); | 46 MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); |
49 } | 47 } |
50 | 48 |
51 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() | 49 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() |
52 : last_error_(VALIDATION_ERROR_NONE) { | 50 : last_error_(VALIDATION_ERROR_NONE) { |
53 assert(!g_validation_error_observer); | 51 MOJO_DCHECK(!g_validation_error_observer); |
54 g_validation_error_observer = this; | 52 g_validation_error_observer = this; |
55 } | 53 } |
56 | 54 |
57 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { | 55 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { |
58 assert(g_validation_error_observer == this); | 56 MOJO_DCHECK(g_validation_error_observer == this); |
59 g_validation_error_observer = NULL; | 57 g_validation_error_observer = NULL; |
60 } | 58 } |
61 | 59 |
62 } // namespace internal | 60 } // namespace internal |
63 } // namespace mojo | 61 } // namespace mojo |
OLD | NEW |