OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 static const std::string crash_on_hang_threads; | 244 static const std::string crash_on_hang_threads; |
245 static const std::string crash_on_live; | 245 static const std::string crash_on_live; |
246 CustomThreadWatcher* io_watcher_; | 246 CustomThreadWatcher* io_watcher_; |
247 CustomThreadWatcher* webkit_watcher_; | 247 CustomThreadWatcher* webkit_watcher_; |
248 ThreadWatcherList* thread_watcher_list_; | 248 ThreadWatcherList* thread_watcher_list_; |
249 | 249 |
250 ThreadWatcherTest() | 250 ThreadWatcherTest() |
251 : setup_complete_(&lock_), | 251 : setup_complete_(&lock_), |
252 initialized_(false) { | 252 initialized_(false) { |
253 webkit_thread_.reset(new content::TestBrowserThread( | 253 webkit_thread_.reset(new content::TestBrowserThread( |
254 BrowserThread::WEBKIT)); | 254 BrowserThread::WEBKIT_DEPRECATED)); |
255 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); | 255 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); |
256 watchdog_thread_.reset(new WatchDogThread()); | 256 watchdog_thread_.reset(new WatchDogThread()); |
257 webkit_thread_->Start(); | 257 webkit_thread_->Start(); |
258 io_thread_->Start(); | 258 io_thread_->Start(); |
259 watchdog_thread_->Start(); | 259 watchdog_thread_->Start(); |
260 | 260 |
261 WatchDogThread::PostTask( | 261 WatchDogThread::PostTask( |
262 FROM_HERE, | 262 FROM_HERE, |
263 base::Bind(&ThreadWatcherTest::SetUpObjects, base::Unretained(this))); | 263 base::Bind(&ThreadWatcherTest::SetUpObjects, base::Unretained(this))); |
264 | 264 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherTest); | 322 DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherTest); |
323 | 323 |
324 // Define static constants. | 324 // Define static constants. |
325 const TimeDelta ThreadWatcherTest::kSleepTime = | 325 const TimeDelta ThreadWatcherTest::kSleepTime = |
326 TimeDelta::FromMilliseconds(50); | 326 TimeDelta::FromMilliseconds(50); |
327 const TimeDelta ThreadWatcherTest::kUnresponsiveTime = | 327 const TimeDelta ThreadWatcherTest::kUnresponsiveTime = |
328 TimeDelta::FromMilliseconds(500); | 328 TimeDelta::FromMilliseconds(500); |
329 const BrowserThread::ID ThreadWatcherTest::io_thread_id = BrowserThread::IO; | 329 const BrowserThread::ID ThreadWatcherTest::io_thread_id = BrowserThread::IO; |
330 const std::string ThreadWatcherTest::io_thread_name = "IO"; | 330 const std::string ThreadWatcherTest::io_thread_name = "IO"; |
331 const BrowserThread::ID ThreadWatcherTest::webkit_thread_id = | 331 const BrowserThread::ID ThreadWatcherTest::webkit_thread_id = |
332 BrowserThread::WEBKIT; | 332 BrowserThread::WEBKIT_DEPRECATED; |
333 const std::string ThreadWatcherTest::webkit_thread_name = "WEBKIT"; | 333 const std::string ThreadWatcherTest::webkit_thread_name = "WEBKIT"; |
334 const std::string ThreadWatcherTest::crash_on_hang_seconds = "24"; | 334 const std::string ThreadWatcherTest::crash_on_hang_seconds = "24"; |
335 const std::string ThreadWatcherTest::crash_on_hang_threads = "IO,UI"; | 335 const std::string ThreadWatcherTest::crash_on_hang_threads = "IO,UI"; |
336 const std::string ThreadWatcherTest::crash_on_live = "3"; | 336 const std::string ThreadWatcherTest::crash_on_live = "3"; |
337 | 337 |
338 TEST_F(ThreadWatcherTest, CommandLineArgs) { | 338 TEST_F(ThreadWatcherTest, CommandLineArgs) { |
339 // Setup command_line arguments. | 339 // Setup command_line arguments. |
340 CommandLine command_line(CommandLine::NO_PROGRAM); | 340 CommandLine command_line(CommandLine::NO_PROGRAM); |
341 command_line.AppendSwitchASCII(switches::kCrashOnHangSeconds, | 341 command_line.AppendSwitchASCII(switches::kCrashOnHangSeconds, |
342 crash_on_hang_seconds); | 342 crash_on_hang_seconds); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 553 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
554 base::Unretained(io_watcher_))); | 554 base::Unretained(io_watcher_))); |
555 WatchDogThread::PostTask( | 555 WatchDogThread::PostTask( |
556 FROM_HERE, | 556 FROM_HERE, |
557 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 557 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
558 base::Unretained(webkit_watcher_))); | 558 base::Unretained(webkit_watcher_))); |
559 | 559 |
560 // Wait for the io_watcher_'s VeryLongMethod to finish. | 560 // Wait for the io_watcher_'s VeryLongMethod to finish. |
561 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); | 561 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); |
562 } | 562 } |
OLD | NEW |