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