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

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

Issue 494943004: Mojo C++ bindings: better log messages for some validation errors at the receiver side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
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 #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 {
(...skipping 26 matching lines...) Expand all
37 return "VALIDATION_ERROR_UNEXPECTED_NULL_POINTER"; 37 return "VALIDATION_ERROR_UNEXPECTED_NULL_POINTER";
38 case VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION: 38 case VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION:
39 return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION"; 39 return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION";
40 case VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID: 40 case VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID:
41 return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID"; 41 return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID";
42 } 42 }
43 43
44 return "Unknown error"; 44 return "Unknown error";
45 } 45 }
46 46
47 void ReportValidationError(ValidationError error) { 47 void ReportValidationError(ValidationError error, const char* description) {
48 if (g_validation_error_observer) 48 if (g_validation_error_observer) {
49 g_validation_error_observer->set_last_error(error); 49 g_validation_error_observer->set_last_error(error);
50 else 50 } else if (description) {
51 MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error)
52 << " (" << description << ")";
53 } else {
51 MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); 54 MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error);
55 }
52 } 56 }
53 57
54 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() 58 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting()
55 : last_error_(VALIDATION_ERROR_NONE) { 59 : last_error_(VALIDATION_ERROR_NONE) {
56 MOJO_DCHECK(!g_validation_error_observer); 60 MOJO_DCHECK(!g_validation_error_observer);
57 g_validation_error_observer = this; 61 g_validation_error_observer = this;
58 } 62 }
59 63
60 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { 64 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() {
61 MOJO_DCHECK(g_validation_error_observer == this); 65 MOJO_DCHECK(g_validation_error_observer == this);
(...skipping 16 matching lines...) Expand all
78 } 82 }
79 83
80 SerializationWarningObserverForTesting:: 84 SerializationWarningObserverForTesting::
81 ~SerializationWarningObserverForTesting() { 85 ~SerializationWarningObserverForTesting() {
82 MOJO_DCHECK(g_serialization_warning_observer == this); 86 MOJO_DCHECK(g_serialization_warning_observer == this);
83 g_serialization_warning_observer = NULL; 87 g_serialization_warning_observer = NULL;
84 } 88 }
85 89
86 } // namespace internal 90 } // namespace internal
87 } // namespace mojo 91 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698