Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/metrics/leak_detector/leak_detector_controller.h" | 5 #include "chrome/browser/metrics/leak_detector/leak_detector_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 DISALLOW_COPY_AND_ASSIGN(LeakDetectorControllerTest); | 52 DISALLOW_COPY_AND_ASSIGN(LeakDetectorControllerTest); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Use a global instance of the test class because LeakDetectorController | 55 // Use a global instance of the test class because LeakDetectorController |
| 56 // initializes class LeakDetector, which can only be initialized once, enforced | 56 // initializes class LeakDetector, which can only be initialized once, enforced |
| 57 // by an internal CHECK. Multiple initializations of LeakDetectorController in | 57 // by an internal CHECK. Multiple initializations of LeakDetectorController in |
| 58 // the same process will result in multiple initializations of class | 58 // the same process will result in multiple initializations of class |
| 59 // LeakDetector. | 59 // LeakDetector. |
| 60 // | 60 // |
| 61 // See src/components/metrics/leak_detector/leak_detector.h for more info. | 61 // See src/components/metrics/leak_detector/leak_detector.h for more info. |
| 62 base::LazyInstance<TestLeakDetectorController> g_instance = | 62 base::LazyInstance<TestLeakDetectorController>::Leaky g_instance = |
|
gab
2016/12/02 19:23:51
Needs to be leaky or its destructor runs after the
oshima
2016/12/02 20:18:12
can you update the comment above?
gab
2016/12/03 03:02:27
Done.
| |
| 63 LAZY_INSTANCE_INITIALIZER; | 63 LAZY_INSTANCE_INITIALIZER; |
| 64 | 64 |
| 65 TEST_F(LeakDetectorControllerTest, SingleReport) { | 65 TEST_F(LeakDetectorControllerTest, SingleReport) { |
| 66 MemoryLeakReportProto report; | 66 MemoryLeakReportProto report; |
| 67 report.set_size_bytes(8); | 67 report.set_size_bytes(8); |
| 68 InitializeRepeatedField({1, 2, 3, 4}, report.mutable_call_stack()); | 68 InitializeRepeatedField({1, 2, 3, 4}, report.mutable_call_stack()); |
| 69 | 69 |
| 70 TestLeakDetectorController* controller = &g_instance.Get(); | 70 TestLeakDetectorController* controller = &g_instance.Get(); |
| 71 controller->OnLeaksFound({report}); | 71 controller->OnLeaksFound({report}); |
| 72 | 72 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 EXPECT_EQ(13U, stored_reports[2].call_stack().Get(4)); | 260 EXPECT_EQ(13U, stored_reports[2].call_stack().Get(4)); |
| 261 EXPECT_EQ(14U, stored_reports[2].call_stack().Get(5)); | 261 EXPECT_EQ(14U, stored_reports[2].call_stack().Get(5)); |
| 262 EXPECT_EQ(15U, stored_reports[2].call_stack().Get(6)); | 262 EXPECT_EQ(15U, stored_reports[2].call_stack().Get(6)); |
| 263 EXPECT_EQ(16U, stored_reports[2].call_stack().Get(7)); | 263 EXPECT_EQ(16U, stored_reports[2].call_stack().Get(7)); |
| 264 | 264 |
| 265 controller->GetLeakReports(&stored_reports); | 265 controller->GetLeakReports(&stored_reports); |
| 266 ASSERT_EQ(0U, stored_reports.size()); | 266 ASSERT_EQ(0U, stored_reports.size()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace metrics | 269 } // namespace metrics |
| OLD | NEW |