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

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

Issue 46076: Removed zombie hunter code (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/process_singleton_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/process_singleton.h" 5 #include "chrome/browser/process_singleton.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/win_util.h" 10 #include "base/win_util.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 switch (message) { 241 switch (message) {
242 case WM_COPYDATA: 242 case WM_COPYDATA:
243 return OnCopyData(reinterpret_cast<HWND>(wparam), 243 return OnCopyData(reinterpret_cast<HWND>(wparam),
244 reinterpret_cast<COPYDATASTRUCT*>(lparam)); 244 reinterpret_cast<COPYDATASTRUCT*>(lparam));
245 default: 245 default:
246 break; 246 break;
247 } 247 }
248 248
249 return ::DefWindowProc(hwnd, message, wparam, lparam); 249 return ::DefWindowProc(hwnd, message, wparam, lparam);
250 } 250 }
251
252 void ProcessSingleton::HuntForZombieChromeProcesses() {
253 // Detecting dead renderers is simple:
254 // - The process is named chrome.exe.
255 // - The process' parent doesn't exist anymore.
256 // - The process doesn't have a chrome::kMessageWindowClass window.
257 // If these conditions hold, the process is a zombie renderer or plugin.
258
259 // Retrieve the list of browser processes on start. This list is then used to
260 // detect zombie renderer process or plugin process.
261 class ZombieDetector : public base::ProcessFilter {
262 public:
263 ZombieDetector() {
264 for (HWND window = NULL;;) {
265 window = FindWindowEx(HWND_MESSAGE,
266 window,
267 chrome::kMessageWindowClass,
268 NULL);
269 if (!window)
270 break;
271 DWORD process = 0;
272 GetWindowThreadProcessId(window, &process);
273 if (process)
274 browsers_.push_back(process);
275 }
276 // We are also a browser, regardless of having the window or not.
277 browsers_.push_back(::GetCurrentProcessId());
278 }
279
280 virtual bool Includes(uint32 pid, uint32 parent_pid) const {
281 // Don't kill ourself eh.
282 if (GetCurrentProcessId() == pid)
283 return false;
284
285 // Is this a browser? If so, ignore it.
286 if (std::find(browsers_.begin(), browsers_.end(), pid) != browsers_.end())
287 return false;
288
289 // Is the parent a browser? If so, ignore it.
290 if (std::find(browsers_.begin(), browsers_.end(), parent_pid)
291 != browsers_.end())
292 return false;
293
294 // The chrome process is orphan.
295 return true;
296 }
297
298 protected:
299 std::vector<uint32> browsers_;
300 };
301
302 ZombieDetector zombie_detector;
303 base::KillProcesses(L"chrome.exe", ResultCodes::HUNG, &zombie_detector);
304 }
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698