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" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_split.h" | 14 #include "base/string_split.h" |
15 #include "base/string_tokenizer.h" | 15 #include "base/strings/string_tokenizer.h" |
16 #include "base/synchronization/condition_variable.h" | 16 #include "base/synchronization/condition_variable.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
19 #include "base/time.h" | 19 #include "base/time.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/browser/metrics/thread_watcher.h" | 21 #include "chrome/browser/metrics/thread_watcher.h" |
22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
23 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "testing/platform_test.h" | 25 #include "testing/platform_test.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 &unresponsive_threshold, | 344 &unresponsive_threshold, |
345 &crash_on_hang_threads); | 345 &crash_on_hang_threads); |
346 | 346 |
347 // Verify the data. | 347 // Verify the data. |
348 uint32 crash_on_unresponsive_seconds = | 348 uint32 crash_on_unresponsive_seconds = |
349 ThreadWatcherList::kUnresponsiveSeconds * unresponsive_threshold; | 349 ThreadWatcherList::kUnresponsiveSeconds * unresponsive_threshold; |
350 EXPECT_EQ(static_cast<int>(crash_on_unresponsive_seconds), | 350 EXPECT_EQ(static_cast<int>(crash_on_unresponsive_seconds), |
351 atoi(crash_on_hang_seconds.c_str())); | 351 atoi(crash_on_hang_seconds.c_str())); |
352 | 352 |
353 // Check ThreadWatcherTestList has the right crash_on_hang_thread_names. | 353 // Check ThreadWatcherTestList has the right crash_on_hang_thread_names. |
354 StringTokenizer tokens(crash_on_hang_thread_names, ","); | 354 base::StringTokenizer tokens(crash_on_hang_thread_names, ","); |
355 std::vector<std::string> values; | 355 std::vector<std::string> values; |
356 while (tokens.GetNext()) { | 356 while (tokens.GetNext()) { |
357 const std::string& token = tokens.token(); | 357 const std::string& token = tokens.token(); |
358 base::SplitString(token, ':', &values); | 358 base::SplitString(token, ':', &values); |
359 if (values.size() != 2) | 359 if (values.size() != 2) |
360 continue; | 360 continue; |
361 std::string thread_name = values[0]; | 361 std::string thread_name = values[0]; |
362 uint32 live_threads_threshold; | 362 uint32 live_threads_threshold; |
363 if (!base::StringToUint(values[1], &live_threads_threshold)) | 363 if (!base::StringToUint(values[1], &live_threads_threshold)) |
364 continue; | 364 continue; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 549 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
550 base::Unretained(io_watcher_))); | 550 base::Unretained(io_watcher_))); |
551 WatchDogThread::PostTask( | 551 WatchDogThread::PostTask( |
552 FROM_HERE, | 552 FROM_HERE, |
553 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 553 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
554 base::Unretained(webkit_watcher_))); | 554 base::Unretained(webkit_watcher_))); |
555 | 555 |
556 // Wait for the io_watcher_'s VeryLongMethod to finish. | 556 // Wait for the io_watcher_'s VeryLongMethod to finish. |
557 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); | 557 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); |
558 } | 558 } |
OLD | NEW |