Chromium Code Reviews| 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 <utility> | 10 #include <utility> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 #include "content/child/memory/child_memory_coordinator_impl.h" | 63 #include "content/child/memory/child_memory_coordinator_impl.h" |
| 64 #include "content/child/resource_dispatcher.h" | 64 #include "content/child/resource_dispatcher.h" |
| 65 #include "content/child/resource_scheduling_filter.h" | 65 #include "content/child/resource_scheduling_filter.h" |
| 66 #include "content/child/runtime_features.h" | 66 #include "content/child/runtime_features.h" |
| 67 #include "content/child/thread_safe_sender.h" | 67 #include "content/child/thread_safe_sender.h" |
| 68 #include "content/child/web_database_observer_impl.h" | 68 #include "content/child/web_database_observer_impl.h" |
| 69 #include "content/child/worker_thread_registry.h" | 69 #include "content/child/worker_thread_registry.h" |
| 70 #include "content/common/child_process_messages.h" | 70 #include "content/common/child_process_messages.h" |
| 71 #include "content/common/content_constants_internal.h" | 71 #include "content/common/content_constants_internal.h" |
| 72 #include "content/common/dom_storage/dom_storage_messages.h" | 72 #include "content/common/dom_storage/dom_storage_messages.h" |
| 73 #include "content/common/field_trial_recorder.mojom.h" | |
| 73 #include "content/common/frame_messages.h" | 74 #include "content/common/frame_messages.h" |
| 74 #include "content/common/frame_owner_properties.h" | 75 #include "content/common/frame_owner_properties.h" |
| 75 #include "content/common/render_process_messages.h" | 76 #include "content/common/render_process_messages.h" |
| 76 #include "content/common/resource_messages.h" | 77 #include "content/common/resource_messages.h" |
| 77 #include "content/common/site_isolation_policy.h" | 78 #include "content/common/site_isolation_policy.h" |
| 78 #include "content/common/view_messages.h" | 79 #include "content/common/view_messages.h" |
| 79 #include "content/common/worker_messages.h" | 80 #include "content/common/worker_messages.h" |
| 80 #include "content/public/common/content_constants.h" | 81 #include "content/public/common/content_constants.h" |
| 81 #include "content/public/common/content_features.h" | 82 #include "content/public/common/content_features.h" |
| 82 #include "content/public/common/content_paths.h" | 83 #include "content/public/common/content_paths.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, | 572 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, |
| 572 const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) | 573 const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) |
| 573 : ChildThreadImpl(Options::Builder() | 574 : ChildThreadImpl(Options::Builder() |
| 574 .InBrowserProcess(params) | 575 .InBrowserProcess(params) |
| 575 .AutoStartServiceManagerConnection(false) | 576 .AutoStartServiceManagerConnection(false) |
| 576 .ConnectToBrowser(true) | 577 .ConnectToBrowser(true) |
| 577 .Build()), | 578 .Build()), |
| 578 renderer_scheduler_(std::move(scheduler)), | 579 renderer_scheduler_(std::move(scheduler)), |
| 579 categorized_worker_pool_(new CategorizedWorkerPool()), | 580 categorized_worker_pool_(new CategorizedWorkerPool()), |
| 580 renderer_binding_(this), | 581 renderer_binding_(this), |
| 581 client_id_(1) { | 582 client_id_(1), |
| 583 field_trial_syncer_(this) { | |
| 582 Init(resource_task_queue); | 584 Init(resource_task_queue); |
| 583 } | 585 } |
| 584 | 586 |
| 585 // When we run plugins in process, we actually run them on the render thread, | 587 // When we run plugins in process, we actually run them on the render thread, |
| 586 // which means that we need to make the render thread pump UI events. | 588 // which means that we need to make the render thread pump UI events. |
| 587 RenderThreadImpl::RenderThreadImpl( | 589 RenderThreadImpl::RenderThreadImpl( |
| 588 std::unique_ptr<base::MessageLoop> main_message_loop, | 590 std::unique_ptr<base::MessageLoop> main_message_loop, |
| 589 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) | 591 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) |
| 590 : ChildThreadImpl(Options::Builder() | 592 : ChildThreadImpl(Options::Builder() |
| 591 .AutoStartServiceManagerConnection(false) | 593 .AutoStartServiceManagerConnection(false) |
| 592 .ConnectToBrowser(true) | 594 .ConnectToBrowser(true) |
| 593 .Build()), | 595 .Build()), |
| 594 renderer_scheduler_(std::move(scheduler)), | 596 renderer_scheduler_(std::move(scheduler)), |
| 595 main_message_loop_(std::move(main_message_loop)), | 597 main_message_loop_(std::move(main_message_loop)), |
| 596 categorized_worker_pool_(new CategorizedWorkerPool()), | 598 categorized_worker_pool_(new CategorizedWorkerPool()), |
| 597 is_scroll_animator_enabled_(false), | 599 is_scroll_animator_enabled_(false), |
| 598 is_surface_synchronization_enabled_(false), | 600 is_surface_synchronization_enabled_(false), |
| 599 renderer_binding_(this) { | 601 renderer_binding_(this), |
| 602 field_trial_syncer_(this) { | |
| 600 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; | 603 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; |
| 601 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 604 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 602 switches::kRendererClientId)); | 605 switches::kRendererClientId)); |
| 603 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 606 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 604 switches::kRendererClientId), | 607 switches::kRendererClientId), |
| 605 &client_id_); | 608 &client_id_); |
| 606 Init(test_task_counter); | 609 Init(test_task_counter); |
| 607 } | 610 } |
| 608 | 611 |
| 609 void RenderThreadImpl::Init( | 612 void RenderThreadImpl::Init( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 switches::kNoUseMusInRenderer)) { | 712 switches::kNoUseMusInRenderer)) { |
| 710 CreateRenderWidgetWindowTreeClientFactory(GetServiceManagerConnection()); | 713 CreateRenderWidgetWindowTreeClientFactory(GetServiceManagerConnection()); |
| 711 } | 714 } |
| 712 #endif | 715 #endif |
| 713 | 716 |
| 714 // Must be called before RenderThreadStarted() below. | 717 // Must be called before RenderThreadStarted() below. |
| 715 StartServiceManagerConnection(); | 718 StartServiceManagerConnection(); |
| 716 | 719 |
| 717 GetContentClient()->renderer()->RenderThreadStarted(); | 720 GetContentClient()->renderer()->RenderThreadStarted(); |
| 718 | 721 |
| 722 field_trial_syncer_.InitFieldTrialObserving( | |
| 723 *base::CommandLine::ForCurrentProcess(), switches::kSingleProcess); | |
| 724 | |
| 719 GetAssociatedInterfaceRegistry()->AddInterface( | 725 GetAssociatedInterfaceRegistry()->AddInterface( |
| 720 base::Bind(&RenderThreadImpl::OnRendererInterfaceRequest, | 726 base::Bind(&RenderThreadImpl::OnRendererInterfaceRequest, |
| 721 base::Unretained(this))); | 727 base::Unretained(this))); |
| 722 | 728 |
| 723 InitSkiaEventTracer(); | 729 InitSkiaEventTracer(); |
| 724 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 730 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 725 skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr); | 731 skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr); |
| 726 | 732 |
| 727 const base::CommandLine& command_line = | 733 const base::CommandLine& command_line = |
| 728 *base::CommandLine::ForCurrentProcess(); | 734 *base::CommandLine::ForCurrentProcess(); |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1478 scoped_refptr<base::SingleThreadTaskRunner> | 1484 scoped_refptr<base::SingleThreadTaskRunner> |
| 1479 RenderThreadImpl::GetTimerTaskRunner() { | 1485 RenderThreadImpl::GetTimerTaskRunner() { |
| 1480 return renderer_scheduler_->TimerTaskRunner(); | 1486 return renderer_scheduler_->TimerTaskRunner(); |
| 1481 } | 1487 } |
| 1482 | 1488 |
| 1483 scoped_refptr<base::SingleThreadTaskRunner> | 1489 scoped_refptr<base::SingleThreadTaskRunner> |
| 1484 RenderThreadImpl::GetLoadingTaskRunner() { | 1490 RenderThreadImpl::GetLoadingTaskRunner() { |
| 1485 return renderer_scheduler_->LoadingTaskRunner(); | 1491 return renderer_scheduler_->LoadingTaskRunner(); |
| 1486 } | 1492 } |
| 1487 | 1493 |
| 1494 void RenderThreadImpl::SetFieldTrialGroup(const std::string& trial_name, | |
| 1495 const std::string& group_name) { | |
| 1496 field_trial_syncer_.OnSetFieldTrialGroup(trial_name, group_name); | |
| 1497 } | |
| 1498 | |
| 1488 void RenderThreadImpl::OnAssociatedInterfaceRequest( | 1499 void RenderThreadImpl::OnAssociatedInterfaceRequest( |
| 1489 const std::string& name, | 1500 const std::string& name, |
| 1490 mojo::ScopedInterfaceEndpointHandle handle) { | 1501 mojo::ScopedInterfaceEndpointHandle handle) { |
| 1491 if (associated_interfaces_.CanBindRequest(name)) | 1502 if (associated_interfaces_.CanBindRequest(name)) |
| 1492 associated_interfaces_.BindRequest(name, std::move(handle)); | 1503 associated_interfaces_.BindRequest(name, std::move(handle)); |
| 1493 else | 1504 else |
| 1494 ChildThreadImpl::OnAssociatedInterfaceRequest(name, std::move(handle)); | 1505 ChildThreadImpl::OnAssociatedInterfaceRequest(name, std::move(handle)); |
| 1495 } | 1506 } |
| 1496 | 1507 |
| 1497 bool RenderThreadImpl::IsGpuRasterizationForced() { | 1508 bool RenderThreadImpl::IsGpuRasterizationForced() { |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2036 } | 2047 } |
| 2037 | 2048 |
| 2038 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { | 2049 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { |
| 2039 if (!gpu_channel_) | 2050 if (!gpu_channel_) |
| 2040 return nullptr; | 2051 return nullptr; |
| 2041 if (gpu_channel_->IsLost()) | 2052 if (gpu_channel_->IsLost()) |
| 2042 return nullptr; | 2053 return nullptr; |
| 2043 return gpu_channel_.get(); | 2054 return gpu_channel_.get(); |
| 2044 } | 2055 } |
| 2045 | 2056 |
| 2057 void RenderThreadImpl::OnFieldTrialGroupFinalized( | |
| 2058 const std::string& trial_name, | |
| 2059 const std::string& group_name) { | |
| 2060 content::mojom::FieldTrialRecorderPtr field_trial_recorder; | |
|
jam
2017/03/16 15:33:40
nit: no content::
chiniforooshan
2017/03/16 17:35:46
Done.
| |
| 2061 GetRemoteInterfaces()->GetInterface(&field_trial_recorder); | |
| 2062 field_trial_recorder->FieldTrialActivated(trial_name); | |
| 2063 } | |
| 2064 | |
| 2046 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { | 2065 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { |
| 2047 CompositorDependencies* compositor_deps = this; | 2066 CompositorDependencies* compositor_deps = this; |
| 2048 is_scroll_animator_enabled_ = params->web_preferences.enable_scroll_animator; | 2067 is_scroll_animator_enabled_ = params->web_preferences.enable_scroll_animator; |
| 2049 // When bringing in render_view, also bring in webkit's glue and jsbindings. | 2068 // When bringing in render_view, also bring in webkit's glue and jsbindings. |
| 2050 RenderViewImpl::Create(compositor_deps, *params, | 2069 RenderViewImpl::Create(compositor_deps, *params, |
| 2051 RenderWidget::ShowCallback()); | 2070 RenderWidget::ShowCallback()); |
| 2052 } | 2071 } |
| 2053 | 2072 |
| 2054 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { | 2073 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { |
| 2055 // Debug cases of https://crbug.com/626802. | 2074 // Debug cases of https://crbug.com/626802. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2396 } | 2415 } |
| 2397 } | 2416 } |
| 2398 | 2417 |
| 2399 void RenderThreadImpl::OnRendererInterfaceRequest( | 2418 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2400 mojom::RendererAssociatedRequest request) { | 2419 mojom::RendererAssociatedRequest request) { |
| 2401 DCHECK(!renderer_binding_.is_bound()); | 2420 DCHECK(!renderer_binding_.is_bound()); |
| 2402 renderer_binding_.Bind(std::move(request)); | 2421 renderer_binding_.Bind(std::move(request)); |
| 2403 } | 2422 } |
| 2404 | 2423 |
| 2405 } // namespace content | 2424 } // namespace content |
| OLD | NEW |