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

Unified Diff: chrome/browser/metrics/thread_watcher_unittest.cc

Issue 2295983002: Fix memory leak in ThreadWatcher. (Closed)
Patch Set: Address feedback from isherman in comment #17 Created 4 years, 4 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
Index: chrome/browser/metrics/thread_watcher_unittest.cc
diff --git a/chrome/browser/metrics/thread_watcher_unittest.cc b/chrome/browser/metrics/thread_watcher_unittest.cc
index 4aca262b664fda495d657724d99aeec98ba7856d..c5ee92364f3964958e2518e85487ad793c7aca44 100644
--- a/chrome/browser/metrics/thread_watcher_unittest.cc
+++ b/chrome/browser/metrics/thread_watcher_unittest.cc
@@ -279,13 +279,19 @@ class ThreadWatcherTest : public ::testing::Test {
thread_watcher_list_ = new ThreadWatcherList();
// Create thread watcher object for the IO thread.
- io_watcher_ = new CustomThreadWatcher(BrowserThread::IO, kIOThreadName,
- kSleepTime, kUnresponsiveTime);
+ std::unique_ptr<CustomThreadWatcher> io_watcher(
+ new CustomThreadWatcher(BrowserThread::IO, kIOThreadName,
+ kSleepTime, kUnresponsiveTime));
+ io_watcher_ = io_watcher.get();
+ ASSERT_TRUE(ThreadWatcherList::Register(std::move(io_watcher)));
EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(BrowserThread::IO));
// Create thread watcher object for the DB thread.
- db_watcher_ = new CustomThreadWatcher(BrowserThread::DB, kDBThreadName,
- kSleepTime, kUnresponsiveTime);
+ std::unique_ptr<CustomThreadWatcher> db_watcher(
+ new CustomThreadWatcher(BrowserThread::DB, kDBThreadName,
+ kSleepTime, kUnresponsiveTime));
+ db_watcher_ = db_watcher.get();
+ ASSERT_TRUE(ThreadWatcherList::Register(std::move(db_watcher)));
EXPECT_EQ(db_watcher_, thread_watcher_list_->Find(BrowserThread::DB));
{
« chrome/browser/metrics/thread_watcher.cc ('K') | « chrome/browser/metrics/thread_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698