OLD | NEW |
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 Loading... |
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 io_watcher_ = new CustomThreadWatcher(BrowserThread::IO, kIOThreadName, | 282 std::unique_ptr<CustomThreadWatcher> io_watcher( |
283 kSleepTime, kUnresponsiveTime); | 283 new CustomThreadWatcher(BrowserThread::IO, kIOThreadName, |
| 284 kSleepTime, kUnresponsiveTime)); |
| 285 io_watcher_ = io_watcher.get(); |
| 286 ASSERT_TRUE(ThreadWatcherList::Register(std::move(io_watcher))); |
284 EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(BrowserThread::IO)); | 287 EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(BrowserThread::IO)); |
285 | 288 |
286 // Create thread watcher object for the DB thread. | 289 // Create thread watcher object for the DB thread. |
287 db_watcher_ = new CustomThreadWatcher(BrowserThread::DB, kDBThreadName, | 290 std::unique_ptr<CustomThreadWatcher> db_watcher( |
288 kSleepTime, kUnresponsiveTime); | 291 new CustomThreadWatcher(BrowserThread::DB, kDBThreadName, |
| 292 kSleepTime, kUnresponsiveTime)); |
| 293 db_watcher_ = db_watcher.get(); |
| 294 ASSERT_TRUE(ThreadWatcherList::Register(std::move(db_watcher))); |
289 EXPECT_EQ(db_watcher_, thread_watcher_list_->Find(BrowserThread::DB)); | 295 EXPECT_EQ(db_watcher_, thread_watcher_list_->Find(BrowserThread::DB)); |
290 | 296 |
291 { | 297 { |
292 base::AutoLock lock(lock_); | 298 base::AutoLock lock(lock_); |
293 initialized_ = true; | 299 initialized_ = true; |
294 } | 300 } |
295 setup_complete_.Signal(); | 301 setup_complete_.Signal(); |
296 } | 302 } |
297 | 303 |
298 void WaitForSetUp(TimeDelta wait_time) { | 304 void WaitForSetUp(TimeDelta wait_time) { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 } | 820 } |
815 | 821 |
816 TEST_F(JankTimeBombTest, ArmTest) { | 822 TEST_F(JankTimeBombTest, ArmTest) { |
817 // Test firing of Alarm by passing empty delay. | 823 // Test firing of Alarm by passing empty delay. |
818 TestingJankTimeBomb timebomb((base::TimeDelta())); | 824 TestingJankTimeBomb timebomb((base::TimeDelta())); |
819 if (!timebomb.IsEnabled()) | 825 if (!timebomb.IsEnabled()) |
820 return; | 826 return; |
821 WaitForWatchDogThreadPostTask(); | 827 WaitForWatchDogThreadPostTask(); |
822 EXPECT_TRUE(timebomb.alarm_invoked()); | 828 EXPECT_TRUE(timebomb.alarm_invoked()); |
823 } | 829 } |
OLD | NEW |