Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_process_finder_win.h" | 5 #include "chrome/browser/chrome_process_finder_win.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
| 22 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
| 23 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
| 24 #include "chrome/browser/metro_utils/metro_chrome_win.h" | 24 #include "chrome/browser/metro_utils/metro_chrome_win.h" |
| 25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 | 27 |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const int kTimeoutInSeconds = 20; | 31 const int kDefaultTimeoutInSeconds = 20; |
| 32 | |
| 33 int timeout_in_seconds = kDefaultTimeoutInSeconds; | |
|
gab
2015/03/11 13:20:39
nit: |g_timeout_in_seconds| (g_ prefix for globals
Sigurður Ásgeirsson
2015/03/11 14:32:36
Done.
| |
| 32 | 34 |
| 33 // The following is copied from net/base/escape.cc. We don't want to depend on | 35 // The following is copied from net/base/escape.cc. We don't want to depend on |
| 34 // net here because this gets compiled into chrome.exe to facilitate | 36 // net here because this gets compiled into chrome.exe to facilitate |
| 35 // fast-rendezvous (see https://codereview.chromium.org/14617003/). | 37 // fast-rendezvous (see https://codereview.chromium.org/14617003/). |
| 36 | 38 |
| 37 // TODO(koz): Move these functions out of net/base/escape.cc into base/escape.cc | 39 // TODO(koz): Move these functions out of net/base/escape.cc into base/escape.cc |
| 38 // so we can depend on it directly. | 40 // so we can depend on it directly. |
| 39 | 41 |
| 40 // BEGIN COPY from net/base/escape.cc | 42 // BEGIN COPY from net/base/escape.cc |
| 41 | 43 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 COPYDATASTRUCT cds; | 141 COPYDATASTRUCT cds; |
| 140 cds.dwData = 0; | 142 cds.dwData = 0; |
| 141 cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t)); | 143 cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t)); |
| 142 cds.lpData = const_cast<wchar_t*>(to_send.c_str()); | 144 cds.lpData = const_cast<wchar_t*>(to_send.c_str()); |
| 143 DWORD_PTR result = 0; | 145 DWORD_PTR result = 0; |
| 144 if (::SendMessageTimeout(remote_window, | 146 if (::SendMessageTimeout(remote_window, |
| 145 WM_COPYDATA, | 147 WM_COPYDATA, |
| 146 NULL, | 148 NULL, |
| 147 reinterpret_cast<LPARAM>(&cds), | 149 reinterpret_cast<LPARAM>(&cds), |
| 148 SMTO_ABORTIFHUNG, | 150 SMTO_ABORTIFHUNG, |
| 149 kTimeoutInSeconds * 1000, | 151 timeout_in_seconds * 1000, |
| 150 &result)) { | 152 &result)) { |
| 151 return result ? NOTIFY_SUCCESS : NOTIFY_FAILED; | 153 return result ? NOTIFY_SUCCESS : NOTIFY_FAILED; |
| 152 } | 154 } |
| 153 | 155 |
| 154 // It is possible that the process owning this window may have died by now. | 156 // It is possible that the process owning this window may have died by now. |
| 155 if (!::IsWindow(remote_window)) | 157 if (!::IsWindow(remote_window)) |
| 156 return NOTIFY_FAILED; | 158 return NOTIFY_FAILED; |
| 157 | 159 |
| 158 // If the window couldn't be notified but still exists, assume it is hung. | 160 // If the window couldn't be notified but still exists, assume it is hung. |
| 159 return NOTIFY_WINDOW_HUNG; | 161 return NOTIFY_WINDOW_HUNG; |
| 160 } | 162 } |
| 161 | 163 |
| 164 int SetNotificationTimeoutInSecondsForTesting(int new_timeout) { | |
| 165 int old_timeout = timeout_in_seconds; | |
| 166 timeout_in_seconds = new_timeout; | |
| 167 return old_timeout; | |
|
gab
2015/03/11 13:20:39
<investigate>
Sigurður Ásgeirsson
2015/03/11 14:32:36
???
gab
2015/03/11 15:19:42
Oops that was a note to self to figure out why we
| |
| 168 } | |
| 169 | |
| 162 } // namespace chrome | 170 } // namespace chrome |
| OLD | NEW |