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

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

Issue 10027027: Moved SuicideOnChannelErrorFilter to content. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | content/renderer/render_thread_impl.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) 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 std::vector<char> font_data; 137 std::vector<char> font_data;
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)
148 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
149 void OnChannelError() {
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.
152 //
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
155 // processed (because that message loop is stuck in V8).
156 //
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
159 // the browser because "it's stuck") will leave behind a process eating all
160 // the CPU.
161 //
162 // So, we install a filter on the channel so that we can process this event
163 // here and kill the process.
164
165 _exit(0);
166 }
167 };
168 #endif // OS_POSIX
169
170 } // namespace 147 } // namespace
171 148
172 bool ChromeRenderProcessObserver::is_incognito_process_ = false; 149 bool ChromeRenderProcessObserver::is_incognito_process_ = false;
173 150
174 ChromeRenderProcessObserver::ChromeRenderProcessObserver( 151 ChromeRenderProcessObserver::ChromeRenderProcessObserver(
175 chrome::ChromeContentRendererClient* client) 152 chrome::ChromeContentRendererClient* client)
176 : client_(client), 153 : client_(client),
177 clear_cache_pending_(false) { 154 clear_cache_pending_(false) {
178 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 155 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
179 if (command_line.HasSwitch(switches::kEnableWatchdog)) { 156 if (command_line.HasSwitch(switches::kEnableWatchdog)) {
180 // TODO(JAR): Need to implement renderer IO msgloop watchdog. 157 // TODO(JAR): Need to implement renderer IO msgloop watchdog.
181 } 158 }
182 159
183 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { 160 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) {
184 base::StatisticsRecorder::set_dump_on_exit(true); 161 base::StatisticsRecorder::set_dump_on_exit(true);
185 } 162 }
186 163
187 RenderThread* thread = RenderThread::Get(); 164 RenderThread* thread = RenderThread::Get();
188 resource_delegate_.reset(new RendererResourceDelegate()); 165 resource_delegate_.reset(new RendererResourceDelegate());
189 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); 166 thread->SetResourceDispatcherDelegate(resource_delegate_.get());
190 167
191 #if defined(OS_POSIX)
192 thread->AddFilter(new SuicideOnChannelErrorFilter());
193 #endif
194
195 // Configure modules that need access to resources. 168 // Configure modules that need access to resources.
196 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); 169 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
197 170
198 #if defined(OS_WIN) 171 #if defined(OS_WIN)
199 // Need to patch a few functions for font loading to work correctly. 172 // Need to patch a few functions for font loading to work correctly.
200 FilePath pdf; 173 FilePath pdf;
201 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) && 174 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) &&
202 file_util::PathExists(pdf)) { 175 file_util::PathExists(pdf)) {
203 g_iat_patch_createdca.Patch( 176 g_iat_patch_createdca.Patch(
204 pdf.value().c_str(), "gdi32.dll", "CreateDCA", CreateDCAPatch); 177 pdf.value().c_str(), "gdi32.dll", "CreateDCA", CreateDCAPatch);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (clear_cache_pending_) { 347 if (clear_cache_pending_) {
375 clear_cache_pending_ = false; 348 clear_cache_pending_ = false;
376 WebCache::clear(); 349 WebCache::clear();
377 } 350 }
378 } 351 }
379 352
380 const RendererContentSettingRules* 353 const RendererContentSettingRules*
381 ChromeRenderProcessObserver::content_setting_rules() const { 354 ChromeRenderProcessObserver::content_setting_rules() const {
382 return &content_setting_rules_; 355 return &content_setting_rules_;
383 } 356 }
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698