| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 base::RunLoop().Run(); | 744 base::RunLoop().Run(); |
| 745 | 745 |
| 746 CheckState(false /* has_thread_watcher_list */, | 746 CheckState(false /* has_thread_watcher_list */, |
| 747 true /* stopped */, | 747 true /* stopped */, |
| 748 "Stopped"); | 748 "Stopped"); |
| 749 } | 749 } |
| 750 | 750 |
| 751 class TestingJankTimeBomb : public JankTimeBomb { | 751 class TestingJankTimeBomb : public JankTimeBomb { |
| 752 public: | 752 public: |
| 753 explicit TestingJankTimeBomb(base::TimeDelta duration) | 753 explicit TestingJankTimeBomb(base::TimeDelta duration) |
| 754 : JankTimeBomb(duration), | 754 : JankTimeBomb(duration, metrics::CallStackProfileParams::UI_THREAD), |
| 755 thread_id_(base::PlatformThread::CurrentId()), | 755 thread_id_(base::PlatformThread::CurrentId()), |
| 756 alarm_invoked_(false) { | 756 alarm_invoked_(false) { |
| 757 } | 757 } |
| 758 | 758 |
| 759 ~TestingJankTimeBomb() override {} | 759 ~TestingJankTimeBomb() override {} |
| 760 | 760 |
| 761 void Alarm(base::PlatformThreadId thread_id) override { | 761 void Alarm(base::PlatformThreadId thread_id) override { |
| 762 EXPECT_EQ(thread_id_, thread_id); | 762 EXPECT_EQ(thread_id_, thread_id); |
| 763 alarm_invoked_ = true; | 763 alarm_invoked_ = true; |
| 764 } | 764 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 } | 824 } |
| 825 | 825 |
| 826 TEST_F(JankTimeBombTest, ArmTest) { | 826 TEST_F(JankTimeBombTest, ArmTest) { |
| 827 // Test firing of Alarm by passing empty delay. | 827 // Test firing of Alarm by passing empty delay. |
| 828 TestingJankTimeBomb timebomb((base::TimeDelta())); | 828 TestingJankTimeBomb timebomb((base::TimeDelta())); |
| 829 if (!timebomb.IsEnabled()) | 829 if (!timebomb.IsEnabled()) |
| 830 return; | 830 return; |
| 831 WaitForWatchDogThreadPostTask(); | 831 WaitForWatchDogThreadPostTask(); |
| 832 EXPECT_TRUE(timebomb.alarm_invoked()); | 832 EXPECT_TRUE(timebomb.alarm_invoked()); |
| 833 } | 833 } |
| OLD | NEW |