OLD | NEW |
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 "net/test/scoped_disable_exit_on_dfatal.h" | 5 #include "net/test/scoped_disable_exit_on_dfatal.h" |
6 | 6 |
7 #include "base/bind.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/strings/string_piece.h" | |
10 | 8 |
11 namespace net { | 9 namespace net { |
12 namespace test { | 10 namespace test { |
13 | 11 |
14 ScopedDisableExitOnDFatal::ScopedDisableExitOnDFatal() | 12 // static |
15 : assert_handler_(base::Bind(LogAssertHandler)) {} | 13 ScopedDisableExitOnDFatal* ScopedDisableExitOnDFatal::g_instance_ = NULL; |
16 | 14 |
17 ScopedDisableExitOnDFatal::~ScopedDisableExitOnDFatal() {} | 15 ScopedDisableExitOnDFatal::ScopedDisableExitOnDFatal() { |
| 16 CHECK(!g_instance_); |
| 17 g_instance_ = this; |
| 18 logging::SetLogAssertHandler(LogAssertHandler); |
| 19 } |
| 20 |
| 21 ScopedDisableExitOnDFatal::~ScopedDisableExitOnDFatal() { |
| 22 CHECK_EQ(g_instance_, this); |
| 23 logging::SetLogAssertHandler(NULL); |
| 24 g_instance_ = NULL; |
| 25 } |
18 | 26 |
19 // static | 27 // static |
20 void ScopedDisableExitOnDFatal::LogAssertHandler( | 28 void ScopedDisableExitOnDFatal::LogAssertHandler(const std::string& str) { |
21 const char* file, | |
22 int line, | |
23 const base::StringPiece message, | |
24 const base::StringPiece stack_trace) { | |
25 // Simply swallow the assert. | 29 // Simply swallow the assert. |
26 } | 30 } |
27 | 31 |
28 } // namespace test | 32 } // namespace test |
29 } // namespace net | 33 } // namespace net |
OLD | NEW |