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

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

Issue 10895: Add Terminate() to the Process object, have RenderProcessHost use this to avo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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/browser.cc ('k') | chrome/browser/browser_main.cc » ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser_init.h" 5 #include "chrome/browser/browser_init.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 std::wstring text = l10n_util::GetString(IDS_BROWSER_HUNGBROWSER_MESSAGE); 170 std::wstring text = l10n_util::GetString(IDS_BROWSER_HUNGBROWSER_MESSAGE);
171 std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); 171 std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME);
172 if (IDYES != win_util::MessageBox(NULL, text, caption, 172 if (IDYES != win_util::MessageBox(NULL, text, caption,
173 MB_YESNO | MB_ICONSTOP | MB_TOPMOST)) { 173 MB_YESNO | MB_ICONSTOP | MB_TOPMOST)) {
174 // The user denied. Quit silently. 174 // The user denied. Quit silently.
175 return true; 175 return true;
176 } 176 }
177 } 177 }
178 178
179 // Time to take action. Kill the browser process. 179 // Time to take action. Kill the browser process.
180 process_util::KillProcess(process_id, ResultCodes::HUNG, true); 180 base::KillProcess(process_id, ResultCodes::HUNG, true);
181 remote_window_ = NULL; 181 remote_window_ = NULL;
182 return false; 182 return false;
183 } 183 }
184 184
185 void BrowserInit::MessageWindow::Create() { 185 void BrowserInit::MessageWindow::Create() {
186 DCHECK(!window_); 186 DCHECK(!window_);
187 DCHECK(!remote_window_); 187 DCHECK(!remote_window_);
188 HINSTANCE hinst = GetModuleHandle(NULL); 188 HINSTANCE hinst = GetModuleHandle(NULL);
189 189
190 WNDCLASSEX wc = {0}; 190 WNDCLASSEX wc = {0};
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 void BrowserInit::MessageWindow::HuntForZombieChromeProcesses() { 314 void BrowserInit::MessageWindow::HuntForZombieChromeProcesses() {
315 // Detecting dead renderers is simple: 315 // Detecting dead renderers is simple:
316 // - The process is named chrome.exe. 316 // - The process is named chrome.exe.
317 // - The process' parent doesn't exist anymore. 317 // - The process' parent doesn't exist anymore.
318 // - The process doesn't have a chrome::kMessageWindowClass window. 318 // - The process doesn't have a chrome::kMessageWindowClass window.
319 // If these conditions hold, the process is a zombie renderer or plugin. 319 // If these conditions hold, the process is a zombie renderer or plugin.
320 320
321 // Retrieve the list of browser processes on start. This list is then used to 321 // Retrieve the list of browser processes on start. This list is then used to
322 // detect zombie renderer process or plugin process. 322 // detect zombie renderer process or plugin process.
323 class ZombieDetector : public process_util::ProcessFilter { 323 class ZombieDetector : public base::ProcessFilter {
324 public: 324 public:
325 ZombieDetector() { 325 ZombieDetector() {
326 for (HWND window = NULL;;) { 326 for (HWND window = NULL;;) {
327 window = FindWindowEx(HWND_MESSAGE, 327 window = FindWindowEx(HWND_MESSAGE,
328 window, 328 window,
329 chrome::kMessageWindowClass, 329 chrome::kMessageWindowClass,
330 NULL); 330 NULL);
331 if (!window) 331 if (!window)
332 break; 332 break;
333 DWORD process = 0; 333 DWORD process = 0;
(...skipping 21 matching lines...) Expand all
355 355
356 // The chrome process is orphan. 356 // The chrome process is orphan.
357 return true; 357 return true;
358 } 358 }
359 359
360 protected: 360 protected:
361 std::vector<uint32> browsers_; 361 std::vector<uint32> browsers_;
362 }; 362 };
363 363
364 ZombieDetector zombie_detector; 364 ZombieDetector zombie_detector;
365 process_util::KillProcesses(L"chrome.exe", 365 base::KillProcesses(L"chrome.exe", ResultCodes::HUNG, &zombie_detector);
366 ResultCodes::HUNG,
367 &zombie_detector);
368 } 366 }
369 367
370 368
371 // LaunchWithProfile ---------------------------------------------------------- 369 // LaunchWithProfile ----------------------------------------------------------
372 370
373 BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir, 371 BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir,
374 const std::wstring& cmd_line, 372 const std::wstring& cmd_line,
375 int show_command) 373 int show_command)
376 : command_line_(cmd_line), 374 : command_line_(cmd_line),
377 show_command_(show_command), 375 show_command_(show_command),
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (!launched) { 718 if (!launched) {
721 LOG(ERROR) << "launch error"; 719 LOG(ERROR) << "launch error";
722 if (return_code != NULL) { 720 if (return_code != NULL) {
723 *return_code = ResultCodes::INVALID_CMDLINE_URL; 721 *return_code = ResultCodes::INVALID_CMDLINE_URL;
724 } 722 }
725 return false; 723 return false;
726 } 724 }
727 725
728 return true; 726 return true;
729 } 727 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698