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

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

Issue 10032023: Reland r131429 (Moved SuicideOnChannelErrorFilter to content.). Install it in renderer_main.cc so t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/renderer_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) 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 std::vector<char> font_data; 139 std::vector<char> font_data;
140 RenderThread::Get()->PreCacheFont(logfont); 140 RenderThread::Get()->PreCacheFont(logfont);
141 rv = GetFontData(hdc, table, offset, buffer, length); 141 rv = GetFontData(hdc, table, offset, buffer, length);
142 RenderThread::Get()->ReleaseCachedFonts(); 142 RenderThread::Get()->ReleaseCachedFonts();
143 } 143 }
144 } 144 }
145 return rv; 145 return rv;
146 } 146 }
147 #endif // OS_WIN 147 #endif // OS_WIN
148 148
149 #if defined(OS_POSIX)
150 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
151 void OnChannelError() {
152 // On POSIX, at least, one can install an unload handler which loops
153 // forever and leave behind a renderer process which eats 100% CPU forever.
154 //
155 // This is because the terminate signals (ViewMsg_ShouldClose and the error
156 // from the IPC channel) are routed to the main message loop but never
157 // processed (because that message loop is stuck in V8).
158 //
159 // One could make the browser SIGKILL the renderers, but that leaves open a
160 // large window where a browser failure (or a user, manually terminating
161 // the browser because "it's stuck") will leave behind a process eating all
162 // the CPU.
163 //
164 // So, we install a filter on the channel so that we can process this event
165 // here and kill the process.
166
167 _exit(0);
168 }
169 };
170 #endif // OS_POSIX
171
172 } // namespace 149 } // namespace
173 150
174 bool ChromeRenderProcessObserver::is_incognito_process_ = false; 151 bool ChromeRenderProcessObserver::is_incognito_process_ = false;
175 152
176 ChromeRenderProcessObserver::ChromeRenderProcessObserver( 153 ChromeRenderProcessObserver::ChromeRenderProcessObserver(
177 chrome::ChromeContentRendererClient* client) 154 chrome::ChromeContentRendererClient* client)
178 : client_(client), 155 : client_(client),
179 clear_cache_pending_(false) { 156 clear_cache_pending_(false) {
180 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 157 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
181 if (command_line.HasSwitch(switches::kEnableWatchdog)) { 158 if (command_line.HasSwitch(switches::kEnableWatchdog)) {
182 // TODO(JAR): Need to implement renderer IO msgloop watchdog. 159 // TODO(JAR): Need to implement renderer IO msgloop watchdog.
183 } 160 }
184 161
185 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { 162 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) {
186 base::StatisticsRecorder::set_dump_on_exit(true); 163 base::StatisticsRecorder::set_dump_on_exit(true);
187 } 164 }
188 165
189 RenderThread* thread = RenderThread::Get(); 166 RenderThread* thread = RenderThread::Get();
190 resource_delegate_.reset(new RendererResourceDelegate()); 167 resource_delegate_.reset(new RendererResourceDelegate());
191 thread->SetResourceDispatcherDelegate(resource_delegate_.get()); 168 thread->SetResourceDispatcherDelegate(resource_delegate_.get());
192 169
193 #if defined(OS_POSIX)
194 thread->AddFilter(new SuicideOnChannelErrorFilter());
195 #endif
196
197 // Configure modules that need access to resources. 170 // Configure modules that need access to resources.
198 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); 171 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
199 172
200 #if defined(OS_WIN) 173 #if defined(OS_WIN)
201 // Need to patch a few functions for font loading to work correctly. 174 // Need to patch a few functions for font loading to work correctly.
202 FilePath pdf; 175 FilePath pdf;
203 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) && 176 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) &&
204 file_util::PathExists(pdf)) { 177 file_util::PathExists(pdf)) {
205 g_iat_patch_createdca.Patch( 178 g_iat_patch_createdca.Patch(
206 pdf.value().c_str(), "gdi32.dll", "CreateDCA", CreateDCAPatch); 179 pdf.value().c_str(), "gdi32.dll", "CreateDCA", CreateDCAPatch);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (clear_cache_pending_) { 352 if (clear_cache_pending_) {
380 clear_cache_pending_ = false; 353 clear_cache_pending_ = false;
381 WebCache::clear(); 354 WebCache::clear();
382 } 355 }
383 } 356 }
384 357
385 const RendererContentSettingRules* 358 const RendererContentSettingRules*
386 ChromeRenderProcessObserver::content_setting_rules() const { 359 ChromeRenderProcessObserver::content_setting_rules() const {
387 return &content_setting_rules_; 360 return &content_setting_rules_;
388 } 361 }
OLDNEW
« no previous file with comments | « no previous file | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698