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

Side by Side Diff: chrome/renderer/chrome_render_process_observer.cc

Issue 9936002: Added code so renderer would cleanly exit. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed nits. Created 8 years, 8 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
OLDNEW
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/renderer/chrome_render_process_observer.h" 5 #include "chrome/renderer/chrome_render_process_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 RenderThread::Get()->PreCacheFont(logfont); 138 RenderThread::Get()->PreCacheFont(logfont);
139 rv = GetFontData(hdc, table, offset, buffer, length); 139 rv = GetFontData(hdc, table, offset, buffer, length);
140 RenderThread::Get()->ReleaseCachedFonts(); 140 RenderThread::Get()->ReleaseCachedFonts();
141 } 141 }
142 } 142 }
143 return rv; 143 return rv;
144 } 144 }
145 #endif // OS_WIN 145 #endif // OS_WIN
146 146
147 #if defined(OS_POSIX) 147 #if defined(OS_POSIX)
148 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { 148 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
jam 2012/04/09 16:02:37 I just realized I missed moving this class to cont
asharif1 2012/04/09 23:26:35 Separate CL uploaded here: https://chromiumcoderev
149 void OnChannelError() { 149 void OnChannelError() {
150 // On POSIX, at least, one can install an unload handler which loops 150 // On POSIX, at least, one can install an unload handler which loops
151 // forever and leave behind a renderer process which eats 100% CPU forever. 151 // forever and leave behind a renderer process which eats 100% CPU forever.
152 // 152 //
153 // This is because the terminate signals (ViewMsg_ShouldClose and the error 153 // This is because the terminate signals (ViewMsg_ShouldClose and the error
154 // from the IPC channel) are routed to the main message loop but never 154 // from the IPC channel) are routed to the main message loop but never
155 // processed (because that message loop is stuck in V8). 155 // processed (because that message loop is stuck in V8).
156 // 156 //
157 // One could make the browser SIGKILL the renderers, but that leaves open a 157 // One could make the browser SIGKILL the renderers, but that leaves open a
158 // large window where a browser failure (or a user, manually terminating 158 // large window where a browser failure (or a user, manually terminating
159 // the browser because "it's stuck") will leave behind a process eating all 159 // the browser because "it's stuck") will leave behind a process eating all
160 // the CPU. 160 // the CPU.
161 // 161 //
162 // So, we install a filter on the channel so that we can process this event 162 // So, we install a filter on the channel so that we can process this event
163 // here and kill the process. 163 // here and kill the process.
164 164
165 _exit(0); 165 if (CommandLine::ForCurrentProcess()->
166 HasSwitch(switches::kEnableRendererCleanExit))
167 alarm(30);
Markus (顧孟勤) 2012/04/06 21:41:59 I think I mentioned this before. A comment would b
asharif1 2012/04/09 23:26:35 Done.
168 else
169 _exit(0);
166 } 170 }
167 }; 171 };
168 #endif // OS_POSIX 172 #endif // OS_POSIX
169 173
170 } // namespace 174 } // namespace
171 175
172 bool ChromeRenderProcessObserver::is_incognito_process_ = false; 176 bool ChromeRenderProcessObserver::is_incognito_process_ = false;
173 177
174 ChromeRenderProcessObserver::ChromeRenderProcessObserver( 178 ChromeRenderProcessObserver::ChromeRenderProcessObserver(
175 chrome::ChromeContentRendererClient* client) 179 chrome::ChromeContentRendererClient* client)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (clear_cache_pending_) { 378 if (clear_cache_pending_) {
375 clear_cache_pending_ = false; 379 clear_cache_pending_ = false;
376 WebCache::clear(); 380 WebCache::clear();
377 } 381 }
378 } 382 }
379 383
380 const RendererContentSettingRules* 384 const RendererContentSettingRules*
381 ChromeRenderProcessObserver::content_setting_rules() const { 385 ChromeRenderProcessObserver::content_setting_rules() const {
382 return &content_setting_rules_; 386 return &content_setting_rules_;
383 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698