| 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 <math.h> | 5 #include <math.h> |
| 6 #include <stdint.h> |
| 6 | 7 |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_tokenizer.h" | 18 #include "base/strings/string_tokenizer.h" |
| 18 #include "base/synchronization/condition_variable.h" | 19 #include "base/synchronization/condition_variable.h" |
| 19 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 20 #include "base/synchronization/spin_wait.h" | 21 #include "base/synchronization/spin_wait.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // thread that keeps it busy. It also has an utility method to block running of | 60 // thread that keeps it busy. It also has an utility method to block running of |
| 60 // tests until ThreadWatcher object's post-condition state changes to an | 61 // tests until ThreadWatcher object's post-condition state changes to an |
| 61 // expected state. | 62 // expected state. |
| 62 class CustomThreadWatcher : public ThreadWatcher { | 63 class CustomThreadWatcher : public ThreadWatcher { |
| 63 public: | 64 public: |
| 64 base::Lock custom_lock_; | 65 base::Lock custom_lock_; |
| 65 base::ConditionVariable state_changed_; | 66 base::ConditionVariable state_changed_; |
| 66 State thread_watcher_state_; | 67 State thread_watcher_state_; |
| 67 WaitState wait_state_; | 68 WaitState wait_state_; |
| 68 CheckResponseState check_response_state_; | 69 CheckResponseState check_response_state_; |
| 69 uint64 ping_sent_; | 70 uint64_t ping_sent_; |
| 70 uint64 pong_received_; | 71 uint64_t pong_received_; |
| 71 base::subtle::Atomic32 success_response_; | 72 base::subtle::Atomic32 success_response_; |
| 72 base::subtle::Atomic32 failed_response_; | 73 base::subtle::Atomic32 failed_response_; |
| 73 base::TimeTicks saved_ping_time_; | 74 base::TimeTicks saved_ping_time_; |
| 74 uint64 saved_ping_sequence_number_; | 75 uint64_t saved_ping_sequence_number_; |
| 75 | 76 |
| 76 CustomThreadWatcher(const BrowserThread::ID thread_id, | 77 CustomThreadWatcher(const BrowserThread::ID thread_id, |
| 77 const std::string thread_name, | 78 const std::string thread_name, |
| 78 const TimeDelta& sleep_time, | 79 const TimeDelta& sleep_time, |
| 79 const TimeDelta& unresponsive_time) | 80 const TimeDelta& unresponsive_time) |
| 80 : ThreadWatcher(WatchingParams(thread_id, thread_name, sleep_time, | 81 : ThreadWatcher(WatchingParams(thread_id, thread_name, sleep_time, |
| 81 unresponsive_time, ThreadWatcherList::kUnresponsiveCount, | 82 unresponsive_time, ThreadWatcherList::kUnresponsiveCount, |
| 82 true, ThreadWatcherList::kLiveThreadsThreshold)), | 83 true, ThreadWatcherList::kLiveThreadsThreshold)), |
| 83 state_changed_(&custom_lock_), | 84 state_changed_(&custom_lock_), |
| 84 thread_watcher_state_(INITIALIZED), | 85 thread_watcher_state_(INITIALIZED), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 old_state == RECEIVED_PONG); | 134 old_state == RECEIVED_PONG); |
| 134 ThreadWatcher::DeActivateThreadWatching(); | 135 ThreadWatcher::DeActivateThreadWatching(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void PostPingMessage() override { | 138 void PostPingMessage() override { |
| 138 State old_state = UpdateState(SENT_PING); | 139 State old_state = UpdateState(SENT_PING); |
| 139 EXPECT_TRUE(old_state == ACTIVATED || old_state == RECEIVED_PONG); | 140 EXPECT_TRUE(old_state == ACTIVATED || old_state == RECEIVED_PONG); |
| 140 ThreadWatcher::PostPingMessage(); | 141 ThreadWatcher::PostPingMessage(); |
| 141 } | 142 } |
| 142 | 143 |
| 143 void OnPongMessage(uint64 ping_sequence_number) override { | 144 void OnPongMessage(uint64_t ping_sequence_number) override { |
| 144 State old_state = UpdateState(RECEIVED_PONG); | 145 State old_state = UpdateState(RECEIVED_PONG); |
| 145 EXPECT_TRUE(old_state == SENT_PING || old_state == DEACTIVATED); | 146 EXPECT_TRUE(old_state == SENT_PING || old_state == DEACTIVATED); |
| 146 ThreadWatcher::OnPongMessage(ping_sequence_number); | 147 ThreadWatcher::OnPongMessage(ping_sequence_number); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void OnCheckResponsiveness(uint64 ping_sequence_number) override { | 150 void OnCheckResponsiveness(uint64_t ping_sequence_number) override { |
| 150 ThreadWatcher::OnCheckResponsiveness(ping_sequence_number); | 151 ThreadWatcher::OnCheckResponsiveness(ping_sequence_number); |
| 151 { | 152 { |
| 152 base::AutoLock auto_lock(custom_lock_); | 153 base::AutoLock auto_lock(custom_lock_); |
| 153 if (responsive_) { | 154 if (responsive_) { |
| 154 base::subtle::Release_Store(&success_response_, | 155 base::subtle::Release_Store(&success_response_, |
| 155 base::subtle::Acquire_Load(&success_response_) + 1); | 156 base::subtle::Acquire_Load(&success_response_) + 1); |
| 156 check_response_state_ = SUCCESSFUL; | 157 check_response_state_ = SUCCESSFUL; |
| 157 } else { | 158 } else { |
| 158 base::subtle::Release_Store(&failed_response_, | 159 base::subtle::Release_Store(&failed_response_, |
| 159 base::subtle::Acquire_Load(&failed_response_) + 1); | 160 base::subtle::Acquire_Load(&failed_response_) + 1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 181 UpdateWaitState(ALL_DONE); | 182 UpdateWaitState(ALL_DONE); |
| 182 } | 183 } |
| 183 | 184 |
| 184 State WaitForStateChange(const TimeDelta& wait_time, State expected_state) { | 185 State WaitForStateChange(const TimeDelta& wait_time, State expected_state) { |
| 185 DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread()); | 186 DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread()); |
| 186 UpdateWaitState(STARTED_WAITING); | 187 UpdateWaitState(STARTED_WAITING); |
| 187 | 188 |
| 188 State exit_state = INITIALIZED; | 189 State exit_state = INITIALIZED; |
| 189 // Keep the thread that is running the tests waiting until ThreadWatcher | 190 // Keep the thread that is running the tests waiting until ThreadWatcher |
| 190 // object's state changes to the expected_state or until wait_time elapses. | 191 // object's state changes to the expected_state or until wait_time elapses. |
| 191 for (uint32 i = 0; i < unresponsive_threshold_; ++i) { | 192 for (uint32_t i = 0; i < unresponsive_threshold_; ++i) { |
| 192 TimeTicks end_time = TimeTicks::Now() + wait_time; | 193 TimeTicks end_time = TimeTicks::Now() + wait_time; |
| 193 { | 194 { |
| 194 base::AutoLock auto_lock(custom_lock_); | 195 base::AutoLock auto_lock(custom_lock_); |
| 195 while (thread_watcher_state_ != expected_state && | 196 while (thread_watcher_state_ != expected_state && |
| 196 TimeTicks::Now() < end_time) { | 197 TimeTicks::Now() < end_time) { |
| 197 TimeDelta state_change_wait_time = end_time - TimeTicks::Now(); | 198 TimeDelta state_change_wait_time = end_time - TimeTicks::Now(); |
| 198 state_changed_.TimedWait(state_change_wait_time); | 199 state_changed_.TimedWait(state_change_wait_time); |
| 199 } | 200 } |
| 200 // Capture the thread_watcher_state_ before it changes and return it | 201 // Capture the thread_watcher_state_ before it changes and return it |
| 201 // to the caller. | 202 // to the caller. |
| 202 exit_state = thread_watcher_state_; | 203 exit_state = thread_watcher_state_; |
| 203 if (exit_state == expected_state) | 204 if (exit_state == expected_state) |
| 204 break; | 205 break; |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 UpdateWaitState(STOPPED_WAITING); | 208 UpdateWaitState(STOPPED_WAITING); |
| 208 return exit_state; | 209 return exit_state; |
| 209 } | 210 } |
| 210 | 211 |
| 211 CheckResponseState WaitForCheckResponse(const TimeDelta& wait_time, | 212 CheckResponseState WaitForCheckResponse(const TimeDelta& wait_time, |
| 212 CheckResponseState expected_state) { | 213 CheckResponseState expected_state) { |
| 213 DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread()); | 214 DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread()); |
| 214 UpdateWaitState(STARTED_WAITING); | 215 UpdateWaitState(STARTED_WAITING); |
| 215 | 216 |
| 216 CheckResponseState exit_state = UNKNOWN; | 217 CheckResponseState exit_state = UNKNOWN; |
| 217 // Keep the thread that is running the tests waiting until ThreadWatcher | 218 // Keep the thread that is running the tests waiting until ThreadWatcher |
| 218 // object's check_response_state_ changes to the expected_state or until | 219 // object's check_response_state_ changes to the expected_state or until |
| 219 // wait_time elapses. | 220 // wait_time elapses. |
| 220 for (uint32 i = 0; i < unresponsive_threshold_; ++i) { | 221 for (uint32_t i = 0; i < unresponsive_threshold_; ++i) { |
| 221 TimeTicks end_time = TimeTicks::Now() + wait_time; | 222 TimeTicks end_time = TimeTicks::Now() + wait_time; |
| 222 { | 223 { |
| 223 base::AutoLock auto_lock(custom_lock_); | 224 base::AutoLock auto_lock(custom_lock_); |
| 224 while (check_response_state_ != expected_state && | 225 while (check_response_state_ != expected_state && |
| 225 TimeTicks::Now() < end_time) { | 226 TimeTicks::Now() < end_time) { |
| 226 TimeDelta state_change_wait_time = end_time - TimeTicks::Now(); | 227 TimeDelta state_change_wait_time = end_time - TimeTicks::Now(); |
| 227 state_changed_.TimedWait(state_change_wait_time); | 228 state_changed_.TimedWait(state_change_wait_time); |
| 228 } | 229 } |
| 229 // Capture the check_response_state_ before it changes and return it | 230 // Capture the check_response_state_ before it changes and return it |
| 230 // to the caller. | 231 // to the caller. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 "UI:5:12,IO:5:12,FILE:5:12"; | 341 "UI:5:12,IO:5:12,FILE:5:12"; |
| 341 | 342 |
| 342 TEST_F(ThreadWatcherTest, ThreadNamesOnlyArgs) { | 343 TEST_F(ThreadWatcherTest, ThreadNamesOnlyArgs) { |
| 343 // Setup command_line arguments. | 344 // Setup command_line arguments. |
| 344 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 345 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 345 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, | 346 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, |
| 346 crash_on_hang_thread_names); | 347 crash_on_hang_thread_names); |
| 347 | 348 |
| 348 // Parse command_line arguments. | 349 // Parse command_line arguments. |
| 349 ThreadWatcherList::CrashOnHangThreadMap crash_on_hang_threads; | 350 ThreadWatcherList::CrashOnHangThreadMap crash_on_hang_threads; |
| 350 uint32 unresponsive_threshold; | 351 uint32_t unresponsive_threshold; |
| 351 ThreadWatcherList::ParseCommandLine(command_line, | 352 ThreadWatcherList::ParseCommandLine(command_line, |
| 352 &unresponsive_threshold, | 353 &unresponsive_threshold, |
| 353 &crash_on_hang_threads); | 354 &crash_on_hang_threads); |
| 354 | 355 |
| 355 // Verify the data. | 356 // Verify the data. |
| 356 base::StringTokenizer tokens(crash_on_hang_thread_names, ","); | 357 base::StringTokenizer tokens(crash_on_hang_thread_names, ","); |
| 357 while (tokens.GetNext()) { | 358 while (tokens.GetNext()) { |
| 358 std::vector<base::StringPiece> values = base::SplitStringPiece( | 359 std::vector<base::StringPiece> values = base::SplitStringPiece( |
| 359 tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 360 tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 360 std::string thread_name = values[0].as_string(); | 361 std::string thread_name = values[0].as_string(); |
| 361 | 362 |
| 362 ThreadWatcherList::CrashOnHangThreadMap::iterator it = | 363 ThreadWatcherList::CrashOnHangThreadMap::iterator it = |
| 363 crash_on_hang_threads.find(thread_name); | 364 crash_on_hang_threads.find(thread_name); |
| 364 bool crash_on_hang = (it != crash_on_hang_threads.end()); | 365 bool crash_on_hang = (it != crash_on_hang_threads.end()); |
| 365 EXPECT_TRUE(crash_on_hang); | 366 EXPECT_TRUE(crash_on_hang); |
| 366 EXPECT_LT(0u, it->second.live_threads_threshold); | 367 EXPECT_LT(0u, it->second.live_threads_threshold); |
| 367 EXPECT_LT(0u, it->second.unresponsive_threshold); | 368 EXPECT_LT(0u, it->second.unresponsive_threshold); |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 | 371 |
| 371 TEST_F(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs) { | 372 TEST_F(ThreadWatcherTest, ThreadNamesAndLiveThresholdArgs) { |
| 372 // Setup command_line arguments. | 373 // Setup command_line arguments. |
| 373 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 374 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 374 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, | 375 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, |
| 375 thread_names_and_live_threshold); | 376 thread_names_and_live_threshold); |
| 376 | 377 |
| 377 // Parse command_line arguments. | 378 // Parse command_line arguments. |
| 378 ThreadWatcherList::CrashOnHangThreadMap crash_on_hang_threads; | 379 ThreadWatcherList::CrashOnHangThreadMap crash_on_hang_threads; |
| 379 uint32 unresponsive_threshold; | 380 uint32_t unresponsive_threshold; |
| 380 ThreadWatcherList::ParseCommandLine(command_line, | 381 ThreadWatcherList::ParseCommandLine(command_line, |
| 381 &unresponsive_threshold, | 382 &unresponsive_threshold, |
| 382 &crash_on_hang_threads); | 383 &crash_on_hang_threads); |
| 383 | 384 |
| 384 // Verify the data. | 385 // Verify the data. |
| 385 base::StringTokenizer tokens(thread_names_and_live_threshold, ","); | 386 base::StringTokenizer tokens(thread_names_and_live_threshold, ","); |
| 386 while (tokens.GetNext()) { | 387 while (tokens.GetNext()) { |
| 387 std::vector<base::StringPiece> values = base::SplitStringPiece( | 388 std::vector<base::StringPiece> values = base::SplitStringPiece( |
| 388 tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 389 tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 389 std::string thread_name = values[0].as_string(); | 390 std::string thread_name = values[0].as_string(); |
| 390 | 391 |
| 391 ThreadWatcherList::CrashOnHangThreadMap::iterator it = | 392 ThreadWatcherList::CrashOnHangThreadMap::iterator it = |
| 392 crash_on_hang_threads.find(thread_name); | 393 crash_on_hang_threads.find(thread_name); |
| 393 bool crash_on_hang = (it != crash_on_hang_threads.end()); | 394 bool crash_on_hang = (it != crash_on_hang_threads.end()); |
| 394 EXPECT_TRUE(crash_on_hang); | 395 EXPECT_TRUE(crash_on_hang); |
| 395 EXPECT_EQ(4u, it->second.live_threads_threshold); | 396 EXPECT_EQ(4u, it->second.live_threads_threshold); |
| 396 EXPECT_LT(0u, it->second.unresponsive_threshold); | 397 EXPECT_LT(0u, it->second.unresponsive_threshold); |
| 397 } | 398 } |
| 398 } | 399 } |
| 399 | 400 |
| 400 TEST_F(ThreadWatcherTest, CrashOnHangThreadsAllArgs) { | 401 TEST_F(ThreadWatcherTest, CrashOnHangThreadsAllArgs) { |
| 401 // Setup command_line arguments. | 402 // Setup command_line arguments. |
| 402 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 403 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 403 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, | 404 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, |
| 404 crash_on_hang_thread_data); | 405 crash_on_hang_thread_data); |
| 405 | 406 |
| 406 // Parse command_line arguments. | 407 // Parse command_line arguments. |
| 407 ThreadWatcherList::CrashOnHangThreadMap crash_on_hang_threads; | 408 ThreadWatcherList::CrashOnHangThreadMap crash_on_hang_threads; |
| 408 uint32 unresponsive_threshold; | 409 uint32_t unresponsive_threshold; |
| 409 ThreadWatcherList::ParseCommandLine(command_line, | 410 ThreadWatcherList::ParseCommandLine(command_line, |
| 410 &unresponsive_threshold, | 411 &unresponsive_threshold, |
| 411 &crash_on_hang_threads); | 412 &crash_on_hang_threads); |
| 412 | 413 |
| 413 // Verify the data. | 414 // Verify the data. |
| 414 base::StringTokenizer tokens(crash_on_hang_thread_data, ","); | 415 base::StringTokenizer tokens(crash_on_hang_thread_data, ","); |
| 415 while (tokens.GetNext()) { | 416 while (tokens.GetNext()) { |
| 416 std::vector<base::StringPiece> values = base::SplitStringPiece( | 417 std::vector<base::StringPiece> values = base::SplitStringPiece( |
| 417 tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 418 tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 418 std::string thread_name = values[0].as_string(); | 419 std::string thread_name = values[0].as_string(); |
| 419 | 420 |
| 420 ThreadWatcherList::CrashOnHangThreadMap::iterator it = | 421 ThreadWatcherList::CrashOnHangThreadMap::iterator it = |
| 421 crash_on_hang_threads.find(thread_name); | 422 crash_on_hang_threads.find(thread_name); |
| 422 | 423 |
| 423 bool crash_on_hang = (it != crash_on_hang_threads.end()); | 424 bool crash_on_hang = (it != crash_on_hang_threads.end()); |
| 424 EXPECT_TRUE(crash_on_hang); | 425 EXPECT_TRUE(crash_on_hang); |
| 425 | 426 |
| 426 uint32 crash_live_threads_threshold = it->second.live_threads_threshold; | 427 uint32_t crash_live_threads_threshold = it->second.live_threads_threshold; |
| 427 EXPECT_EQ(5u, crash_live_threads_threshold); | 428 EXPECT_EQ(5u, crash_live_threads_threshold); |
| 428 | 429 |
| 429 uint32 crash_unresponsive_threshold = it->second.unresponsive_threshold; | 430 uint32_t crash_unresponsive_threshold = it->second.unresponsive_threshold; |
| 430 uint32 crash_on_unresponsive_seconds = | 431 uint32_t crash_on_unresponsive_seconds = |
| 431 ThreadWatcherList::kUnresponsiveSeconds * crash_unresponsive_threshold; | 432 ThreadWatcherList::kUnresponsiveSeconds * crash_unresponsive_threshold; |
| 432 EXPECT_EQ(12u, crash_on_unresponsive_seconds); | 433 EXPECT_EQ(12u, crash_on_unresponsive_seconds); |
| 433 } | 434 } |
| 434 } | 435 } |
| 435 | 436 |
| 436 // Test registration. When thread_watcher_list_ goes out of scope after | 437 // Test registration. When thread_watcher_list_ goes out of scope after |
| 437 // TearDown, all thread watcher objects will be deleted. | 438 // TearDown, all thread watcher objects will be deleted. |
| 438 TEST_F(ThreadWatcherTest, Registration) { | 439 TEST_F(ThreadWatcherTest, Registration) { |
| 439 // Check ThreadWatcher object has all correct parameters. | 440 // Check ThreadWatcher object has all correct parameters. |
| 440 EXPECT_EQ(io_thread_id, io_watcher_->thread_id()); | 441 EXPECT_EQ(io_thread_id, io_watcher_->thread_id()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 461 // Activate watching IO thread. | 462 // Activate watching IO thread. |
| 462 WatchDogThread::PostTask( | 463 WatchDogThread::PostTask( |
| 463 FROM_HERE, | 464 FROM_HERE, |
| 464 base::Bind(&ThreadWatcher::ActivateThreadWatching, | 465 base::Bind(&ThreadWatcher::ActivateThreadWatching, |
| 465 base::Unretained(io_watcher_))); | 466 base::Unretained(io_watcher_))); |
| 466 | 467 |
| 467 // Activate would have started ping/pong messaging. Expect atleast one | 468 // Activate would have started ping/pong messaging. Expect atleast one |
| 468 // ping/pong messaging sequence to happen. | 469 // ping/pong messaging sequence to happen. |
| 469 io_watcher_->WaitForStateChange(kSleepTime + TimeDelta::FromMinutes(1), | 470 io_watcher_->WaitForStateChange(kSleepTime + TimeDelta::FromMinutes(1), |
| 470 RECEIVED_PONG); | 471 RECEIVED_PONG); |
| 471 EXPECT_GT(io_watcher_->ping_sent_, static_cast<uint64>(0)); | 472 EXPECT_GT(io_watcher_->ping_sent_, static_cast<uint64_t>(0)); |
| 472 EXPECT_GT(io_watcher_->pong_received_, static_cast<uint64>(0)); | 473 EXPECT_GT(io_watcher_->pong_received_, static_cast<uint64_t>(0)); |
| 473 EXPECT_TRUE(io_watcher_->active()); | 474 EXPECT_TRUE(io_watcher_->active()); |
| 474 EXPECT_GE(io_watcher_->saved_ping_time_, time_before_ping); | 475 EXPECT_GE(io_watcher_->saved_ping_time_, time_before_ping); |
| 475 EXPECT_GE(io_watcher_->saved_ping_sequence_number_, static_cast<uint64>(0)); | 476 EXPECT_GE(io_watcher_->saved_ping_sequence_number_, static_cast<uint64_t>(0)); |
| 476 | 477 |
| 477 // Verify watched thread is responding with ping/pong messaging. | 478 // Verify watched thread is responding with ping/pong messaging. |
| 478 io_watcher_->WaitForCheckResponse( | 479 io_watcher_->WaitForCheckResponse( |
| 479 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); | 480 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); |
| 480 EXPECT_GT(base::subtle::NoBarrier_Load(&(io_watcher_->success_response_)), | 481 EXPECT_GT(base::subtle::NoBarrier_Load(&(io_watcher_->success_response_)), |
| 481 static_cast<base::subtle::Atomic32>(0)); | 482 static_cast<base::subtle::Atomic32>(0)); |
| 482 EXPECT_EQ(base::subtle::NoBarrier_Load(&(io_watcher_->failed_response_)), | 483 EXPECT_EQ(base::subtle::NoBarrier_Load(&(io_watcher_->failed_response_)), |
| 483 static_cast<base::subtle::Atomic32>(0)); | 484 static_cast<base::subtle::Atomic32>(0)); |
| 484 | 485 |
| 485 // DeActivate thread watching for shutdown. | 486 // DeActivate thread watching for shutdown. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 540 |
| 540 // Check for IO thread to perform ping/pong messaging. | 541 // Check for IO thread to perform ping/pong messaging. |
| 541 WatchDogThread::PostTask( | 542 WatchDogThread::PostTask( |
| 542 FROM_HERE, | 543 FROM_HERE, |
| 543 base::Bind(&ThreadWatcher::ActivateThreadWatching, | 544 base::Bind(&ThreadWatcher::ActivateThreadWatching, |
| 544 base::Unretained(io_watcher_))); | 545 base::Unretained(io_watcher_))); |
| 545 | 546 |
| 546 // Verify DB thread is responding with ping/pong messaging. | 547 // Verify DB thread is responding with ping/pong messaging. |
| 547 db_watcher_->WaitForCheckResponse( | 548 db_watcher_->WaitForCheckResponse( |
| 548 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); | 549 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); |
| 549 EXPECT_GT(db_watcher_->ping_sent_, static_cast<uint64>(0)); | 550 EXPECT_GT(db_watcher_->ping_sent_, static_cast<uint64_t>(0)); |
| 550 EXPECT_GT(db_watcher_->pong_received_, static_cast<uint64>(0)); | 551 EXPECT_GT(db_watcher_->pong_received_, static_cast<uint64_t>(0)); |
| 551 EXPECT_GE(db_watcher_->ping_sequence_number_, static_cast<uint64>(0)); | 552 EXPECT_GE(db_watcher_->ping_sequence_number_, static_cast<uint64_t>(0)); |
| 552 EXPECT_GT(base::subtle::NoBarrier_Load(&(db_watcher_->success_response_)), | 553 EXPECT_GT(base::subtle::NoBarrier_Load(&(db_watcher_->success_response_)), |
| 553 static_cast<base::subtle::Atomic32>(0)); | 554 static_cast<base::subtle::Atomic32>(0)); |
| 554 EXPECT_EQ(base::subtle::NoBarrier_Load(&(db_watcher_->failed_response_)), | 555 EXPECT_EQ(base::subtle::NoBarrier_Load(&(db_watcher_->failed_response_)), |
| 555 static_cast<base::subtle::Atomic32>(0)); | 556 static_cast<base::subtle::Atomic32>(0)); |
| 556 | 557 |
| 557 // Verify IO thread is responding with ping/pong messaging. | 558 // Verify IO thread is responding with ping/pong messaging. |
| 558 io_watcher_->WaitForCheckResponse( | 559 io_watcher_->WaitForCheckResponse( |
| 559 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); | 560 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); |
| 560 EXPECT_GT(io_watcher_->ping_sent_, static_cast<uint64>(0)); | 561 EXPECT_GT(io_watcher_->ping_sent_, static_cast<uint64_t>(0)); |
| 561 EXPECT_GT(io_watcher_->pong_received_, static_cast<uint64>(0)); | 562 EXPECT_GT(io_watcher_->pong_received_, static_cast<uint64_t>(0)); |
| 562 EXPECT_GE(io_watcher_->ping_sequence_number_, static_cast<uint64>(0)); | 563 EXPECT_GE(io_watcher_->ping_sequence_number_, static_cast<uint64_t>(0)); |
| 563 EXPECT_GT(base::subtle::NoBarrier_Load(&(io_watcher_->success_response_)), | 564 EXPECT_GT(base::subtle::NoBarrier_Load(&(io_watcher_->success_response_)), |
| 564 static_cast<base::subtle::Atomic32>(0)); | 565 static_cast<base::subtle::Atomic32>(0)); |
| 565 EXPECT_EQ(base::subtle::NoBarrier_Load(&(io_watcher_->failed_response_)), | 566 EXPECT_EQ(base::subtle::NoBarrier_Load(&(io_watcher_->failed_response_)), |
| 566 static_cast<base::subtle::Atomic32>(0)); | 567 static_cast<base::subtle::Atomic32>(0)); |
| 567 | 568 |
| 568 // DeActivate thread watching for shutdown. | 569 // DeActivate thread watching for shutdown. |
| 569 WatchDogThread::PostTask( | 570 WatchDogThread::PostTask( |
| 570 FROM_HERE, | 571 FROM_HERE, |
| 571 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 572 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
| 572 base::Unretained(io_watcher_))); | 573 base::Unretained(io_watcher_))); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 } | 810 } |
| 810 | 811 |
| 811 TEST_F(JankTimeBombTest, ArmTest) { | 812 TEST_F(JankTimeBombTest, ArmTest) { |
| 812 // Test firing of Alarm by passing empty delay. | 813 // Test firing of Alarm by passing empty delay. |
| 813 TestingJankTimeBomb timebomb((base::TimeDelta())); | 814 TestingJankTimeBomb timebomb((base::TimeDelta())); |
| 814 if (!timebomb.IsEnabled()) | 815 if (!timebomb.IsEnabled()) |
| 815 return; | 816 return; |
| 816 WaitForWatchDogThreadPostTask(); | 817 WaitForWatchDogThreadPostTask(); |
| 817 EXPECT_TRUE(timebomb.alarm_invoked()); | 818 EXPECT_TRUE(timebomb.alarm_invoked()); |
| 818 } | 819 } |
| OLD | NEW |