| OLD | NEW |
| 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 "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/allocator/allocator_extension.h" | 12 #include "base/allocator/allocator_extension.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/discardable_memory.h" | 17 #include "base/memory/discardable_memory.h" |
| 18 #include "base/memory/discardable_memory_emulated.h" | 18 #include "base/memory/discardable_memory_emulated.h" |
| 19 #include "base/memory/shared_memory.h" | 19 #include "base/memory/shared_memory.h" |
| 20 #include "base/metrics/field_trial.h" | 20 #include "base/metrics/field_trial.h" |
| 21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
| 22 #include "base/metrics/stats_table.h" | 22 #include "base/metrics/stats_table.h" |
| 23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/single_thread_task_runner.h" | |
| 25 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
| 26 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/string_tokenizer.h" | 26 #include "base/strings/string_tokenizer.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/threading/thread_local.h" | 28 #include "base/threading/thread_local.h" |
| 30 #include "base/threading/thread_restrictions.h" | 29 #include "base/threading/thread_restrictions.h" |
| 31 #include "base/values.h" | 30 #include "base/values.h" |
| 32 #include "cc/base/switches.h" | 31 #include "cc/base/switches.h" |
| 33 #include "cc/blink/web_external_bitmap_impl.h" | 32 #include "cc/blink/web_external_bitmap_impl.h" |
| 34 #include "cc/blink/web_layer_impl.h" | 33 #include "cc/blink/web_layer_impl.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 #include "content/renderer/media/midi_message_filter.h" | 85 #include "content/renderer/media/midi_message_filter.h" |
| 87 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" | 86 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" |
| 88 #include "content/renderer/media/video_capture_impl_manager.h" | 87 #include "content/renderer/media/video_capture_impl_manager.h" |
| 89 #include "content/renderer/media/video_capture_message_filter.h" | 88 #include "content/renderer/media/video_capture_message_filter.h" |
| 90 #include "content/renderer/net_info_helper.h" | 89 #include "content/renderer/net_info_helper.h" |
| 91 #include "content/renderer/p2p/socket_dispatcher.h" | 90 #include "content/renderer/p2p/socket_dispatcher.h" |
| 92 #include "content/renderer/render_frame_proxy.h" | 91 #include "content/renderer/render_frame_proxy.h" |
| 93 #include "content/renderer/render_process_impl.h" | 92 #include "content/renderer/render_process_impl.h" |
| 94 #include "content/renderer/render_view_impl.h" | 93 #include "content/renderer/render_view_impl.h" |
| 95 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 94 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 96 #include "content/renderer/scheduler_proxy_task_runner.h" | |
| 97 #include "content/renderer/service_worker/embedded_worker_context_message_filter
.h" | 95 #include "content/renderer/service_worker/embedded_worker_context_message_filter
.h" |
| 98 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 96 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 99 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 97 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 100 #include "ipc/ipc_channel_handle.h" | 98 #include "ipc/ipc_channel_handle.h" |
| 101 #include "ipc/ipc_forwarding_message_filter.h" | 99 #include "ipc/ipc_forwarding_message_filter.h" |
| 102 #include "ipc/ipc_platform_file.h" | 100 #include "ipc/ipc_platform_file.h" |
| 103 #include "media/base/audio_hardware_config.h" | 101 #include "media/base/audio_hardware_config.h" |
| 104 #include "media/base/media.h" | 102 #include "media/base/media.h" |
| 105 #include "media/filters/gpu_video_accelerator_factories.h" | 103 #include "media/filters/gpu_video_accelerator_factories.h" |
| 106 #include "mojo/common/common_type_converters.h" | 104 #include "mojo/common/common_type_converters.h" |
| 107 #include "net/base/net_errors.h" | 105 #include "net/base/net_errors.h" |
| 108 #include "net/base/net_util.h" | 106 #include "net/base/net_util.h" |
| 109 #include "skia/ext/event_tracer_impl.h" | 107 #include "skia/ext/event_tracer_impl.h" |
| 110 #include "third_party/WebKit/public/platform/WebString.h" | 108 #include "third_party/WebKit/public/platform/WebString.h" |
| 111 #include "third_party/WebKit/public/platform/WebThread.h" | |
| 112 #include "third_party/WebKit/public/web/WebColorName.h" | 109 #include "third_party/WebKit/public/web/WebColorName.h" |
| 113 #include "third_party/WebKit/public/web/WebDatabase.h" | 110 #include "third_party/WebKit/public/web/WebDatabase.h" |
| 114 #include "third_party/WebKit/public/web/WebDocument.h" | 111 #include "third_party/WebKit/public/web/WebDocument.h" |
| 115 #include "third_party/WebKit/public/web/WebFrame.h" | 112 #include "third_party/WebKit/public/web/WebFrame.h" |
| 116 #include "third_party/WebKit/public/web/WebImageCache.h" | 113 #include "third_party/WebKit/public/web/WebImageCache.h" |
| 117 #include "third_party/WebKit/public/web/WebKit.h" | 114 #include "third_party/WebKit/public/web/WebKit.h" |
| 118 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" | 115 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
| 119 #include "third_party/WebKit/public/web/WebPopupMenu.h" | 116 #include "third_party/WebKit/public/web/WebPopupMenu.h" |
| 120 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 117 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 121 #include "third_party/WebKit/public/web/WebScriptController.h" | 118 #include "third_party/WebKit/public/web/WebScriptController.h" |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 650 |
| 654 // RemoveEmbeddedWorkerRoute may be called while deleting | 651 // RemoveEmbeddedWorkerRoute may be called while deleting |
| 655 // EmbeddedWorkerDispatcher. So it must be deleted before deleting | 652 // EmbeddedWorkerDispatcher. So it must be deleted before deleting |
| 656 // RenderThreadImpl. | 653 // RenderThreadImpl. |
| 657 embedded_worker_dispatcher_.reset(); | 654 embedded_worker_dispatcher_.reset(); |
| 658 | 655 |
| 659 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might | 656 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might |
| 660 // hold pointers to V8 objects (e.g., via pending requests). | 657 // hold pointers to V8 objects (e.g., via pending requests). |
| 661 main_thread_indexed_db_dispatcher_.reset(); | 658 main_thread_indexed_db_dispatcher_.reset(); |
| 662 | 659 |
| 663 main_thread_compositor_task_runner_ = NULL; | |
| 664 main_thread_input_task_runner_ = NULL; | |
| 665 | |
| 666 if (webkit_platform_support_) | 660 if (webkit_platform_support_) |
| 667 blink::shutdown(); | 661 blink::shutdown(); |
| 668 | 662 |
| 669 lazy_tls.Pointer()->Set(NULL); | 663 lazy_tls.Pointer()->Set(NULL); |
| 670 | 664 |
| 671 // TODO(port) | 665 // TODO(port) |
| 672 #if defined(OS_WIN) | 666 #if defined(OS_WIN) |
| 673 // Clean up plugin channels before this thread goes away. | 667 // Clean up plugin channels before this thread goes away. |
| 674 NPChannelBase::CleanupChannels(); | 668 NPChannelBase::CleanupChannels(); |
| 675 #endif | 669 #endif |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 ResourceDispatcherDelegate* delegate) { | 832 ResourceDispatcherDelegate* delegate) { |
| 839 resource_dispatcher()->set_delegate(delegate); | 833 resource_dispatcher()->set_delegate(delegate); |
| 840 } | 834 } |
| 841 | 835 |
| 842 void RenderThreadImpl::EnsureWebKitInitialized() { | 836 void RenderThreadImpl::EnsureWebKitInitialized() { |
| 843 if (webkit_platform_support_) | 837 if (webkit_platform_support_) |
| 844 return; | 838 return; |
| 845 | 839 |
| 846 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); | 840 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); |
| 847 blink::initialize(webkit_platform_support_.get()); | 841 blink::initialize(webkit_platform_support_.get()); |
| 848 main_thread_compositor_task_runner_ = | |
| 849 make_scoped_refptr(new SchedulerProxyTaskRunner< | |
| 850 &blink::WebSchedulerProxy::postCompositorTask>()); | |
| 851 main_thread_input_task_runner_ = make_scoped_refptr( | |
| 852 new SchedulerProxyTaskRunner<&blink::WebSchedulerProxy::postInputTask>()); | |
| 853 | 842 |
| 854 v8::Isolate* isolate = blink::mainThreadIsolate(); | 843 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 855 | 844 |
| 856 isolate->SetCounterFunction(base::StatsTable::FindLocation); | 845 isolate->SetCounterFunction(base::StatsTable::FindLocation); |
| 857 isolate->SetCreateHistogramFunction(CreateHistogram); | 846 isolate->SetCreateHistogramFunction(CreateHistogram); |
| 858 isolate->SetAddHistogramSampleFunction(AddHistogramSample); | 847 isolate->SetAddHistogramSampleFunction(AddHistogramSample); |
| 859 | 848 |
| 860 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 849 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 861 | 850 |
| 862 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); | 851 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 882 } | 871 } |
| 883 | 872 |
| 884 InputHandlerManagerClient* input_handler_manager_client = NULL; | 873 InputHandlerManagerClient* input_handler_manager_client = NULL; |
| 885 #if defined(OS_ANDROID) | 874 #if defined(OS_ANDROID) |
| 886 if (SynchronousCompositorFactory* factory = | 875 if (SynchronousCompositorFactory* factory = |
| 887 SynchronousCompositorFactory::GetInstance()) { | 876 SynchronousCompositorFactory::GetInstance()) { |
| 888 input_handler_manager_client = factory->GetInputHandlerManagerClient(); | 877 input_handler_manager_client = factory->GetInputHandlerManagerClient(); |
| 889 } | 878 } |
| 890 #endif | 879 #endif |
| 891 if (!input_handler_manager_client) { | 880 if (!input_handler_manager_client) { |
| 892 input_event_filter_ = new InputEventFilter( | 881 input_event_filter_ = |
| 893 this, main_thread_input_task_runner_, compositor_message_loop_proxy_); | 882 new InputEventFilter(this, compositor_message_loop_proxy_); |
| 894 AddFilter(input_event_filter_.get()); | 883 AddFilter(input_event_filter_.get()); |
| 895 input_handler_manager_client = input_event_filter_.get(); | 884 input_handler_manager_client = input_event_filter_.get(); |
| 896 } | 885 } |
| 897 input_handler_manager_.reset( | 886 input_handler_manager_.reset( |
| 898 new InputHandlerManager(compositor_message_loop_proxy_, | 887 new InputHandlerManager(compositor_message_loop_proxy_, |
| 899 input_handler_manager_client)); | 888 input_handler_manager_client)); |
| 900 } | 889 } |
| 901 | 890 |
| 902 scoped_refptr<base::MessageLoopProxy> output_surface_loop; | 891 scoped_refptr<base::MessageLoopProxy> output_surface_loop; |
| 903 if (enable) | 892 if (enable) |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 hidden_widget_count_--; | 1645 hidden_widget_count_--; |
| 1657 | 1646 |
| 1658 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1647 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1659 return; | 1648 return; |
| 1660 } | 1649 } |
| 1661 | 1650 |
| 1662 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1651 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1663 } | 1652 } |
| 1664 | 1653 |
| 1665 } // namespace content | 1654 } // namespace content |
| OLD | NEW |