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

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

Issue 2295983002: Fix memory leak in ThreadWatcher. (Closed)
Patch Set: Cleanup ThreadWatcher initialization logic. 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..ef7192e1f5e25dd035e8792a174d85baf42371ce 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();
+ EXPECT_TRUE(ThreadWatcherList::Register(std::move(io_watcher)));
Ilya Sherman 2016/08/31 03:54:42 nit: This should be an ASSERT_TRUE, as the followi
Joshua LeVasseur 2016/08/31 19:06:50 Done.
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();
+ EXPECT_TRUE(ThreadWatcherList::Register(std::move(db_watcher)));
Ilya Sherman 2016/08/31 03:54:42 Ditto.
Joshua LeVasseur 2016/08/31 19:06:50 Done.
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