Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2732213004: Move FieldTrialRecorder mojom to content (Closed)
Patch Set: initialize FieldTrialList for RenderThreadImplBrowserTest Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/features.h" 73 #include "content/common/features.h"
74 #include "content/common/field_trial_recorder.mojom.h"
74 #include "content/common/frame_messages.h" 75 #include "content/common/frame_messages.h"
75 #include "content/common/frame_owner_properties.h" 76 #include "content/common/frame_owner_properties.h"
76 #include "content/common/render_process_messages.h" 77 #include "content/common/render_process_messages.h"
77 #include "content/common/resource_messages.h" 78 #include "content/common/resource_messages.h"
78 #include "content/common/site_isolation_policy.h" 79 #include "content/common/site_isolation_policy.h"
79 #include "content/common/view_messages.h" 80 #include "content/common/view_messages.h"
80 #include "content/common/worker_messages.h" 81 #include "content/common/worker_messages.h"
81 #include "content/public/common/content_constants.h" 82 #include "content/public/common/content_constants.h"
82 #include "content/public/common/content_features.h" 83 #include "content/public/common/content_features.h"
83 #include "content/public/common/content_paths.h" 84 #include "content/public/common/content_paths.h"
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, 573 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
573 const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 574 const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
574 : ChildThreadImpl(Options::Builder() 575 : ChildThreadImpl(Options::Builder()
575 .InBrowserProcess(params) 576 .InBrowserProcess(params)
576 .AutoStartServiceManagerConnection(false) 577 .AutoStartServiceManagerConnection(false)
577 .ConnectToBrowser(true) 578 .ConnectToBrowser(true)
578 .Build()), 579 .Build()),
579 renderer_scheduler_(std::move(scheduler)), 580 renderer_scheduler_(std::move(scheduler)),
580 categorized_worker_pool_(new CategorizedWorkerPool()), 581 categorized_worker_pool_(new CategorizedWorkerPool()),
581 renderer_binding_(this), 582 renderer_binding_(this),
582 client_id_(1) { 583 client_id_(1),
584 field_trial_syncer_(this) {
583 Init(resource_task_queue); 585 Init(resource_task_queue);
584 } 586 }
585 587
586 // When we run plugins in process, we actually run them on the render thread, 588 // When we run plugins in process, we actually run them on the render thread,
587 // which means that we need to make the render thread pump UI events. 589 // which means that we need to make the render thread pump UI events.
588 RenderThreadImpl::RenderThreadImpl( 590 RenderThreadImpl::RenderThreadImpl(
589 std::unique_ptr<base::MessageLoop> main_message_loop, 591 std::unique_ptr<base::MessageLoop> main_message_loop,
590 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) 592 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler)
591 : ChildThreadImpl(Options::Builder() 593 : ChildThreadImpl(Options::Builder()
592 .AutoStartServiceManagerConnection(false) 594 .AutoStartServiceManagerConnection(false)
593 .ConnectToBrowser(true) 595 .ConnectToBrowser(true)
594 .Build()), 596 .Build()),
595 renderer_scheduler_(std::move(scheduler)), 597 renderer_scheduler_(std::move(scheduler)),
596 main_message_loop_(std::move(main_message_loop)), 598 main_message_loop_(std::move(main_message_loop)),
597 categorized_worker_pool_(new CategorizedWorkerPool()), 599 categorized_worker_pool_(new CategorizedWorkerPool()),
598 is_scroll_animator_enabled_(false), 600 is_scroll_animator_enabled_(false),
599 is_surface_synchronization_enabled_(false), 601 is_surface_synchronization_enabled_(false),
600 renderer_binding_(this) { 602 renderer_binding_(this),
603 field_trial_syncer_(this) {
601 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; 604 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter;
602 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 605 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
603 switches::kRendererClientId)); 606 switches::kRendererClientId));
604 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 607 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
605 switches::kRendererClientId), 608 switches::kRendererClientId),
606 &client_id_); 609 &client_id_);
607 Init(test_task_counter); 610 Init(test_task_counter);
608 } 611 }
609 612
610 void RenderThreadImpl::Init( 613 void RenderThreadImpl::Init(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 switches::kNoUseMusInRenderer)) { 713 switches::kNoUseMusInRenderer)) {
711 CreateRenderWidgetWindowTreeClientFactory(GetServiceManagerConnection()); 714 CreateRenderWidgetWindowTreeClientFactory(GetServiceManagerConnection());
712 } 715 }
713 #endif 716 #endif
714 717
715 // Must be called before RenderThreadStarted() below. 718 // Must be called before RenderThreadStarted() below.
716 StartServiceManagerConnection(); 719 StartServiceManagerConnection();
717 720
718 GetContentClient()->renderer()->RenderThreadStarted(); 721 GetContentClient()->renderer()->RenderThreadStarted();
719 722
723 field_trial_syncer_.InitFieldTrialObserving(
724 *base::CommandLine::ForCurrentProcess(), switches::kSingleProcess);
725
720 GetAssociatedInterfaceRegistry()->AddInterface( 726 GetAssociatedInterfaceRegistry()->AddInterface(
721 base::Bind(&RenderThreadImpl::OnRendererInterfaceRequest, 727 base::Bind(&RenderThreadImpl::OnRendererInterfaceRequest,
722 base::Unretained(this))); 728 base::Unretained(this)));
723 729
724 InitSkiaEventTracer(); 730 InitSkiaEventTracer();
725 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 731 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
726 skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr); 732 skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr);
727 733
728 const base::CommandLine& command_line = 734 const base::CommandLine& command_line =
729 *base::CommandLine::ForCurrentProcess(); 735 *base::CommandLine::ForCurrentProcess();
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 } 2051 }
2041 2052
2042 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { 2053 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
2043 if (!gpu_channel_) 2054 if (!gpu_channel_)
2044 return nullptr; 2055 return nullptr;
2045 if (gpu_channel_->IsLost()) 2056 if (gpu_channel_->IsLost())
2046 return nullptr; 2057 return nullptr;
2047 return gpu_channel_.get(); 2058 return gpu_channel_.get();
2048 } 2059 }
2049 2060
2061 void RenderThreadImpl::OnFieldTrialGroupFinalized(
2062 const std::string& trial_name,
2063 const std::string& group_name) {
2064 mojom::FieldTrialRecorderPtr field_trial_recorder;
2065 GetRemoteInterfaces()->GetInterface(&field_trial_recorder);
2066 field_trial_recorder->FieldTrialActivated(trial_name);
2067 }
2068
2050 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { 2069 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) {
2051 CompositorDependencies* compositor_deps = this; 2070 CompositorDependencies* compositor_deps = this;
2052 is_scroll_animator_enabled_ = params->web_preferences.enable_scroll_animator; 2071 is_scroll_animator_enabled_ = params->web_preferences.enable_scroll_animator;
2053 // When bringing in render_view, also bring in webkit's glue and jsbindings. 2072 // When bringing in render_view, also bring in webkit's glue and jsbindings.
2054 RenderViewImpl::Create(compositor_deps, *params, 2073 RenderViewImpl::Create(compositor_deps, *params,
2055 RenderWidget::ShowCallback()); 2074 RenderWidget::ShowCallback());
2056 } 2075 }
2057 2076
2058 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { 2077 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) {
2059 // Debug cases of https://crbug.com/626802. 2078 // Debug cases of https://crbug.com/626802.
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 } 2419 }
2401 } 2420 }
2402 2421
2403 void RenderThreadImpl::OnRendererInterfaceRequest( 2422 void RenderThreadImpl::OnRendererInterfaceRequest(
2404 mojom::RendererAssociatedRequest request) { 2423 mojom::RendererAssociatedRequest request) {
2405 DCHECK(!renderer_binding_.is_bound()); 2424 DCHECK(!renderer_binding_.is_bound());
2406 renderer_binding_.Bind(std::move(request)); 2425 renderer_binding_.Bind(std::move(request));
2407 } 2426 }
2408 2427
2409 } // namespace content 2428 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_thread_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698