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

Unified Diff: base/test/logging_utils.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Add comment. Fix missed usage of SetLogAssertHandler. Created 3 years, 11 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
Index: base/test/logging_utils.cc
diff --git a/base/test/logging_utils.cc b/base/test/logging_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..49bf0abe24b759b2b3865d36f3121ec8499480de
--- /dev/null
+++ b/base/test/logging_utils.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
Paweł Hajdan Jr. 2017/01/27 17:19:44 nit: 2017, no (c).
alex-ac 2017/02/11 20:12:19 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/logging_utils.h"
+
+#include <utility>
+
+namespace logging {
+
+namespace {
+
+// std::swap doesn't works with base::Callback.
+void SwapHandlers(LogAssertHandlerFunction* a, LogAssertHandlerFunction* b) {
+ LogAssertHandlerFunction temp = *a;
+ *a = *b;
+ *b = temp;
+}
+
+} // namespace
+
+ScopedLogAssertHandler::ScopedLogAssertHandler() {}
+
+ScopedLogAssertHandler::ScopedLogAssertHandler(LogAssertHandlerFunction handler)
+ : handler_(handler) {
+ if (handler_)
+ SetLogAssertHandler(handler);
+}
+
+ScopedLogAssertHandler::~ScopedLogAssertHandler() {
+ if (handler_)
+ ResetLogAssertHandler();
+}
+
+ScopedLogAssertHandler::ScopedLogAssertHandler(ScopedLogAssertHandler&& other) {
+ SwapHandlers(&handler_, &other.handler_);
+}
+
+ScopedLogAssertHandler& ScopedLogAssertHandler::operator=(
+ ScopedLogAssertHandler&& other) {
+ ScopedLogAssertHandler temp_copy(std::move(other));
+ SwapHandlers(&handler_, &temp_copy.handler_);
+ return *this;
+}
+
+} // namespace logging

Powered by Google App Engine
This is Rietveld 408576698