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 "chrome/browser/hang_monitor/hung_window_detector.h" | 5 #include "chrome/browser/hang_monitor/hung_window_detector.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/win/win_util.h" |
11 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" | 12 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" |
12 #include "content/public/common/result_codes.h" | 13 #include "content/public/common/result_codes.h" |
13 | 14 |
14 const wchar_t HungWindowDetector::kHungChildWindowTimeout[] = | 15 const wchar_t HungWindowDetector::kHungChildWindowTimeout[] = |
15 L"Chrome_HungChildWindowTimeout"; | 16 L"Chrome_HungChildWindowTimeout"; |
16 | 17 |
17 HungWindowDetector::HungWindowDetector(HungWindowNotification* notification) | 18 HungWindowDetector::HungWindowDetector(HungWindowNotification* notification) |
18 : notification_(notification), | 19 : notification_(notification), |
19 top_level_window_(NULL), | 20 top_level_window_(NULL), |
20 message_response_timeout_(0), | 21 message_response_timeout_(0), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 82 |
82 DWORD child_window_process_id = 0; | 83 DWORD child_window_process_id = 0; |
83 DWORD child_window_thread_id = | 84 DWORD child_window_thread_id = |
84 GetWindowThreadProcessId(child_window, &child_window_process_id); | 85 GetWindowThreadProcessId(child_window, &child_window_process_id); |
85 bool continue_hang_detection = true; | 86 bool continue_hang_detection = true; |
86 | 87 |
87 if (top_level_window_thread_id != child_window_thread_id) { | 88 if (top_level_window_thread_id != child_window_thread_id) { |
88 // The message timeout for a child window starts of with a default | 89 // The message timeout for a child window starts of with a default |
89 // value specified by the message_response_timeout_ member. It is | 90 // value specified by the message_response_timeout_ member. It is |
90 // tracked by a property on the child window. | 91 // tracked by a property on the child window. |
91 #pragma warning(disable:4311) | 92 int child_window_message_timeout = base::win::HandleToUint32( |
92 int child_window_message_timeout = | 93 GetProp(child_window, kHungChildWindowTimeout)); |
93 reinterpret_cast<int>(GetProp(child_window, kHungChildWindowTimeout)); | |
94 #pragma warning(default:4311) | |
95 if (!child_window_message_timeout) { | 94 if (!child_window_message_timeout) { |
96 child_window_message_timeout = message_response_timeout_; | 95 child_window_message_timeout = message_response_timeout_; |
97 } | 96 } |
98 | 97 |
99 DWORD_PTR result = 0; | 98 DWORD_PTR result = 0; |
100 if (0 == SendMessageTimeout(child_window, | 99 if (0 == SendMessageTimeout(child_window, |
101 WM_NULL, | 100 WM_NULL, |
102 0, | 101 0, |
103 0, | 102 0, |
104 SMTO_BLOCK, | 103 SMTO_BLOCK, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 LPARAM param) { | 151 LPARAM param) { |
153 HungWindowDetector* detector_instance = | 152 HungWindowDetector* detector_instance = |
154 reinterpret_cast<HungWindowDetector*>(param); | 153 reinterpret_cast<HungWindowDetector*>(param); |
155 if (NULL == detector_instance) { | 154 if (NULL == detector_instance) { |
156 NOTREACHED(); | 155 NOTREACHED(); |
157 return FALSE; | 156 return FALSE; |
158 } | 157 } |
159 | 158 |
160 return detector_instance->CheckChildWindow(child_window); | 159 return detector_instance->CheckChildWindow(child_window); |
161 } | 160 } |
OLD | NEW |