| 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 "components/metrics/leak_detector/leak_detector.h" | 5 #include "components/metrics/leak_detector/leak_detector.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/allocator/allocator_extension.h" | 10 #include "base/allocator/allocator_extension.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 namespace metrics { | 16 namespace metrics { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // Default values for LeakDetector params. See header file for the meaning of | 20 // Default values for LeakDetector params. See header file for the meaning of |
| 20 // each parameter. | 21 // each parameter. |
| 21 const float kDefaultSamplingRate = 1.0f; | 22 const float kDefaultSamplingRate = 1.0f; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 public: | 69 public: |
| 69 LeakDetectorTest() : detector_(LeakDetector::GetInstance()) { | 70 LeakDetectorTest() : detector_(LeakDetector::GetInstance()) { |
| 70 MemoryLeakReportProto::Params params; | 71 MemoryLeakReportProto::Params params; |
| 71 params.set_sampling_rate(kDefaultSamplingRate); | 72 params.set_sampling_rate(kDefaultSamplingRate); |
| 72 params.set_max_stack_depth(kDefaultMaxCallStackUnwindDepth); | 73 params.set_max_stack_depth(kDefaultMaxCallStackUnwindDepth); |
| 73 params.set_analysis_interval_bytes(kDefaultAnalysisIntervalBytes); | 74 params.set_analysis_interval_bytes(kDefaultAnalysisIntervalBytes); |
| 74 params.set_size_suspicion_threshold(kDefaultSizeSuspicionThreshold); | 75 params.set_size_suspicion_threshold(kDefaultSizeSuspicionThreshold); |
| 75 params.set_call_stack_suspicion_threshold( | 76 params.set_call_stack_suspicion_threshold( |
| 76 kDefaultCallStackSuspicionThreshold); | 77 kDefaultCallStackSuspicionThreshold); |
| 77 | 78 |
| 78 detector_->Init(params); | 79 EXPECT_TRUE(base::ThreadTaskRunnerHandle::IsSet()); |
| 80 detector_->Init(params, base::ThreadTaskRunnerHandle::Get()); |
| 79 } | 81 } |
| 80 | 82 |
| 81 protected: | 83 protected: |
| 82 // Points to the instance of LeakDetector returned by GetInstance(). | 84 // Points to the instance of LeakDetector returned by GetInstance(). |
| 83 LeakDetector* detector_; | 85 LeakDetector* detector_; |
| 84 | 86 |
| 85 private: | 87 private: |
| 86 // For supporting content::BrowserThread operations. | 88 // For supporting content::BrowserThread operations. |
| 87 content::TestBrowserThreadBundle thread_bundle_; | 89 content::TestBrowserThreadBundle thread_bundle_; |
| 88 | 90 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 for (const TestObserver* obs : {&obs1, &obs2, &obs3}) { | 136 for (const TestObserver* obs : {&obs1, &obs2, &obs3}) { |
| 135 EXPECT_EQ(6U, obs->reports().size()); | 137 EXPECT_EQ(6U, obs->reports().size()); |
| 136 for (const auto& report : {reports1[0], reports1[1], reports1[2], | 138 for (const auto& report : {reports1[0], reports1[1], reports1[2], |
| 137 reports2[0], reports2[1], reports2[2]}) { | 139 reports2[0], reports2[1], reports2[2]}) { |
| 138 EXPECT_TRUE(obs->reports().find(report) != obs->reports().end()); | 140 EXPECT_TRUE(obs->reports().find(report) != obs->reports().end()); |
| 139 } | 141 } |
| 140 } | 142 } |
| 141 } | 143 } |
| 142 | 144 |
| 143 } // namespace metrics | 145 } // namespace metrics |
| OLD | NEW |