Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/renderer/render_thread.h" | 5 #include "chrome/renderer/render_thread.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 } | 95 } |
| 96 | 96 |
| 97 void RenderThread::SendHistograms() { | 97 void RenderThread::SendHistograms() { |
| 98 return histogram_snapshots_->SendHistograms(); | 98 return histogram_snapshots_->SendHistograms(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 static WebAppCacheContext* CreateAppCacheContextForRenderer() { | 101 static WebAppCacheContext* CreateAppCacheContextForRenderer() { |
| 102 return new AppCacheContextImpl(RenderThread::current()); | 102 return new AppCacheContextImpl(RenderThread::current()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 #if defined(OS_POSIX) | |
| 106 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { | |
|
Evan Stade
2009/04/30 21:40:43
lol at this name
| |
| 107 void OnChannelError() { | |
| 108 // On POSIX, at least, one can install an unload handler which loops | |
| 109 // forever and leave behind a renderer process which eats 100% CPU forever. | |
| 110 // | |
| 111 // This is because the terminate signals (ViewMsg_ShouldClose and the error | |
| 112 // from the IPC channel) are routed to the main message loop but never | |
| 113 // processed (because that message loop is stuck in V8). | |
| 114 // | |
| 115 // One could make the browser SIGKILL the renderers, but that leaves open a | |
| 116 // large window where a browser failure (or a user, manually terminating | |
| 117 // the browser because "it's stuck") will leave behind a process eating all | |
| 118 // the CPU. | |
| 119 // | |
| 120 // So, we install a filter on the channel so that we can process this event | |
| 121 // here and kill the process. | |
| 122 exit(0); | |
| 123 } | |
| 124 }; | |
| 125 #endif | |
| 126 | |
| 105 void RenderThread::Init() { | 127 void RenderThread::Init() { |
| 106 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 107 // If you are running plugins in this thread you need COM active but in | 129 // If you are running plugins in this thread you need COM active but in |
| 108 // the normal case you don't. | 130 // the normal case you don't. |
| 109 if (RenderProcess::InProcessPlugins()) | 131 if (RenderProcess::InProcessPlugins()) |
| 110 CoInitialize(0); | 132 CoInitialize(0); |
| 111 #endif | 133 #endif |
| 112 | 134 |
| 113 ChildThread::Init(); | 135 ChildThread::Init(); |
| 114 notification_service_.reset(new NotificationService); | 136 notification_service_.reset(new NotificationService); |
| 115 cache_stats_factory_.reset( | 137 cache_stats_factory_.reset( |
| 116 new ScopedRunnableMethodFactory<RenderThread>(this)); | 138 new ScopedRunnableMethodFactory<RenderThread>(this)); |
| 117 | 139 |
| 118 visited_link_slave_.reset(new VisitedLinkSlave()); | 140 visited_link_slave_.reset(new VisitedLinkSlave()); |
| 119 user_script_slave_.reset(new UserScriptSlave()); | 141 user_script_slave_.reset(new UserScriptSlave()); |
| 120 dns_master_.reset(new RenderDnsMaster()); | 142 dns_master_.reset(new RenderDnsMaster()); |
| 121 histogram_snapshots_.reset(new RendererHistogramSnapshots()); | 143 histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
| 122 app_cache_dispatcher_.reset(new AppCacheDispatcher()); | 144 app_cache_dispatcher_.reset(new AppCacheDispatcher()); |
| 123 WebAppCacheContext::SetFactory(CreateAppCacheContextForRenderer); | 145 WebAppCacheContext::SetFactory(CreateAppCacheContextForRenderer); |
| 124 devtools_agent_filter_ = new DevToolsAgentFilter(); | 146 devtools_agent_filter_ = new DevToolsAgentFilter(); |
| 125 AddFilter(devtools_agent_filter_.get()); | 147 AddFilter(devtools_agent_filter_.get()); |
| 148 | |
| 149 #if defined(OS_POSIX) | |
| 150 AddFilter(new SuicideOnChannelErrorFilter); | |
| 151 #endif | |
| 126 } | 152 } |
| 127 | 153 |
| 128 void RenderThread::CleanUp() { | 154 void RenderThread::CleanUp() { |
| 129 // Shutdown in reverse of the initialization order. | 155 // Shutdown in reverse of the initialization order. |
| 130 RemoveFilter(devtools_agent_filter_.get()); | 156 RemoveFilter(devtools_agent_filter_.get()); |
| 131 devtools_agent_filter_ = NULL; | 157 devtools_agent_filter_ = NULL; |
| 132 WebAppCacheContext::SetFactory(NULL); | 158 WebAppCacheContext::SetFactory(NULL); |
| 133 app_cache_dispatcher_.reset(); | 159 app_cache_dispatcher_.reset(); |
| 134 histogram_snapshots_.reset(); | 160 histogram_snapshots_.reset(); |
| 135 dns_master_.reset(); | 161 dns_master_.reset(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 | 368 |
| 343 void RenderThread::OnPurgePluginListCache() { | 369 void RenderThread::OnPurgePluginListCache() { |
| 344 // The call below will cause a GetPlugins call with refresh=true, but at this | 370 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 345 // point we already know that the browser has refreshed its list, so disable | 371 // point we already know that the browser has refreshed its list, so disable |
| 346 // refresh temporarily to prevent each renderer process causing the list to be | 372 // refresh temporarily to prevent each renderer process causing the list to be |
| 347 // regenerated. | 373 // regenerated. |
| 348 plugin_refresh_allowed_ = false; | 374 plugin_refresh_allowed_ = false; |
| 349 WebKit::resetPluginCache(); | 375 WebKit::resetPluginCache(); |
| 350 plugin_refresh_allowed_ = true; | 376 plugin_refresh_allowed_ = true; |
| 351 } | 377 } |
| OLD | NEW |