| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 RenderThread::RenderThread() { | 223 RenderThread::RenderThread() { |
| 224 Init(); | 224 Init(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 RenderThread::RenderThread(const std::string& channel_name) | 227 RenderThread::RenderThread(const std::string& channel_name) |
| 228 : ChildThread(channel_name) { | 228 : ChildThread(channel_name) { |
| 229 Init(); | 229 Init(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void RenderThread::Init() { | 232 void RenderThread::Init() { |
| 233 TRACE_EVENT_BEGIN("RenderThread::Init", 0, ""); | 233 // Forward GPU trace data unless we are in single-process mode. |
| 234 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
| 235 base::debug::TraceLog::GetInstance()->SetOutputCallback(NewCallback(this, |
| 236 &RenderThread::OnTraceDataCollected)); |
| 237 |
| 238 TRACE_EVENT_BEGIN_LEGACY("RenderThread::Init", 0, ""); |
| 234 | 239 |
| 235 lazy_tls.Pointer()->Set(this); | 240 lazy_tls.Pointer()->Set(this); |
| 236 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
| 237 // If you are running plugins in this thread you need COM active but in | 242 // If you are running plugins in this thread you need COM active but in |
| 238 // the normal case you don't. | 243 // the normal case you don't. |
| 239 if (RenderProcessImpl::InProcessPlugins()) | 244 if (RenderProcessImpl::InProcessPlugins()) |
| 240 CoInitialize(0); | 245 CoInitialize(0); |
| 241 #endif | 246 #endif |
| 242 | 247 |
| 243 std::string type_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 248 std::string type_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 272 AddFilter(db_message_filter_.get()); | 277 AddFilter(db_message_filter_.get()); |
| 273 | 278 |
| 274 cookie_message_filter_ = new CookieMessageFilter(); | 279 cookie_message_filter_ = new CookieMessageFilter(); |
| 275 AddFilter(cookie_message_filter_.get()); | 280 AddFilter(cookie_message_filter_.get()); |
| 276 | 281 |
| 277 #if defined(OS_POSIX) | 282 #if defined(OS_POSIX) |
| 278 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter; | 283 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter; |
| 279 AddFilter(suicide_on_channel_error_filter_.get()); | 284 AddFilter(suicide_on_channel_error_filter_.get()); |
| 280 #endif | 285 #endif |
| 281 | 286 |
| 282 TRACE_EVENT_END("RenderThread::Init", 0, ""); | 287 TRACE_EVENT_END_LEGACY("RenderThread::Init", 0, ""); |
| 283 } | 288 } |
| 284 | 289 |
| 285 RenderThread::~RenderThread() { | 290 RenderThread::~RenderThread() { |
| 286 // Wait for all databases to be closed. | 291 // Wait for all databases to be closed. |
| 287 if (web_database_observer_impl_.get()) | 292 if (web_database_observer_impl_.get()) |
| 288 web_database_observer_impl_->WaitForAllDatabasesToClose(); | 293 web_database_observer_impl_->WaitForAllDatabasesToClose(); |
| 289 | 294 |
| 290 // Shutdown in reverse of the initialization order. | 295 // Shutdown in reverse of the initialization order. |
| 291 RemoveFilter(db_message_filter_.get()); | 296 RemoveFilter(db_message_filter_.get()); |
| 292 db_message_filter_ = NULL; | 297 db_message_filter_ = NULL; |
| 293 RemoveFilter(devtools_agent_filter_.get()); | 298 RemoveFilter(devtools_agent_filter_.get()); |
| 294 | 299 |
| 295 // Shutdown the file thread if it's running. | 300 // Shutdown the file thread if it's running. |
| 296 if (file_thread_.get()) | 301 if (file_thread_.get()) |
| 297 file_thread_->Stop(); | 302 file_thread_->Stop(); |
| 298 | 303 |
| 299 if (webkit_client_.get()) | 304 if (webkit_client_.get()) |
| 300 WebKit::shutdown(); | 305 WebKit::shutdown(); |
| 301 | 306 |
| 302 lazy_tls.Pointer()->Set(NULL); | 307 lazy_tls.Pointer()->Set(NULL); |
| 303 | 308 |
| 309 // Clean up GPU_TRACE |
| 310 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
| 311 base::debug::TraceLog::GetInstance()->SetOutputCallback(NULL); |
| 312 |
| 304 // TODO(port) | 313 // TODO(port) |
| 305 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
| 306 // Clean up plugin channels before this thread goes away. | 315 // Clean up plugin channels before this thread goes away. |
| 307 PluginChannelBase::CleanupChannels(); | 316 PluginChannelBase::CleanupChannels(); |
| 308 // Don't call COM if the renderer is in the sandbox. | 317 // Don't call COM if the renderer is in the sandbox. |
| 309 if (RenderProcessImpl::InProcessPlugins()) | 318 if (RenderProcessImpl::InProcessPlugins()) |
| 310 CoUninitialize(); | 319 CoUninitialize(); |
| 311 #endif | 320 #endif |
| 312 } | 321 } |
| 313 | 322 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, | 646 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, |
| 638 OnSetIPCLoggingEnabled) | 647 OnSetIPCLoggingEnabled) |
| 639 #endif | 648 #endif |
| 640 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_Init, | 649 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_Init, |
| 641 OnInitSpellChecker) | 650 OnInitSpellChecker) |
| 642 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_WordAdded, | 651 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_WordAdded, |
| 643 OnSpellCheckWordAdded) | 652 OnSpellCheckWordAdded) |
| 644 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, | 653 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, |
| 645 OnSpellCheckEnableAutoSpellCorrect) | 654 OnSpellCheckEnableAutoSpellCorrect) |
| 646 IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished) | 655 IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished) |
| 656 IPC_MESSAGE_HANDLER(ViewMsg_SetTraceEnabled, OnSetTraceEnabled) |
| 647 IPC_MESSAGE_HANDLER(ViewMsg_SetPhishingModel, OnSetPhishingModel) | 657 IPC_MESSAGE_HANDLER(ViewMsg_SetPhishingModel, OnSetPhishingModel) |
| 648 IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_SetFeatureEnabled, | 658 IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_SetFeatureEnabled, |
| 649 OnSetSpeechInputEnabled) | 659 OnSetSpeechInputEnabled) |
| 650 IPC_MESSAGE_UNHANDLED(handled = false) | 660 IPC_MESSAGE_UNHANDLED(handled = false) |
| 651 IPC_END_MESSAGE_MAP() | 661 IPC_END_MESSAGE_MAP() |
| 652 return handled; | 662 return handled; |
| 653 } | 663 } |
| 654 | 664 |
| 655 void RenderThread::OnSetSpeechInputEnabled(bool enabled) { | 665 void RenderThread::OnSetSpeechInputEnabled(bool enabled) { |
| 656 DCHECK(!webkit_client_.get()); | 666 DCHECK(!webkit_client_.get()); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 | 1100 |
| 1091 if (channel_handle.name.size() != 0) { | 1101 if (channel_handle.name.size() != 0) { |
| 1092 // Connect to the GPU process if a channel name was received. | 1102 // Connect to the GPU process if a channel name was received. |
| 1093 gpu_channel_->Connect(channel_handle); | 1103 gpu_channel_->Connect(channel_handle); |
| 1094 } else { | 1104 } else { |
| 1095 // Otherwise cancel the connection. | 1105 // Otherwise cancel the connection. |
| 1096 gpu_channel_ = NULL; | 1106 gpu_channel_ = NULL; |
| 1097 } | 1107 } |
| 1098 } | 1108 } |
| 1099 | 1109 |
| 1110 void RenderThread::OnTraceDataCollected(const std::string& json_events) { |
| 1111 Send(new ViewHostMsg_TraceDataCollectedRemotely(json_events)); |
| 1112 } |
| 1113 |
| 1114 void RenderThread::OnSetTraceEnabled(bool enabled) { |
| 1115 base::debug::TraceLog::GetInstance()->SetEnabled(enabled); |
| 1116 if(!enabled) { |
| 1117 std::string json_complete("['TRACE_ENDED']"); |
| 1118 Send(new ViewHostMsg_TraceDataCollectedRemotely(json_complete)); |
| 1119 } |
| 1120 } |
| 1121 |
| 1100 void RenderThread::OnSetPhishingModel(IPC::PlatformFileForTransit model_file) { | 1122 void RenderThread::OnSetPhishingModel(IPC::PlatformFileForTransit model_file) { |
| 1101 safe_browsing::PhishingClassifierDelegate::SetPhishingModel(model_file); | 1123 safe_browsing::PhishingClassifierDelegate::SetPhishingModel(model_file); |
| 1102 } | 1124 } |
| 1103 | 1125 |
| 1104 scoped_refptr<base::MessageLoopProxy> | 1126 scoped_refptr<base::MessageLoopProxy> |
| 1105 RenderThread::GetFileThreadMessageLoopProxy() { | 1127 RenderThread::GetFileThreadMessageLoopProxy() { |
| 1106 DCHECK(message_loop() == MessageLoop::current()); | 1128 DCHECK(message_loop() == MessageLoop::current()); |
| 1107 if (!file_thread_.get()) { | 1129 if (!file_thread_.get()) { |
| 1108 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1130 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 1109 file_thread_->Start(); | 1131 file_thread_->Start(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1131 } | 1153 } |
| 1132 | 1154 |
| 1133 return false; | 1155 return false; |
| 1134 } | 1156 } |
| 1135 | 1157 |
| 1136 void RenderThread::RegisterExtension(v8::Extension* extension, | 1158 void RenderThread::RegisterExtension(v8::Extension* extension, |
| 1137 bool restrict_to_extensions) { | 1159 bool restrict_to_extensions) { |
| 1138 WebScriptController::registerExtension(extension); | 1160 WebScriptController::registerExtension(extension); |
| 1139 v8_extensions_[extension->name()] = restrict_to_extensions; | 1161 v8_extensions_[extension->name()] = restrict_to_extensions; |
| 1140 } | 1162 } |
| OLD | NEW |