| 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..a74f6cf3be8a52259829f8e772f7cf88dd0e1185
|
| --- /dev/null
|
| +++ b/base/test/logging_utils.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2017 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 "base/test/logging_utils.h"
|
| +
|
| +#include <utility>
|
| +
|
| +namespace logging {
|
| +
|
| +namespace {
|
| +
|
| +// std::swap doesn't work 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_)
|
| + PushLogAssertHandler(handler);
|
| +}
|
| +
|
| +ScopedLogAssertHandler::~ScopedLogAssertHandler() {
|
| + if (handler_)
|
| + PopLogAssertHandler();
|
| +}
|
| +
|
| +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
|
|
|