Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/chrome_process_finder_win.cc

Issue 981223004: Add test for ProcessSingleton hung rendezvous case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Scott's remaining comment. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chrome_process_finder_win.h ('k') | chrome/browser/process_singleton.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 int timeout_in_milliseconds = 20 * 1000;
32 32
33 // The following is copied from net/base/escape.cc. We don't want to depend on 33 // 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 34 // net here because this gets compiled into chrome.exe to facilitate
35 // fast-rendezvous (see https://codereview.chromium.org/14617003/). 35 // fast-rendezvous (see https://codereview.chromium.org/14617003/).
36 36
37 // TODO(koz): Move these functions out of net/base/escape.cc into base/escape.cc 37 // TODO(koz): Move these functions out of net/base/escape.cc into base/escape.cc
38 // so we can depend on it directly. 38 // so we can depend on it directly.
39 39
40 // BEGIN COPY from net/base/escape.cc 40 // BEGIN COPY from net/base/escape.cc
41 41
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // Allow the current running browser window to make itself the foreground 135 // Allow the current running browser window to make itself the foreground
136 // window (otherwise it will just flash in the taskbar). 136 // window (otherwise it will just flash in the taskbar).
137 ::AllowSetForegroundWindow(process_id); 137 ::AllowSetForegroundWindow(process_id);
138 138
139 COPYDATASTRUCT cds; 139 COPYDATASTRUCT cds;
140 cds.dwData = 0; 140 cds.dwData = 0;
141 cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t)); 141 cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t));
142 cds.lpData = const_cast<wchar_t*>(to_send.c_str()); 142 cds.lpData = const_cast<wchar_t*>(to_send.c_str());
143 DWORD_PTR result = 0; 143 DWORD_PTR result = 0;
144 if (::SendMessageTimeout(remote_window, 144 if (::SendMessageTimeout(remote_window, WM_COPYDATA, NULL,
145 WM_COPYDATA, 145 reinterpret_cast<LPARAM>(&cds), SMTO_ABORTIFHUNG,
146 NULL, 146 timeout_in_milliseconds, &result)) {
147 reinterpret_cast<LPARAM>(&cds),
148 SMTO_ABORTIFHUNG,
149 kTimeoutInSeconds * 1000,
150 &result)) {
151 return result ? NOTIFY_SUCCESS : NOTIFY_FAILED; 147 return result ? NOTIFY_SUCCESS : NOTIFY_FAILED;
152 } 148 }
153 149
154 // It is possible that the process owning this window may have died by now. 150 // It is possible that the process owning this window may have died by now.
155 if (!::IsWindow(remote_window)) 151 if (!::IsWindow(remote_window))
156 return NOTIFY_FAILED; 152 return NOTIFY_FAILED;
157 153
158 // If the window couldn't be notified but still exists, assume it is hung. 154 // If the window couldn't be notified but still exists, assume it is hung.
159 return NOTIFY_WINDOW_HUNG; 155 return NOTIFY_WINDOW_HUNG;
160 } 156 }
161 157
158 base::TimeDelta SetNotificationTimeoutForTesting(base::TimeDelta new_timeout) {
159 base::TimeDelta old_timeout =
160 base::TimeDelta::FromMilliseconds(timeout_in_milliseconds);
161 timeout_in_milliseconds = new_timeout.InMilliseconds();
162 return old_timeout;
163 }
164
162 } // namespace chrome 165 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_process_finder_win.h ('k') | chrome/browser/process_singleton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698