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" |
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_tokenizer.h" | 13 #include "base/string_tokenizer.h" |
14 #include "base/synchronization/condition_variable.h" | 14 #include "base/synchronization/condition_variable.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/metrics/thread_watcher.h" | 19 #include "chrome/browser/metrics/thread_watcher.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "content/test/test_browser_thread.h" | 21 #include "content/test/test_browser_thread.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "testing/platform_test.h" | 23 #include "testing/platform_test.h" |
24 | 24 |
25 using base::TimeDelta; | 25 using base::TimeDelta; |
26 using base::TimeTicks; | 26 using base::TimeTicks; |
| 27 using content::BrowserThread; |
27 | 28 |
28 enum State { | 29 enum State { |
29 INITIALIZED, // Created ThreadWatch object. | 30 INITIALIZED, // Created ThreadWatch object. |
30 ACTIVATED, // Thread watching activated. | 31 ACTIVATED, // Thread watching activated. |
31 SENT_PING, // Sent ping message to watched thread. | 32 SENT_PING, // Sent ping message to watched thread. |
32 RECEIVED_PONG, // Received Pong message. | 33 RECEIVED_PONG, // Received Pong message. |
33 DEACTIVATED, // Thread watching de-activated. | 34 DEACTIVATED, // Thread watching de-activated. |
34 }; | 35 }; |
35 | 36 |
36 enum WaitState { | 37 enum WaitState { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 553 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
553 base::Unretained(io_watcher_))); | 554 base::Unretained(io_watcher_))); |
554 WatchDogThread::PostTask( | 555 WatchDogThread::PostTask( |
555 FROM_HERE, | 556 FROM_HERE, |
556 base::Bind(&ThreadWatcher::DeActivateThreadWatching, | 557 base::Bind(&ThreadWatcher::DeActivateThreadWatching, |
557 base::Unretained(webkit_watcher_))); | 558 base::Unretained(webkit_watcher_))); |
558 | 559 |
559 // Wait for the io_watcher_'s VeryLongMethod to finish. | 560 // Wait for the io_watcher_'s VeryLongMethod to finish. |
560 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); | 561 io_watcher_->WaitForWaitStateChange(kUnresponsiveTime * 10, ALL_DONE); |
561 } | 562 } |
OLD | NEW |