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

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

Issue 344983002: Replace fprintf with mojo logging macro. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/validation_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <assert.h> 7 #include <assert.h>
8 #include <stdio.h> 8
9 #include "mojo/public/cpp/environment/logging.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 namespace internal { 12 namespace internal {
12 namespace { 13 namespace {
13 14
14 ValidationErrorObserverForTesting* g_validation_error_observer = NULL; 15 ValidationErrorObserverForTesting* g_validation_error_observer = NULL;
15 16
16 } // namespace 17 } // namespace
17 18
18 const char* ValidationErrorToString(ValidationError error) { 19 const char* ValidationErrorToString(ValidationError error) {
(...skipping 15 matching lines...) Expand all
34 case VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION: 35 case VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION:
35 return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION"; 36 return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAG_COMBINATION";
36 case VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID: 37 case VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID:
37 return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID"; 38 return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID";
38 } 39 }
39 40
40 return "Unknown error"; 41 return "Unknown error";
41 } 42 }
42 43
43 void ReportValidationError(ValidationError error) { 44 void ReportValidationError(ValidationError error) {
44 if (g_validation_error_observer) { 45 if (g_validation_error_observer)
45 g_validation_error_observer->set_last_error(error); 46 g_validation_error_observer->set_last_error(error);
46 } else { 47 else
47 // TODO(yzshen): Consider adding better logging support. 48 MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error);
48 fprintf(stderr, "Invalid message: %s\n", ValidationErrorToString(error));
49 }
50 } 49 }
51 50
52 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting() 51 ValidationErrorObserverForTesting::ValidationErrorObserverForTesting()
53 : last_error_(VALIDATION_ERROR_NONE) { 52 : last_error_(VALIDATION_ERROR_NONE) {
54 assert(!g_validation_error_observer); 53 assert(!g_validation_error_observer);
55 g_validation_error_observer = this; 54 g_validation_error_observer = this;
56 } 55 }
57 56
58 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() { 57 ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() {
59 assert(g_validation_error_observer == this); 58 assert(g_validation_error_observer == this);
60 g_validation_error_observer = NULL; 59 g_validation_error_observer = NULL;
61 } 60 }
62 61
63 } // namespace internal 62 } // namespace internal
64 } // namespace mojo 63 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/validation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698