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