| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.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> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/metrics/stats_table.h" | 18 #include "base/metrics/stats_table.h" |
| 19 #include "base/process_util.h" | 19 #include "base/process_util.h" |
| 20 #include "base/shared_memory.h" | 20 #include "base/shared_memory.h" |
| 21 #include "base/task.h" | 21 #include "base/task.h" |
| 22 #include "base/threading/thread_local.h" | 22 #include "base/threading/thread_local.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "base/win/scoped_com_initializer.h" |
| 24 #include "content/common/appcache/appcache_dispatcher.h" | 25 #include "content/common/appcache/appcache_dispatcher.h" |
| 25 #include "content/common/child_process_messages.h" | 26 #include "content/common/child_process_messages.h" |
| 26 #include "content/common/database_messages.h" | 27 #include "content/common/database_messages.h" |
| 27 #include "content/common/db_message_filter.h" | 28 #include "content/common/db_message_filter.h" |
| 28 #include "content/common/dom_storage_messages.h" | 29 #include "content/common/dom_storage_messages.h" |
| 29 #include "content/common/gpu/gpu_messages.h" | 30 #include "content/common/gpu/gpu_messages.h" |
| 30 #include "content/common/npobject_util.h" | 31 #include "content/common/npobject_util.h" |
| 31 #include "content/common/plugin_messages.h" | 32 #include "content/common/plugin_messages.h" |
| 32 #include "content/common/renderer_preferences.h" | 33 #include "content/common/renderer_preferences.h" |
| 33 #include "content/common/resource_dispatcher.h" | 34 #include "content/common/resource_dispatcher.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 #if defined(OS_MACOSX) | 176 #if defined(OS_MACOSX) |
| 176 // On Mac, the select popups are rendered by the browser. | 177 // On Mac, the select popups are rendered by the browser. |
| 177 WebKit::WebView::setUseExternalPopupMenus(true); | 178 WebKit::WebView::setUseExternalPopupMenus(true); |
| 178 #endif | 179 #endif |
| 179 | 180 |
| 180 lazy_tls.Pointer()->Set(this); | 181 lazy_tls.Pointer()->Set(this); |
| 181 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
| 182 // If you are running plugins in this thread you need COM active but in | 183 // If you are running plugins in this thread you need COM active but in |
| 183 // the normal case you don't. | 184 // the normal case you don't. |
| 184 if (RenderProcessImpl::InProcessPlugins()) | 185 if (RenderProcessImpl::InProcessPlugins()) |
| 185 CoInitialize(0); | 186 initialize_com_.reset(new base::win::ScopedCOMInitializer()); |
| 186 #endif | 187 #endif |
| 187 | 188 |
| 188 // In single process the single process is all there is. | 189 // In single process the single process is all there is. |
| 189 suspend_webkit_shared_timer_ = true; | 190 suspend_webkit_shared_timer_ = true; |
| 190 notify_webkit_of_modal_loop_ = true; | 191 notify_webkit_of_modal_loop_ = true; |
| 191 plugin_refresh_allowed_ = true; | 192 plugin_refresh_allowed_ = true; |
| 192 widget_count_ = 0; | 193 widget_count_ = 0; |
| 193 hidden_widget_count_ = 0; | 194 hidden_widget_count_ = 0; |
| 194 idle_notification_delay_in_s_ = kInitialIdleHandlerDelayS; | 195 idle_notification_delay_in_s_ = kInitialIdleHandlerDelayS; |
| 195 task_factory_.reset(new ScopedRunnableMethodFactory<RenderThreadImpl>(this)); | 196 task_factory_.reset(new ScopedRunnableMethodFactory<RenderThreadImpl>(this)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 252 |
| 252 if (webkit_platform_support_.get()) | 253 if (webkit_platform_support_.get()) |
| 253 WebKit::shutdown(); | 254 WebKit::shutdown(); |
| 254 | 255 |
| 255 lazy_tls.Pointer()->Set(NULL); | 256 lazy_tls.Pointer()->Set(NULL); |
| 256 | 257 |
| 257 // TODO(port) | 258 // TODO(port) |
| 258 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
| 259 // Clean up plugin channels before this thread goes away. | 260 // Clean up plugin channels before this thread goes away. |
| 260 NPChannelBase::CleanupChannels(); | 261 NPChannelBase::CleanupChannels(); |
| 261 // Don't call COM if the renderer is in the sandbox. | |
| 262 if (RenderProcessImpl::InProcessPlugins()) | |
| 263 CoUninitialize(); | |
| 264 #endif | 262 #endif |
| 265 } | 263 } |
| 266 | 264 |
| 267 bool RenderThreadImpl::Send(IPC::Message* msg) { | 265 bool RenderThreadImpl::Send(IPC::Message* msg) { |
| 268 // Certain synchronous messages cannot always be processed synchronously by | 266 // Certain synchronous messages cannot always be processed synchronously by |
| 269 // the browser, e.g., Chrome frame communicating with the embedding browser. | 267 // the browser, e.g., Chrome frame communicating with the embedding browser. |
| 270 // This could cause a complete hang of Chrome if a windowed plug-in is trying | 268 // This could cause a complete hang of Chrome if a windowed plug-in is trying |
| 271 // to communicate with the renderer thread since the browser's UI thread | 269 // to communicate with the renderer thread since the browser's UI thread |
| 272 // could be stuck (within a Windows API call) trying to synchronously | 270 // could be stuck (within a Windows API call) trying to synchronously |
| 273 // communicate with the plug-in. The remedy is to pump messages on this | 271 // communicate with the plug-in. The remedy is to pump messages on this |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 776 |
| 779 scoped_refptr<base::MessageLoopProxy> | 777 scoped_refptr<base::MessageLoopProxy> |
| 780 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 778 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
| 781 DCHECK(message_loop() == MessageLoop::current()); | 779 DCHECK(message_loop() == MessageLoop::current()); |
| 782 if (!file_thread_.get()) { | 780 if (!file_thread_.get()) { |
| 783 file_thread_.reset(new base::Thread("Renderer::FILE")); | 781 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 784 file_thread_->Start(); | 782 file_thread_->Start(); |
| 785 } | 783 } |
| 786 return file_thread_->message_loop_proxy(); | 784 return file_thread_->message_loop_proxy(); |
| 787 } | 785 } |
| OLD | NEW |