OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/test/logging_utils.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 namespace logging { |
| 10 |
| 11 namespace { |
| 12 |
| 13 // std::swap doesn't work with base::Callback. |
| 14 void SwapHandlers(LogAssertHandlerFunction* a, LogAssertHandlerFunction* b) { |
| 15 LogAssertHandlerFunction temp = *a; |
| 16 *a = *b; |
| 17 *b = temp; |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 ScopedLogAssertHandler::ScopedLogAssertHandler() {} |
| 23 |
| 24 ScopedLogAssertHandler::ScopedLogAssertHandler(LogAssertHandlerFunction handler) |
| 25 : handler_(handler) { |
| 26 if (handler_) |
| 27 PushLogAssertHandler(handler); |
| 28 } |
| 29 |
| 30 ScopedLogAssertHandler::~ScopedLogAssertHandler() { |
| 31 if (handler_) |
| 32 PopLogAssertHandler(); |
| 33 } |
| 34 |
| 35 ScopedLogAssertHandler::ScopedLogAssertHandler(ScopedLogAssertHandler&& other) { |
| 36 SwapHandlers(&handler_, &other.handler_); |
| 37 } |
| 38 |
| 39 ScopedLogAssertHandler& ScopedLogAssertHandler::operator=( |
| 40 ScopedLogAssertHandler&& other) { |
| 41 ScopedLogAssertHandler temp_copy(std::move(other)); |
| 42 SwapHandlers(&handler_, &temp_copy.handler_); |
| 43 return *this; |
| 44 } |
| 45 |
| 46 } // namespace logging |
OLD | NEW |