| 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 #ifndef COMPONENTS_BROWSER_WATCHER_WINDOW_HANG_MONITOR_WIN_H_ | 4 #ifndef COMPONENTS_BROWSER_WATCHER_WINDOW_HANG_MONITOR_WIN_H_ |
| 5 #define COMPONENTS_BROWSER_WATCHER_WINDOW_HANG_MONITOR_WIN_H_ | 5 #define COMPONENTS_BROWSER_WATCHER_WINDOW_HANG_MONITOR_WIN_H_ |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // Initialize the monitor with |callback|. The callback is guaranteed | 36 // Initialize the monitor with |callback|. The callback is guaranteed |
| 37 // to be called no more than once, and never after the WindowHangMonitor is | 37 // to be called no more than once, and never after the WindowHangMonitor is |
| 38 // destroyed. The monitor will be configured to issue pings according to | 38 // destroyed. The monitor will be configured to issue pings according to |
| 39 // |ping_interval|. A failure to respond within |timeout| will be interpreted | 39 // |ping_interval|. A failure to respond within |timeout| will be interpreted |
| 40 // as a hang. | 40 // as a hang. |
| 41 WindowHangMonitor(base::TimeDelta ping_interval, | 41 WindowHangMonitor(base::TimeDelta ping_interval, |
| 42 base::TimeDelta timeout, | 42 base::TimeDelta timeout, |
| 43 const WindowEventCallback& callback); | 43 const WindowEventCallback& callback); |
| 44 ~WindowHangMonitor(); | 44 ~WindowHangMonitor(); |
| 45 | 45 |
| 46 // Initializes the watcher to monitor a window named |window_name| and owned | 46 // Initializes the watcher to monitor the Chrome message window owned |
| 47 // by |process|. May be invoked prior to the appearance of the window. | 47 // by |process|. May be invoked prior to the appearance of the window. |
| 48 void Initialize(base::Process process, const base::string16& window_name); | 48 void Initialize(base::Process process); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 struct OutstandingPing { | 51 struct OutstandingPing { |
| 52 WindowHangMonitor* monitor; | 52 WindowHangMonitor* monitor; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Schedules a delayed task to poll for the appearance of the target window. | 55 // Schedules a delayed task to poll for the appearance of the target window. |
| 56 void ScheduleFindWindow(); | 56 void ScheduleFindWindow(); |
| 57 | 57 |
| 58 // Checks for the appearance of the target window. If found, initiates the | 58 // Checks for the appearance of the target window. If found, initiates the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // Non-null when there is an outstanding ping. | 100 // Non-null when there is an outstanding ping. |
| 101 // This is intentionally leaked when a hang is detected. | 101 // This is intentionally leaked when a hang is detected. |
| 102 OutstandingPing* outstanding_ping_; | 102 OutstandingPing* outstanding_ping_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(WindowHangMonitor); | 104 DISALLOW_COPY_AND_ASSIGN(WindowHangMonitor); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace browser_watcher | 107 } // namespace browser_watcher |
| 108 | 108 |
| 109 #endif // COMPONENTS_BROWSER_WATCHER_WINDOW_HANG_MONITOR_WIN_H_ | 109 #endif // COMPONENTS_BROWSER_WATCHER_WINDOW_HANG_MONITOR_WIN_H_ |
| OLD | NEW |