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 "base/threading/watchdog.h" | 5 #include "base/threading/watchdog.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/synchronization/spin_wait.h" | 8 #include "base/synchronization/spin_wait.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 public: | 21 public: |
22 WatchdogCounter(const TimeDelta& duration, | 22 WatchdogCounter(const TimeDelta& duration, |
23 const std::string& thread_watched_name, | 23 const std::string& thread_watched_name, |
24 bool enabled) | 24 bool enabled) |
25 : Watchdog(duration, thread_watched_name, enabled), | 25 : Watchdog(duration, thread_watched_name, enabled), |
26 alarm_counter_(0) { | 26 alarm_counter_(0) { |
27 } | 27 } |
28 | 28 |
29 virtual ~WatchdogCounter() {} | 29 virtual ~WatchdogCounter() {} |
30 | 30 |
31 virtual void Alarm() OVERRIDE { | 31 virtual void Alarm() override { |
32 alarm_counter_++; | 32 alarm_counter_++; |
33 Watchdog::Alarm(); | 33 Watchdog::Alarm(); |
34 } | 34 } |
35 | 35 |
36 int alarm_counter() { return alarm_counter_; } | 36 int alarm_counter() { return alarm_counter_; } |
37 | 37 |
38 private: | 38 private: |
39 int alarm_counter_; | 39 int alarm_counter_; |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(WatchdogCounter); | 41 DISALLOW_COPY_AND_ASSIGN(WatchdogCounter); |
42 }; | 42 }; |
43 | 43 |
44 class WatchdogTest : public testing::Test { | 44 class WatchdogTest : public testing::Test { |
45 public: | 45 public: |
46 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() override { |
47 Watchdog::ResetStaticData(); | 47 Watchdog::ResetStaticData(); |
48 } | 48 } |
49 }; | 49 }; |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 //------------------------------------------------------------------------------ | 53 //------------------------------------------------------------------------------ |
54 // Actual tests | 54 // Actual tests |
55 | 55 |
56 // Minimal constructor/destructor test. | 56 // Minimal constructor/destructor test. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Set a time greater than the timeout into the past. | 133 // Set a time greater than the timeout into the past. |
134 watchdog.ArmSomeTimeDeltaAgo(TimeDelta::FromSeconds(10)); | 134 watchdog.ArmSomeTimeDeltaAgo(TimeDelta::FromSeconds(10)); |
135 // It should almost instantly go off, but certainly in less than 5 minutes. | 135 // It should almost instantly go off, but certainly in less than 5 minutes. |
136 SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(TimeDelta::FromMinutes(5), | 136 SPIN_FOR_TIMEDELTA_OR_UNTIL_TRUE(TimeDelta::FromMinutes(5), |
137 watchdog.alarm_counter() > 0); | 137 watchdog.alarm_counter() > 0); |
138 | 138 |
139 EXPECT_EQ(1, watchdog.alarm_counter()); | 139 EXPECT_EQ(1, watchdog.alarm_counter()); |
140 } | 140 } |
141 | 141 |
142 } // namespace base | 142 } // namespace base |
OLD | NEW |