OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_HANG_MONITOR_HUNG_WINDOW_DETECTOR_H__ | 5 #ifndef CHROME_BROWSER_HANG_MONITOR_HUNG_WINDOW_DETECTOR_H__ |
6 #define CHROME_BROWSER_HANG_MONITOR_HUNG_WINDOW_DETECTOR_H__ | 6 #define CHROME_BROWSER_HANG_MONITOR_HUNG_WINDOW_DETECTOR_H__ |
7 | 7 |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "chrome/common/worker_thread_ticker.h" | 9 #include "chrome/common/worker_thread_ticker.h" |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 virtual bool OnHungWindowDetected(HWND hung_window, HWND top_level_window, | 41 virtual bool OnHungWindowDetected(HWND hung_window, HWND top_level_window, |
42 ActionOnHungWindow* action) = 0; | 42 ActionOnHungWindow* action) = 0; |
43 }; | 43 }; |
44 | 44 |
45 // The notification object is not owned by this class. It is assumed that | 45 // The notification object is not owned by this class. It is assumed that |
46 // this pointer will be valid throughout the lifetime of this class. | 46 // this pointer will be valid throughout the lifetime of this class. |
47 // Ownership of this pointer is not transferred to this class. | 47 // Ownership of this pointer is not transferred to this class. |
48 // Note that the Initialize method needs to be called to initiate monitoring | 48 // Note that the Initialize method needs to be called to initiate monitoring |
49 // of hung windows. | 49 // of hung windows. |
50 explicit HungWindowDetector(HungWindowNotification* notification); | 50 explicit HungWindowDetector(HungWindowNotification* notification); |
51 ~HungWindowDetector(); | 51 ~HungWindowDetector() override; |
52 | 52 |
53 // This method initialized the monitoring of hung windows. All descendant | 53 // This method initialized the monitoring of hung windows. All descendant |
54 // windows of the passed-in top-level window which belong to a thread | 54 // windows of the passed-in top-level window which belong to a thread |
55 // different from that of the top-level window are monitored. The | 55 // different from that of the top-level window are monitored. The |
56 // message_response_timeout parameter indicates how long this class must | 56 // message_response_timeout parameter indicates how long this class must |
57 // wait for a window to respond to a sent message before it is considered | 57 // wait for a window to respond to a sent message before it is considered |
58 // to be non-responsive. | 58 // to be non-responsive. |
59 // Initialize can be called multiple times to change the actual window to | 59 // Initialize can be called multiple times to change the actual window to |
60 // be monitored as well as the message response timeout | 60 // be monitored as well as the message response timeout |
61 bool Initialize(HWND top_level_window, | 61 bool Initialize(HWND top_level_window, |
62 int message_response_timeout); | 62 int message_response_timeout); |
63 | 63 |
64 // Implementation of the WorkerThreadTicker::Callback interface | 64 // Implementation of the WorkerThreadTicker::Callback interface |
65 virtual void OnTick(); | 65 void OnTick() override; |
66 | 66 |
67 private: | 67 private: |
68 // Helper function that checks whether the specified child window is hung. | 68 // Helper function that checks whether the specified child window is hung. |
69 // If so, it invokes the HungWindowNotification interface implementation | 69 // If so, it invokes the HungWindowNotification interface implementation |
70 bool CheckChildWindow(HWND child_window); | 70 bool CheckChildWindow(HWND child_window); |
71 | 71 |
72 static BOOL CALLBACK ChildWndEnumProc(HWND child_window, LPARAM param); | 72 static BOOL CALLBACK ChildWndEnumProc(HWND child_window, LPARAM param); |
73 | 73 |
74 // Pointer to the HungWindowNotification callback interface. This class does | 74 // Pointer to the HungWindowNotification callback interface. This class does |
75 // not RefCount this pointer and it is assumed that the pointer will be valid | 75 // not RefCount this pointer and it is assumed that the pointer will be valid |
76 // throughout the lifetime of this class. | 76 // throughout the lifetime of this class. |
77 HungWindowNotification* notification_; | 77 HungWindowNotification* notification_; |
78 HWND top_level_window_; | 78 HWND top_level_window_; |
79 | 79 |
80 // How long do we wait before we consider a window hung (in ms) | 80 // How long do we wait before we consider a window hung (in ms) |
81 int message_response_timeout_; | 81 int message_response_timeout_; |
82 base::Lock hang_detection_lock_; | 82 base::Lock hang_detection_lock_; |
83 // Indicates if this object is currently enumerating hung windows | 83 // Indicates if this object is currently enumerating hung windows |
84 bool enumerating_; | 84 bool enumerating_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(HungWindowDetector); | 86 DISALLOW_COPY_AND_ASSIGN(HungWindowDetector); |
87 }; | 87 }; |
88 | 88 |
89 | 89 |
90 #endif // CHROME_BROWSER_HANG_MONITOR_HUNG_WINDOW_DETECTOR_H__ | 90 #endif // CHROME_BROWSER_HANG_MONITOR_HUNG_WINDOW_DETECTOR_H__ |
OLD | NEW |