| 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 "mojo/public/cpp/environment/logging.h" | 7 #include "mojo/public/cpp/environment/logging.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 namespace internal { | 10 namespace internal { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 ValidationErrorObserverForTesting* g_validation_error_observer = NULL; | 13 ValidationErrorObserverForTesting* g_validation_error_observer = nullptr; |
| 14 SerializationWarningObserverForTesting* g_serialization_warning_observer = NULL; | 14 SerializationWarningObserverForTesting* g_serialization_warning_observer = |
| 15 nullptr; |
| 15 | 16 |
| 16 } // namespace | 17 } // namespace |
| 17 | 18 |
| 18 const char* ValidationErrorToString(ValidationError error) { | 19 const char* ValidationErrorToString(ValidationError error) { |
| 19 switch (error) { | 20 switch (error) { |
| 20 case VALIDATION_ERROR_NONE: | 21 case VALIDATION_ERROR_NONE: |
| 21 return "VALIDATION_ERROR_NONE"; | 22 return "VALIDATION_ERROR_NONE"; |
| 22 case VALIDATION_ERROR_MISALIGNED_OBJECT: | 23 case VALIDATION_ERROR_MISALIGNED_OBJECT: |
| 23 return "VALIDATION_ERROR_MISALIGNED_OBJECT"; | 24 return "VALIDATION_ERROR_MISALIGNED_OBJECT"; |
| 24 case VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE: | 25 case VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 57 } |
| 57 | 58 |
| 58 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() | 59 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() |
| 59 : last_error_(VALIDATION_ERROR_NONE) { | 60 : last_error_(VALIDATION_ERROR_NONE) { |
| 60 MOJO_DCHECK(!g_validation_error_observer); | 61 MOJO_DCHECK(!g_validation_error_observer); |
| 61 g_validation_error_observer = this; | 62 g_validation_error_observer = this; |
| 62 } | 63 } |
| 63 | 64 |
| 64 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { | 65 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { |
| 65 MOJO_DCHECK(g_validation_error_observer == this); | 66 MOJO_DCHECK(g_validation_error_observer == this); |
| 66 g_validation_error_observer = NULL; | 67 g_validation_error_observer = nullptr; |
| 67 } | 68 } |
| 68 | 69 |
| 69 bool ReportSerializationWarning(ValidationError error) { | 70 bool ReportSerializationWarning(ValidationError error) { |
| 70 if (g_serialization_warning_observer) { | 71 if (g_serialization_warning_observer) { |
| 71 g_serialization_warning_observer->set_last_warning(error); | 72 g_serialization_warning_observer->set_last_warning(error); |
| 72 return true; | 73 return true; |
| 73 } | 74 } |
| 74 | 75 |
| 75 return false; | 76 return false; |
| 76 } | 77 } |
| 77 | 78 |
| 78 SerializationWarningObserverForTesting::SerializationWarningObserverForTesting() | 79 SerializationWarningObserverForTesting::SerializationWarningObserverForTesting() |
| 79 : last_warning_(VALIDATION_ERROR_NONE) { | 80 : last_warning_(VALIDATION_ERROR_NONE) { |
| 80 MOJO_DCHECK(!g_serialization_warning_observer); | 81 MOJO_DCHECK(!g_serialization_warning_observer); |
| 81 g_serialization_warning_observer = this; | 82 g_serialization_warning_observer = this; |
| 82 } | 83 } |
| 83 | 84 |
| 84 SerializationWarningObserverForTesting:: | 85 SerializationWarningObserverForTesting:: |
| 85 ~SerializationWarningObserverForTesting() { | 86 ~SerializationWarningObserverForTesting() { |
| 86 MOJO_DCHECK(g_serialization_warning_observer == this); | 87 MOJO_DCHECK(g_serialization_warning_observer == this); |
| 87 g_serialization_warning_observer = NULL; | 88 g_serialization_warning_observer = nullptr; |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace internal | 91 } // namespace internal |
| 91 } // namespace mojo | 92 } // namespace mojo |
| OLD | NEW |