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 #ifndef NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ | 5 #ifndef NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ |
6 #define NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ | 6 #define NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 // The ScopedDisableExitOnDFatal class is used to disable exiting the | 16 // The ScopedDisableExitOnDFatal class is used to disable exiting the |
17 // program when we encounter a LOG(DFATAL) within the current block. | 17 // program when we encounter a LOG(DFATAL) within the current block. |
18 // After we leave the current block, the default behavior is | 18 // After we leave the current block, the default behavior is |
19 // restored. | 19 // restored. |
20 class ScopedDisableExitOnDFatal { | 20 class ScopedDisableExitOnDFatal { |
21 public: | 21 public: |
22 ScopedDisableExitOnDFatal(); | 22 ScopedDisableExitOnDFatal(); |
23 ~ScopedDisableExitOnDFatal(); | 23 ~ScopedDisableExitOnDFatal(); |
24 | 24 |
25 private: | 25 private: |
| 26 // Currently active instance. |
| 27 static ScopedDisableExitOnDFatal* g_instance_; |
| 28 |
26 // Static function which is set as the logging assert handler. | 29 // Static function which is set as the logging assert handler. |
27 // Called when there is a check failure. | 30 // Called when there is a check failure. |
28 static void LogAssertHandler(const char* file, | 31 static void LogAssertHandler(const std::string& msg); |
29 int line, | |
30 const base::StringPiece message, | |
31 const base::StringPiece stack_trace); | |
32 | |
33 logging::ScopedLogAssertHandler assert_handler_; | |
34 | 32 |
35 DISALLOW_COPY_AND_ASSIGN(ScopedDisableExitOnDFatal); | 33 DISALLOW_COPY_AND_ASSIGN(ScopedDisableExitOnDFatal); |
36 }; | 34 }; |
37 | 35 |
38 } // namespace test | 36 } // namespace test |
39 } // namespace net | 37 } // namespace net |
40 | 38 |
41 #endif // NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ | 39 #endif // NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ |
OLD | NEW |