Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: components/metrics/leak_detector/leak_detector_unittest.cc

Issue 1665553002: metrics: Connect leak detector to allocator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: primiano's feedback; Register observer sooner Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/leak_detector/leak_detector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/leak_detector/leak_detector_unittest.cc
diff --git a/components/metrics/leak_detector/leak_detector_unittest.cc b/components/metrics/leak_detector/leak_detector_unittest.cc
index a134a17b130bc2000c659e12f28c0890b580ca8e..6f33c012bb6e2ad0dc41b0aebf772a479a1cb6b1 100644
--- a/components/metrics/leak_detector/leak_detector_unittest.cc
+++ b/components/metrics/leak_detector/leak_detector_unittest.cc
@@ -6,8 +6,8 @@
#include <set>
+#include "base/allocator/allocator_extension.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -59,17 +59,16 @@ class TestObserver : public LeakDetector::Observer {
class LeakDetectorTest : public ::testing::Test {
public:
- LeakDetectorTest()
- : detector_(new LeakDetector(kDefaultSamplingRate,
- kDefaultMaxCallStackUnwindDepth,
- kDefaultAnalysisIntervalBytes,
- kDefaultSizeSuspicionThreshold,
- kDefaultCallStackSuspicionThreshold)) {}
+ LeakDetectorTest() : detector_(LeakDetector::GetInstance()) {
+ detector_->Init(kDefaultSamplingRate, kDefaultMaxCallStackUnwindDepth,
+ kDefaultAnalysisIntervalBytes,
+ kDefaultSizeSuspicionThreshold,
+ kDefaultCallStackSuspicionThreshold);
+ }
protected:
- // Use a scoped_ptr to hold the test object so it can be destroyed before the
- // test is over.
- scoped_ptr<LeakDetector> detector_;
+ // Points to the instance of LeakDetector returned by GetInstance().
+ LeakDetector* detector_;
private:
// For supporting content::BrowserThread operations.
@@ -106,10 +105,6 @@ TEST_F(LeakDetectorTest, NotifyObservers) {
detector_->NotifyObservers(reports1);
detector_->NotifyObservers(reports2);
- // Shut down the leak detector before checking the reports, so that the
- // stored reports can be examined without new reports being generated.
- detector_.reset();
-
// Check that all three observers got both sets of reports, passed in
// separately.
for (const TestObserver* obs : {&obs1, &obs2, &obs3}) {
« no previous file with comments | « components/metrics/leak_detector/leak_detector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698