| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 using WebKit::WebString; | 120 using WebKit::WebString; |
| 121 using WebKit::WebStorageEventDispatcher; | 121 using WebKit::WebStorageEventDispatcher; |
| 122 using WebKit::WebView; | 122 using WebKit::WebView; |
| 123 | 123 |
| 124 namespace { | 124 namespace { |
| 125 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; | 125 static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; |
| 126 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; | 126 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; |
| 127 static const double kInitialExtensionIdleHandlerDelayS = 5.0 /* seconds */; | 127 static const double kInitialExtensionIdleHandlerDelayS = 5.0 /* seconds */; |
| 128 static const int64 kMaxExtensionIdleHandlerDelayS = 5*60 /* seconds */; | 128 static const int64 kMaxExtensionIdleHandlerDelayS = 5*60 /* seconds */; |
| 129 | 129 |
| 130 static const int kPrelauchGpuPercentage = 5; | |
| 131 static const int kPrelauchGpuProcessDelayMS = 10000; | |
| 132 | |
| 133 // Keep the global RenderThread in a TLS slot so it is impossible to access | 130 // Keep the global RenderThread in a TLS slot so it is impossible to access |
| 134 // incorrectly from the wrong thread. | 131 // incorrectly from the wrong thread. |
| 135 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( | 132 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( |
| 136 base::LINKER_INITIALIZED); | 133 base::LINKER_INITIALIZED); |
| 137 | 134 |
| 138 #if defined(OS_POSIX) | 135 #if defined(OS_POSIX) |
| 139 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { | 136 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { |
| 140 void OnChannelError() { | 137 void OnChannelError() { |
| 141 // On POSIX, at least, one can install an unload handler which loops | 138 // On POSIX, at least, one can install an unload handler which loops |
| 142 // forever and leave behind a renderer process which eats 100% CPU forever. | 139 // forever and leave behind a renderer process which eats 100% CPU forever. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 AddFilter(db_message_filter_.get()); | 291 AddFilter(db_message_filter_.get()); |
| 295 | 292 |
| 296 cookie_message_filter_ = new CookieMessageFilter(); | 293 cookie_message_filter_ = new CookieMessageFilter(); |
| 297 AddFilter(cookie_message_filter_.get()); | 294 AddFilter(cookie_message_filter_.get()); |
| 298 | 295 |
| 299 #if defined(OS_POSIX) | 296 #if defined(OS_POSIX) |
| 300 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter; | 297 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter; |
| 301 AddFilter(suicide_on_channel_error_filter_.get()); | 298 AddFilter(suicide_on_channel_error_filter_.get()); |
| 302 #endif | 299 #endif |
| 303 | 300 |
| 304 // Establish a channel to the GPU process asynchronously if requested. If the | |
| 305 // channel is established in time, EstablishGpuChannelSync will not block when | |
| 306 // it is later called. Delays by a fixed period of time to avoid loading the | |
| 307 // GPU immediately in an attempt to not slow startup time. | |
| 308 scoped_refptr<base::FieldTrial> prelaunch_trial( | |
| 309 new base::FieldTrial("PrelaunchGpuProcessExperiment", 100)); | |
| 310 int prelaunch_group = prelaunch_trial->AppendGroup("prelaunch_gpu_process", | |
| 311 kPrelauchGpuPercentage); | |
| 312 if (prelaunch_group == prelaunch_trial->group() || | |
| 313 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 314 switches::kPrelaunchGpuProcess)) { | |
| 315 message_loop()->PostDelayedTask(FROM_HERE, | |
| 316 task_factory_->NewRunnableMethod( | |
| 317 &RenderThread::EstablishGpuChannel), | |
| 318 kPrelauchGpuProcessDelayMS); | |
| 319 } | |
| 320 | |
| 321 TRACE_EVENT_END("RenderThread::Init", 0, ""); | 301 TRACE_EVENT_END("RenderThread::Init", 0, ""); |
| 322 } | 302 } |
| 323 | 303 |
| 324 RenderThread::~RenderThread() { | 304 RenderThread::~RenderThread() { |
| 325 // Wait for all databases to be closed. | 305 // Wait for all databases to be closed. |
| 326 if (web_database_observer_impl_.get()) | 306 if (web_database_observer_impl_.get()) |
| 327 web_database_observer_impl_->WaitForAllDatabasesToClose(); | 307 web_database_observer_impl_->WaitForAllDatabasesToClose(); |
| 328 | 308 |
| 329 // Shutdown in reverse of the initialization order. | 309 // Shutdown in reverse of the initialization order. |
| 330 RemoveFilter(db_message_filter_.get()); | 310 RemoveFilter(db_message_filter_.get()); |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 } | 1127 } |
| 1148 | 1128 |
| 1149 return false; | 1129 return false; |
| 1150 } | 1130 } |
| 1151 | 1131 |
| 1152 void RenderThread::RegisterExtension(v8::Extension* extension, | 1132 void RenderThread::RegisterExtension(v8::Extension* extension, |
| 1153 bool restrict_to_extensions) { | 1133 bool restrict_to_extensions) { |
| 1154 WebScriptController::registerExtension(extension); | 1134 WebScriptController::registerExtension(extension); |
| 1155 v8_extensions_[extension->name()] = restrict_to_extensions; | 1135 v8_extensions_[extension->name()] = restrict_to_extensions; |
| 1156 } | 1136 } |
| OLD | NEW |