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

Side by Side Diff: chrome/browser/metrics/thread_watcher_unittest.cc

Issue 2299453005: Revert of Fix memory leak in ThreadWatcher. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/metrics/thread_watcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/thread_watcher.h" 5 #include "chrome/browser/metrics/thread_watcher.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 WaitForSetUp(TimeDelta::FromMinutes(1)); 272 WaitForSetUp(TimeDelta::FromMinutes(1));
273 } 273 }
274 274
275 void SetUpObjects() { 275 void SetUpObjects() {
276 DCHECK(WatchDogThread::CurrentlyOnWatchDogThread()); 276 DCHECK(WatchDogThread::CurrentlyOnWatchDogThread());
277 277
278 // Setup the registry for thread watchers. 278 // Setup the registry for thread watchers.
279 thread_watcher_list_ = new ThreadWatcherList(); 279 thread_watcher_list_ = new ThreadWatcherList();
280 280
281 // Create thread watcher object for the IO thread. 281 // Create thread watcher object for the IO thread.
282 std::unique_ptr<CustomThreadWatcher> io_watcher( 282 io_watcher_ = new CustomThreadWatcher(BrowserThread::IO, kIOThreadName,
283 new CustomThreadWatcher(BrowserThread::IO, kIOThreadName, 283 kSleepTime, kUnresponsiveTime);
284 kSleepTime, kUnresponsiveTime));
285 io_watcher_ = io_watcher.get();
286 ASSERT_TRUE(ThreadWatcherList::Register(std::move(io_watcher)));
287 EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(BrowserThread::IO)); 284 EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(BrowserThread::IO));
288 285
289 // Create thread watcher object for the DB thread. 286 // Create thread watcher object for the DB thread.
290 std::unique_ptr<CustomThreadWatcher> db_watcher( 287 db_watcher_ = new CustomThreadWatcher(BrowserThread::DB, kDBThreadName,
291 new CustomThreadWatcher(BrowserThread::DB, kDBThreadName, 288 kSleepTime, kUnresponsiveTime);
292 kSleepTime, kUnresponsiveTime));
293 db_watcher_ = db_watcher.get();
294 ASSERT_TRUE(ThreadWatcherList::Register(std::move(db_watcher)));
295 EXPECT_EQ(db_watcher_, thread_watcher_list_->Find(BrowserThread::DB)); 289 EXPECT_EQ(db_watcher_, thread_watcher_list_->Find(BrowserThread::DB));
296 290
297 { 291 {
298 base::AutoLock lock(lock_); 292 base::AutoLock lock(lock_);
299 initialized_ = true; 293 initialized_ = true;
300 } 294 }
301 setup_complete_.Signal(); 295 setup_complete_.Signal();
302 } 296 }
303 297
304 void WaitForSetUp(TimeDelta wait_time) { 298 void WaitForSetUp(TimeDelta wait_time) {
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 814 }
821 815
822 TEST_F(JankTimeBombTest, ArmTest) { 816 TEST_F(JankTimeBombTest, ArmTest) {
823 // Test firing of Alarm by passing empty delay. 817 // Test firing of Alarm by passing empty delay.
824 TestingJankTimeBomb timebomb((base::TimeDelta())); 818 TestingJankTimeBomb timebomb((base::TimeDelta()));
825 if (!timebomb.IsEnabled()) 819 if (!timebomb.IsEnabled())
826 return; 820 return;
827 WaitForWatchDogThreadPostTask(); 821 WaitForWatchDogThreadPostTask();
828 EXPECT_TRUE(timebomb.alarm_invoked()); 822 EXPECT_TRUE(timebomb.alarm_invoked());
829 } 823 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/thread_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698