Chromium Code Reviews| 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 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 return exit_state; | 231 return exit_state; |
| 232 } | 232 } |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 class ThreadWatcherTest : public ::testing::Test { | 235 class ThreadWatcherTest : public ::testing::Test { |
| 236 public: | 236 public: |
| 237 static const TimeDelta kSleepTime; | 237 static const TimeDelta kSleepTime; |
| 238 static const TimeDelta kUnresponsiveTime; | 238 static const TimeDelta kUnresponsiveTime; |
| 239 static const BrowserThread::ID io_thread_id; | 239 static const BrowserThread::ID io_thread_id; |
| 240 static const std::string io_thread_name; | 240 static const std::string io_thread_name; |
| 241 static const BrowserThread::ID webkit_thread_id; | 241 static const BrowserThread::ID db_thread_id; |
| 242 static const std::string webkit_thread_name; | 242 static const std::string db_thread_name; |
| 243 static const std::string crash_on_hang_seconds; | 243 static const std::string crash_on_hang_seconds; |
| 244 static const std::string crash_on_hang_thread_names; | 244 static const std::string crash_on_hang_thread_names; |
| 245 static const std::string thread_names_and_live_threshold; | 245 static const std::string thread_names_and_live_threshold; |
| 246 static const std::string crash_on_hang_thread_data; | 246 static const std::string crash_on_hang_thread_data; |
| 247 CustomThreadWatcher* io_watcher_; | 247 CustomThreadWatcher* io_watcher_; |
| 248 CustomThreadWatcher* webkit_watcher_; | 248 CustomThreadWatcher* db_watcher_; |
| 249 ThreadWatcherList* thread_watcher_list_; | 249 ThreadWatcherList* thread_watcher_list_; |
| 250 | 250 |
| 251 ThreadWatcherTest() | 251 ThreadWatcherTest() |
| 252 : setup_complete_(&lock_), | 252 : setup_complete_(&lock_), |
| 253 initialized_(false) { | 253 initialized_(false) { |
| 254 webkit_thread_.reset(new content::TestBrowserThread( | 254 db_thread_.reset(new content::TestBrowserThread(BrowserThread::DB)); |
| 255 BrowserThread::WEBKIT_DEPRECATED)); | |
| 256 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); | 255 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); |
| 257 watchdog_thread_.reset(new WatchDogThread()); | 256 watchdog_thread_.reset(new WatchDogThread()); |
| 258 webkit_thread_->Start(); | 257 db_thread_->Start(); |
| 259 io_thread_->Start(); | 258 io_thread_->Start(); |
| 260 watchdog_thread_->Start(); | 259 watchdog_thread_->Start(); |
| 261 | 260 |
| 262 WatchDogThread::PostTask( | 261 WatchDogThread::PostTask( |
| 263 FROM_HERE, | 262 FROM_HERE, |
| 264 base::Bind(&ThreadWatcherTest::SetUpObjects, base::Unretained(this))); | 263 base::Bind(&ThreadWatcherTest::SetUpObjects, base::Unretained(this))); |
| 265 | 264 |
| 266 WaitForSetUp(TimeDelta::FromMinutes(1)); | 265 WaitForSetUp(TimeDelta::FromMinutes(1)); |
| 267 } | 266 } |
| 268 | 267 |
| 269 void SetUpObjects() { | 268 void SetUpObjects() { |
| 270 DCHECK(WatchDogThread::CurrentlyOnWatchDogThread()); | 269 DCHECK(WatchDogThread::CurrentlyOnWatchDogThread()); |
| 271 | 270 |
| 272 // Setup the registry for thread watchers. | 271 // Setup the registry for thread watchers. |
| 273 thread_watcher_list_ = new ThreadWatcherList(); | 272 thread_watcher_list_ = new ThreadWatcherList(); |
| 274 | 273 |
| 275 // Create thread watcher object for the IO thread. | 274 // Create thread watcher object for the IO thread. |
| 276 io_watcher_ = new CustomThreadWatcher(io_thread_id, io_thread_name, | 275 io_watcher_ = new CustomThreadWatcher(io_thread_id, io_thread_name, |
| 277 kSleepTime, kUnresponsiveTime); | 276 kSleepTime, kUnresponsiveTime); |
| 278 EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(io_thread_id)); | 277 EXPECT_EQ(io_watcher_, thread_watcher_list_->Find(io_thread_id)); |
| 279 | 278 |
| 280 // Create thread watcher object for the WEBKIT thread. | 279 // Create thread watcher object for the DB thread. |
|
jam
2013/07/19 15:33:25
are you sure that the DB thread wasn't watched on
jam
2013/07/19 20:41:00
argh, i missed that this was a test! nvm
| |
| 281 webkit_watcher_ = new CustomThreadWatcher( | 280 db_watcher_ = new CustomThreadWatcher( |
| 282 webkit_thread_id, webkit_thread_name, kSleepTime, kUnresponsiveTime); | 281 db_thread_id, db_thread_name, kSleepTime, kUnresponsiveTime); |
| 283 EXPECT_EQ(webkit_watcher_, thread_watcher_list_->Find(webkit_thread_id)); | 282 EXPECT_EQ(db_watcher_, thread_watcher_list_->Find(db_thread_id)); |
| 284 | 283 |
| 285 { | 284 { |
| 286 base::AutoLock lock(lock_); | 285 base::AutoLock lock(lock_); |
| 287 initialized_ = true; | 286 initialized_ = true; |
| 288 } | 287 } |
| 289 setup_complete_.Signal(); | 288 setup_complete_.Signal(); |
| 290 } | 289 } |
| 291 | 290 |
| 292 void WaitForSetUp(TimeDelta wait_time) { | 291 void WaitForSetUp(TimeDelta wait_time) { |
| 293 DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread()); | 292 DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread()); |
| 294 TimeTicks end_time = TimeTicks::Now() + wait_time; | 293 TimeTicks end_time = TimeTicks::Now() + wait_time; |
| 295 { | 294 { |
| 296 base::AutoLock auto_lock(lock_); | 295 base::AutoLock auto_lock(lock_); |
| 297 while (!initialized_ && TimeTicks::Now() < end_time) | 296 while (!initialized_ && TimeTicks::Now() < end_time) |
| 298 setup_complete_.TimedWait(end_time - TimeTicks::Now()); | 297 setup_complete_.TimedWait(end_time - TimeTicks::Now()); |
| 299 } | 298 } |
| 300 } | 299 } |
| 301 | 300 |
| 302 virtual ~ThreadWatcherTest() { | 301 virtual ~ThreadWatcherTest() { |
| 303 ThreadWatcherList::DeleteAll(); | 302 ThreadWatcherList::DeleteAll(); |
| 304 io_watcher_ = NULL; | 303 io_watcher_ = NULL; |
| 305 webkit_watcher_ = NULL; | 304 db_watcher_ = NULL; |
| 306 io_thread_.reset(); | 305 io_thread_.reset(); |
| 307 webkit_thread_.reset(); | 306 db_thread_.reset(); |
| 308 watchdog_thread_.reset(); | 307 watchdog_thread_.reset(); |
| 309 thread_watcher_list_ = NULL; | 308 thread_watcher_list_ = NULL; |
| 310 } | 309 } |
| 311 | 310 |
| 312 private: | 311 private: |
| 313 base::Lock lock_; | 312 base::Lock lock_; |
| 314 base::ConditionVariable setup_complete_; | 313 base::ConditionVariable setup_complete_; |
| 315 bool initialized_; | 314 bool initialized_; |
| 316 scoped_ptr<content::TestBrowserThread> webkit_thread_; | 315 scoped_ptr<content::TestBrowserThread> db_thread_; |
| 317 scoped_ptr<content::TestBrowserThread> io_thread_; | 316 scoped_ptr<content::TestBrowserThread> io_thread_; |
| 318 scoped_ptr<WatchDogThread> watchdog_thread_; | 317 scoped_ptr<WatchDogThread> watchdog_thread_; |
| 319 }; | 318 }; |
| 320 | 319 |
| 321 // Define static constants. | 320 // Define static constants. |
| 322 const TimeDelta ThreadWatcherTest::kSleepTime = | 321 const TimeDelta ThreadWatcherTest::kSleepTime = |
| 323 TimeDelta::FromMilliseconds(50); | 322 TimeDelta::FromMilliseconds(50); |
| 324 const TimeDelta ThreadWatcherTest::kUnresponsiveTime = | 323 const TimeDelta ThreadWatcherTest::kUnresponsiveTime = |
| 325 TimeDelta::FromMilliseconds(500); | 324 TimeDelta::FromMilliseconds(500); |
| 326 const BrowserThread::ID ThreadWatcherTest::io_thread_id = BrowserThread::IO; | 325 const BrowserThread::ID ThreadWatcherTest::io_thread_id = BrowserThread::IO; |
| 327 const std::string ThreadWatcherTest::io_thread_name = "IO"; | 326 const std::string ThreadWatcherTest::io_thread_name = "IO"; |
| 328 const BrowserThread::ID ThreadWatcherTest::webkit_thread_id = | 327 const BrowserThread::ID ThreadWatcherTest::db_thread_id = BrowserThread::DB; |
| 329 BrowserThread::WEBKIT_DEPRECATED; | 328 const std::string ThreadWatcherTest::db_thread_name = "DB"; |
| 330 const std::string ThreadWatcherTest::webkit_thread_name = "WEBKIT"; | |
| 331 const std::string ThreadWatcherTest::crash_on_hang_thread_names = "UI,IO"; | 329 const std::string ThreadWatcherTest::crash_on_hang_thread_names = "UI,IO"; |
| 332 const std::string ThreadWatcherTest::thread_names_and_live_threshold = | 330 const std::string ThreadWatcherTest::thread_names_and_live_threshold = |
| 333 "UI:4,IO:4"; | 331 "UI:4,IO:4"; |
| 334 const std::string ThreadWatcherTest::crash_on_hang_thread_data = | 332 const std::string ThreadWatcherTest::crash_on_hang_thread_data = |
| 335 "UI:5:12,IO:5:12,FILE:5:12"; | 333 "UI:5:12,IO:5:12,FILE:5:12"; |
| 336 | 334 |
| 337 TEST_F(ThreadWatcherTest, ThreadNamesOnlyArgs) { | 335 TEST_F(ThreadWatcherTest, ThreadNamesOnlyArgs) { |
| 338 // Setup command_line arguments. | 336 // Setup command_line arguments. |
| 339 CommandLine command_line(CommandLine::NO_PROGRAM); | 337 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 340 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, | 338 command_line.AppendSwitchASCII(switches::kCrashOnHangThreads, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 // Test registration. When thread_watcher_list_ goes out of scope after | 432 // Test registration. When thread_watcher_list_ goes out of scope after |
| 435 // TearDown, all thread watcher objects will be deleted. | 433 // TearDown, all thread watcher objects will be deleted. |
| 436 TEST_F(ThreadWatcherTest, Registration) { | 434 TEST_F(ThreadWatcherTest, Registration) { |
| 437 // Check ThreadWatcher object has all correct parameters. | 435 // Check ThreadWatcher object has all correct parameters. |
| 438 EXPECT_EQ(io_thread_id, io_watcher_->thread_id()); | 436 EXPECT_EQ(io_thread_id, io_watcher_->thread_id()); |
| 439 EXPECT_EQ(io_thread_name, io_watcher_->thread_name()); | 437 EXPECT_EQ(io_thread_name, io_watcher_->thread_name()); |
| 440 EXPECT_EQ(kSleepTime, io_watcher_->sleep_time()); | 438 EXPECT_EQ(kSleepTime, io_watcher_->sleep_time()); |
| 441 EXPECT_EQ(kUnresponsiveTime, io_watcher_->unresponsive_time()); | 439 EXPECT_EQ(kUnresponsiveTime, io_watcher_->unresponsive_time()); |
| 442 EXPECT_FALSE(io_watcher_->active()); | 440 EXPECT_FALSE(io_watcher_->active()); |
| 443 | 441 |
| 444 // Check ThreadWatcher object of watched WEBKIT thread has correct data. | 442 // Check ThreadWatcher object of watched DB thread has correct data. |
| 445 EXPECT_EQ(webkit_thread_id, webkit_watcher_->thread_id()); | 443 EXPECT_EQ(db_thread_id, db_watcher_->thread_id()); |
| 446 EXPECT_EQ(webkit_thread_name, webkit_watcher_->thread_name()); | 444 EXPECT_EQ(db_thread_name, db_watcher_->thread_name()); |
| 447 EXPECT_EQ(kSleepTime, webkit_watcher_->sleep_time()); | 445 EXPECT_EQ(kSleepTime, db_watcher_->sleep_time()); |
| 448 EXPECT_EQ(kUnresponsiveTime, webkit_watcher_->unresponsive_time()); | 446 EXPECT_EQ(kUnresponsiveTime, db_watcher_->unresponsive_time()); |
| 449 EXPECT_FALSE(webkit_watcher_->active()); | 447 EXPECT_FALSE(db_watcher_->active()); |
| 450 } | 448 } |
| 451 | 449 |
| 452 // Test ActivateThreadWatching and DeActivateThreadWatching of IO thread. This | 450 // Test ActivateThreadWatching and DeActivateThreadWatching of IO thread. This |
| 453 // method also checks that pong message was sent by the watched thread and pong | 451 // method also checks that pong message was sent by the watched thread and pong |
| 454 // message was received by the WatchDogThread. It also checks that | 452 // message was received by the WatchDogThread. It also checks that |
| 455 // OnCheckResponsiveness has verified the ping-pong mechanism and the watched | 453 // OnCheckResponsiveness has verified the ping-pong mechanism and the watched |
| 456 // thread is not hung. | 454 // thread is not hung. |
| 457 TEST_F(ThreadWatcherTest, ThreadResponding) { | 455 TEST_F(ThreadWatcherTest, ThreadResponding) { |
| 458 TimeTicks time_before_ping = TimeTicks::Now(); | 456 TimeTicks time_before_ping = TimeTicks::Now(); |
| 459 // Activate watching IO thread. | 457 // Activate watching IO thread. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 FROM_HERE, | 516 FROM_HERE, |
| 519 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 517 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
| 520 base::Unretained(io_watcher_))); | 518 base::Unretained(io_watcher_))); |
| 521 | 519 |
| 522 // Wait for the io_watcher_'s VeryLongMethod to finish. | 520 // Wait for the io_watcher_'s VeryLongMethod to finish. |
| 523 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); | 521 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); |
| 524 } | 522 } |
| 525 | 523 |
| 526 // Test watching of multiple threads with all threads not responding. | 524 // Test watching of multiple threads with all threads not responding. |
| 527 TEST_F(ThreadWatcherTest, MultipleThreadsResponding) { | 525 TEST_F(ThreadWatcherTest, MultipleThreadsResponding) { |
| 528 // Check for WEBKIT thread to perform ping/pong messaging. | 526 // Check for DB thread to perform ping/pong messaging. |
| 529 WatchDogThread::PostTask( | 527 WatchDogThread::PostTask( |
| 530 FROM_HERE, | 528 FROM_HERE, |
| 531 base::Bind(&ThreadWatcher::ActivateThreadWatching, | 529 base::Bind(&ThreadWatcher::ActivateThreadWatching, |
| 532 base::Unretained(webkit_watcher_))); | 530 base::Unretained(db_watcher_))); |
| 533 | 531 |
| 534 // Check for IO thread to perform ping/pong messaging. | 532 // Check for IO thread to perform ping/pong messaging. |
| 535 WatchDogThread::PostTask( | 533 WatchDogThread::PostTask( |
| 536 FROM_HERE, | 534 FROM_HERE, |
| 537 base::Bind(&ThreadWatcher::ActivateThreadWatching, | 535 base::Bind(&ThreadWatcher::ActivateThreadWatching, |
| 538 base::Unretained(io_watcher_))); | 536 base::Unretained(io_watcher_))); |
| 539 | 537 |
| 540 // Verify WEBKIT thread is responding with ping/pong messaging. | 538 // Verify DB thread is responding with ping/pong messaging. |
| 541 webkit_watcher_->WaitForCheckResponse( | 539 db_watcher_->WaitForCheckResponse( |
| 542 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); | 540 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); |
| 543 EXPECT_GT(webkit_watcher_->ping_sent_, static_cast<uint64>(0)); | 541 EXPECT_GT(db_watcher_->ping_sent_, static_cast<uint64>(0)); |
| 544 EXPECT_GT(webkit_watcher_->pong_received_, static_cast<uint64>(0)); | 542 EXPECT_GT(db_watcher_->pong_received_, static_cast<uint64>(0)); |
| 545 EXPECT_GE(webkit_watcher_->ping_sequence_number_, static_cast<uint64>(0)); | 543 EXPECT_GE(db_watcher_->ping_sequence_number_, static_cast<uint64>(0)); |
| 546 EXPECT_GT(webkit_watcher_->success_response_, static_cast<uint64>(0)); | 544 EXPECT_GT(db_watcher_->success_response_, static_cast<uint64>(0)); |
| 547 EXPECT_EQ(webkit_watcher_->failed_response_, static_cast<uint64>(0)); | 545 EXPECT_EQ(db_watcher_->failed_response_, static_cast<uint64>(0)); |
| 548 | 546 |
| 549 // Verify IO thread is responding with ping/pong messaging. | 547 // Verify IO thread is responding with ping/pong messaging. |
| 550 io_watcher_->WaitForCheckResponse( | 548 io_watcher_->WaitForCheckResponse( |
| 551 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); | 549 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); |
| 552 EXPECT_GT(io_watcher_->ping_sent_, static_cast<uint64>(0)); | 550 EXPECT_GT(io_watcher_->ping_sent_, static_cast<uint64>(0)); |
| 553 EXPECT_GT(io_watcher_->pong_received_, static_cast<uint64>(0)); | 551 EXPECT_GT(io_watcher_->pong_received_, static_cast<uint64>(0)); |
| 554 EXPECT_GE(io_watcher_->ping_sequence_number_, static_cast<uint64>(0)); | 552 EXPECT_GE(io_watcher_->ping_sequence_number_, static_cast<uint64>(0)); |
| 555 EXPECT_GT(io_watcher_->success_response_, static_cast<uint64>(0)); | 553 EXPECT_GT(io_watcher_->success_response_, static_cast<uint64>(0)); |
| 556 EXPECT_EQ(io_watcher_->failed_response_, static_cast<uint64>(0)); | 554 EXPECT_EQ(io_watcher_->failed_response_, static_cast<uint64>(0)); |
| 557 | 555 |
| 558 // DeActivate thread watching for shutdown. | 556 // DeActivate thread watching for shutdown. |
| 559 WatchDogThread::PostTask( | 557 WatchDogThread::PostTask( |
| 560 FROM_HERE, | 558 FROM_HERE, |
| 561 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 559 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
| 562 base::Unretained(io_watcher_))); | 560 base::Unretained(io_watcher_))); |
| 563 | 561 |
| 564 WatchDogThread::PostTask( | 562 WatchDogThread::PostTask( |
| 565 FROM_HERE, | 563 FROM_HERE, |
| 566 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 564 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
| 567 base::Unretained(webkit_watcher_))); | 565 base::Unretained(db_watcher_))); |
| 568 } | 566 } |
| 569 | 567 |
| 570 // Test watching of multiple threads with one of the threads not responding. | 568 // Test watching of multiple threads with one of the threads not responding. |
| 571 TEST_F(ThreadWatcherTest, MultipleThreadsNotResponding) { | 569 TEST_F(ThreadWatcherTest, MultipleThreadsNotResponding) { |
| 572 // Simulate hanging of watched thread by making the watched thread wait for a | 570 // Simulate hanging of watched thread by making the watched thread wait for a |
| 573 // very long time by posting a task on watched thread that keeps it busy. | 571 // very long time by posting a task on watched thread that keeps it busy. |
| 574 // It is safe ot use base::Unretained because test is waiting for the method | 572 // It is safe ot use base::Unretained because test is waiting for the method |
| 575 // to finish. | 573 // to finish. |
| 576 BrowserThread::PostTask( | 574 BrowserThread::PostTask( |
| 577 io_thread_id, | 575 io_thread_id, |
| 578 FROM_HERE, | 576 FROM_HERE, |
| 579 base::Bind(&CustomThreadWatcher::VeryLongMethod, | 577 base::Bind(&CustomThreadWatcher::VeryLongMethod, |
| 580 base::Unretained(io_watcher_), | 578 base::Unretained(io_watcher_), |
| 581 kUnresponsiveTime * 10)); | 579 kUnresponsiveTime * 10)); |
| 582 | 580 |
| 583 // Activate watching of WEBKIT thread. | 581 // Activate watching of DB thread. |
| 584 WatchDogThread::PostTask( | 582 WatchDogThread::PostTask( |
| 585 FROM_HERE, | 583 FROM_HERE, |
| 586 base::Bind(&ThreadWatcher::ActivateThreadWatching, | 584 base::Bind(&ThreadWatcher::ActivateThreadWatching, |
| 587 base::Unretained(webkit_watcher_))); | 585 base::Unretained(db_watcher_))); |
| 588 | 586 |
| 589 // Activate watching of IO thread. | 587 // Activate watching of IO thread. |
| 590 WatchDogThread::PostTask( | 588 WatchDogThread::PostTask( |
| 591 FROM_HERE, | 589 FROM_HERE, |
| 592 base::Bind(&ThreadWatcher::ActivateThreadWatching, | 590 base::Bind(&ThreadWatcher::ActivateThreadWatching, |
| 593 base::Unretained(io_watcher_))); | 591 base::Unretained(io_watcher_))); |
| 594 | 592 |
| 595 // Verify WEBKIT thread is responding with ping/pong messaging. | 593 // Verify DB thread is responding with ping/pong messaging. |
| 596 webkit_watcher_->WaitForCheckResponse( | 594 db_watcher_->WaitForCheckResponse( |
| 597 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); | 595 kUnresponsiveTime + TimeDelta::FromMinutes(1), SUCCESSFUL); |
| 598 EXPECT_GT(webkit_watcher_->success_response_, static_cast<uint64>(0)); | 596 EXPECT_GT(db_watcher_->success_response_, static_cast<uint64>(0)); |
| 599 EXPECT_EQ(webkit_watcher_->failed_response_, static_cast<uint64>(0)); | 597 EXPECT_EQ(db_watcher_->failed_response_, static_cast<uint64>(0)); |
| 600 | 598 |
| 601 // Verify IO thread is not responding for ping messages. | 599 // Verify IO thread is not responding for ping messages. |
| 602 io_watcher_->WaitForCheckResponse( | 600 io_watcher_->WaitForCheckResponse( |
| 603 kUnresponsiveTime + TimeDelta::FromMinutes(1), FAILED); | 601 kUnresponsiveTime + TimeDelta::FromMinutes(1), FAILED); |
| 604 EXPECT_EQ(io_watcher_->success_response_, static_cast<uint64>(0)); | 602 EXPECT_EQ(io_watcher_->success_response_, static_cast<uint64>(0)); |
| 605 EXPECT_GT(io_watcher_->failed_response_, static_cast<uint64>(0)); | 603 EXPECT_GT(io_watcher_->failed_response_, static_cast<uint64>(0)); |
| 606 | 604 |
| 607 // DeActivate thread watching for shutdown. | 605 // DeActivate thread watching for shutdown. |
| 608 WatchDogThread::PostTask( | 606 WatchDogThread::PostTask( |
| 609 FROM_HERE, | 607 FROM_HERE, |
| 610 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 608 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
| 611 base::Unretained(io_watcher_))); | 609 base::Unretained(io_watcher_))); |
| 612 WatchDogThread::PostTask( | 610 WatchDogThread::PostTask( |
| 613 FROM_HERE, | 611 FROM_HERE, |
| 614 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 612 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
| 615 base::Unretained(webkit_watcher_))); | 613 base::Unretained(db_watcher_))); |
| 616 | 614 |
| 617 // Wait for the io_watcher_'s VeryLongMethod to finish. | 615 // Wait for the io_watcher_'s VeryLongMethod to finish. |
| 618 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); | 616 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); |
| 619 } | 617 } |
| OLD | NEW |