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

Unified Diff: mojo/public/cpp/bindings/lib/validation_errors.cc

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | mojo/public/cpp/bindings/lib/validation_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/validation_errors.cc
diff --git a/mojo/public/cpp/bindings/lib/validation_errors.cc b/mojo/public/cpp/bindings/lib/validation_errors.cc
deleted file mode 100644
index ff0c6e90675d5de02a1f96882f3ac0dc18255bd0..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/bindings/lib/validation_errors.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/public/cpp/bindings/lib/validation_errors.h"
-
-#include <string>
-
-#include "mojo/public/cpp/environment/logging.h"
-
-namespace mojo {
-namespace internal {
-namespace {
-
-ValidationErrorObserverForTesting* g_validation_error_observer = nullptr;
-
-} // namespace
-
-// TODO(vardhan): There are golden files
-// (mojo/public/interfaces/bindings/tests/data/validation/*expected) with these
-// strings shared between languages, so changing them here requires changing
-// them in all languages, along with the golden files.
-const char* ValidationErrorToString(ValidationError error) {
- switch (error) {
- case ValidationError::NONE:
- return "VALIDATION_ERROR_NONE";
- case ValidationError::MISALIGNED_OBJECT:
- return "VALIDATION_ERROR_MISALIGNED_OBJECT";
- case ValidationError::ILLEGAL_MEMORY_RANGE:
- return "VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE";
- case ValidationError::UNEXPECTED_STRUCT_HEADER:
- return "VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER";
- case ValidationError::UNEXPECTED_ARRAY_HEADER:
- return "VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER";
- case ValidationError::ILLEGAL_HANDLE:
- return "VALIDATION_ERROR_ILLEGAL_HANDLE";
- case ValidationError::UNEXPECTED_INVALID_HANDLE:
- return "VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE";
- case ValidationError::ILLEGAL_POINTER:
- return "VALIDATION_ERROR_ILLEGAL_POINTER";
- case ValidationError::UNEXPECTED_NULL_POINTER:
- return "VALIDATION_ERROR_UNEXPECTED_NULL_POINTER";
- case ValidationError::MESSAGE_HEADER_INVALID_FLAGS:
- return "VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS";
- case ValidationError::MESSAGE_HEADER_MISSING_REQUEST_ID:
- return "VALIDATION_ERROR_MESSAGE_HEADER_MISSING_REQUEST_ID";
- case ValidationError::MESSAGE_HEADER_UNKNOWN_METHOD:
- return "VALIDATION_ERROR_MESSAGE_HEADER_UNKNOWN_METHOD";
- case ValidationError::DIFFERENT_SIZED_ARRAYS_IN_MAP:
- return "VALIDATION_ERROR_DIFFERENT_SIZED_ARRAYS_IN_MAP";
- case ValidationError::UNEXPECTED_NULL_UNION:
- return "VALIDATION_ERROR_UNEXPECTED_NULL_UNION";
- }
-
- return "Unknown error";
-}
-
-void ReportValidationError(ValidationError error, std::string* description) {
- if (g_validation_error_observer) {
- g_validation_error_observer->set_last_error(error);
- } else if (description) {
- MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error)
- << " (" << *description << ")";
- } else {
- MOJO_LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error);
- }
-}
-
-ValidationErrorObserverForTesting::ValidationErrorObserverForTesting()
- : last_error_(ValidationError::NONE) {
- MOJO_DCHECK(!g_validation_error_observer);
- g_validation_error_observer = this;
-}
-
-ValidationErrorObserverForTesting::~ValidationErrorObserverForTesting() {
- MOJO_DCHECK(g_validation_error_observer == this);
- g_validation_error_observer = nullptr;
-}
-
-ValidationErrorStringStream::ValidationErrorStringStream(std::string* err_msg)
- : err_msg_(err_msg) {}
-
-ValidationErrorStringStream::~ValidationErrorStringStream() {
- if (err_msg_)
- *err_msg_ = stream_.str();
-}
-
-} // namespace internal
-} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_errors.h ('k') | mojo/public/cpp/bindings/lib/validation_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698