| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/browser_watcher/window_hang_monitor_win.h" | 5 #include "components/browser_watcher/window_hang_monitor_win.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 MULTIPROCESS_TEST_MAIN(NoWindowChild) { | 39 MULTIPROCESS_TEST_MAIN(NoWindowChild) { |
| 40 ::Sleep(INFINITE); | 40 ::Sleep(INFINITE); |
| 41 return 0; | 41 return 0; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Manages a WindowHangMonitor that lives on a background thread. | 44 // Manages a WindowHangMonitor that lives on a background thread. |
| 45 class HangMonitorThread { | 45 class HangMonitorThread { |
| 46 public: | 46 public: |
| 47 // Instantiates the background thread. | 47 // Instantiates the background thread. |
| 48 HangMonitorThread() | 48 HangMonitorThread() |
| 49 : event_received_(false, false), | 49 : event_(WindowHangMonitor::WINDOW_NOT_FOUND), |
| 50 event_(WindowHangMonitor::WINDOW_NOT_FOUND), | 50 event_received_(false, false), |
| 51 thread_("HangMonitorThread") {} | 51 thread_("HangMonitorThread") {} |
| 52 | 52 |
| 53 ~HangMonitorThread() { | 53 ~HangMonitorThread() { |
| 54 if (hang_monitor_.get()) | 54 if (hang_monitor_.get()) |
| 55 DestroyWatcher(); | 55 DestroyWatcher(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Starts the background thread and the monitor to observe the window named | 58 // Starts the background thread and the monitor to observe the window named |
| 59 // |window_name| in |process|. Blocks until the monitor has been initialized. | 59 // |window_name| in |process|. Blocks until the monitor has been initialized. |
| 60 bool Start(base::Process process, const base::string16& window_name) { | 60 bool Start(base::Process process, const base::string16& window_name) { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 monitor_thread().WaitForEvent()); | 376 monitor_thread().WaitForEvent()); |
| 377 | 377 |
| 378 // Unblock the worker thread. | 378 // Unblock the worker thread. |
| 379 hang.Signal(); | 379 hang.Signal(); |
| 380 | 380 |
| 381 ASSERT_FALSE(monitor_thread().TimedWaitForEvent( | 381 ASSERT_FALSE(monitor_thread().TimedWaitForEvent( |
| 382 base::TimeDelta::FromMilliseconds(150))); | 382 base::TimeDelta::FromMilliseconds(150))); |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace browser_watcher | 385 } // namespace browser_watcher |
| OLD | NEW |