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

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

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #include "ipc/ipc_channel_mojo.h" 134 #include "ipc/ipc_channel_mojo.h"
135 #include "ipc/ipc_platform_file.h" 135 #include "ipc/ipc_platform_file.h"
136 #include "media/base/media.h" 136 #include "media/base/media.h"
137 #include "media/renderers/gpu_video_accelerator_factories.h" 137 #include "media/renderers/gpu_video_accelerator_factories.h"
138 #include "mojo/common/common_type_converters.h" 138 #include "mojo/common/common_type_converters.h"
139 #include "mojo/public/cpp/bindings/strong_binding.h" 139 #include "mojo/public/cpp/bindings/strong_binding.h"
140 #include "net/base/net_errors.h" 140 #include "net/base/net_errors.h"
141 #include "net/base/port_util.h" 141 #include "net/base/port_util.h"
142 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 142 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
143 #include "net/base/url_util.h" 143 #include "net/base/url_util.h"
144 #include "services/shell/public/cpp/interface_provider.h"
145 #include "services/shell/public/cpp/interface_registry.h"
144 #include "skia/ext/event_tracer_impl.h" 146 #include "skia/ext/event_tracer_impl.h"
145 #include "skia/ext/skia_memory_dump_provider.h" 147 #include "skia/ext/skia_memory_dump_provider.h"
146 #include "third_party/WebKit/public/platform/WebImageGenerator.h" 148 #include "third_party/WebKit/public/platform/WebImageGenerator.h"
147 #include "third_party/WebKit/public/platform/WebString.h" 149 #include "third_party/WebKit/public/platform/WebString.h"
148 #include "third_party/WebKit/public/platform/WebThread.h" 150 #include "third_party/WebKit/public/platform/WebThread.h"
149 #include "third_party/WebKit/public/web/WebCache.h" 151 #include "third_party/WebKit/public/web/WebCache.h"
150 #include "third_party/WebKit/public/web/WebDatabase.h" 152 #include "third_party/WebKit/public/web/WebDatabase.h"
151 #include "third_party/WebKit/public/web/WebDocument.h" 153 #include "third_party/WebKit/public/web/WebDocument.h"
152 #include "third_party/WebKit/public/web/WebFrame.h" 154 #include "third_party/WebKit/public/web/WebFrame.h"
153 #include "third_party/WebKit/public/web/WebKit.h" 155 #include "third_party/WebKit/public/web/WebKit.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 return lazy_tls.Pointer()->Get(); 603 return lazy_tls.Pointer()->Get();
602 } 604 }
603 605
604 RenderThreadImpl::RenderThreadImpl( 606 RenderThreadImpl::RenderThreadImpl(
605 const InProcessChildThreadParams& params, 607 const InProcessChildThreadParams& params,
606 std::unique_ptr<scheduler::RendererScheduler> scheduler, 608 std::unique_ptr<scheduler::RendererScheduler> scheduler,
607 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 609 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
608 : ChildThreadImpl(Options::Builder() 610 : ChildThreadImpl(Options::Builder()
609 .InBrowserProcess(params) 611 .InBrowserProcess(params)
610 .UseMojoChannel(true) 612 .UseMojoChannel(true)
613 .AutoStartMojoShellConnection(false)
611 .Build()), 614 .Build()),
612 renderer_scheduler_(std::move(scheduler)), 615 renderer_scheduler_(std::move(scheduler)),
613 categorized_worker_pool_(new CategorizedWorkerPool()) { 616 categorized_worker_pool_(new CategorizedWorkerPool()) {
614 Init(resource_task_queue); 617 Init(resource_task_queue);
615 } 618 }
616 619
617 // When we run plugins in process, we actually run them on the render thread, 620 // When we run plugins in process, we actually run them on the render thread,
618 // which means that we need to make the render thread pump UI events. 621 // which means that we need to make the render thread pump UI events.
619 RenderThreadImpl::RenderThreadImpl( 622 RenderThreadImpl::RenderThreadImpl(
620 std::unique_ptr<base::MessageLoop> main_message_loop, 623 std::unique_ptr<base::MessageLoop> main_message_loop,
621 std::unique_ptr<scheduler::RendererScheduler> scheduler) 624 std::unique_ptr<scheduler::RendererScheduler> scheduler)
622 : ChildThreadImpl(Options::Builder().UseMojoChannel(true).Build()), 625 : ChildThreadImpl(Options::Builder()
626 .UseMojoChannel(true)
627 .AutoStartMojoShellConnection(false)
628 .Build()),
623 renderer_scheduler_(std::move(scheduler)), 629 renderer_scheduler_(std::move(scheduler)),
624 main_message_loop_(std::move(main_message_loop)), 630 main_message_loop_(std::move(main_message_loop)),
625 categorized_worker_pool_(new CategorizedWorkerPool()) { 631 categorized_worker_pool_(new CategorizedWorkerPool()) {
626 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; 632 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter;
627 Init(test_task_counter); 633 Init(test_task_counter);
628 } 634 }
629 635
630 void RenderThreadImpl::Init( 636 void RenderThreadImpl::Init(
631 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { 637 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) {
632 TRACE_EVENT0("startup", "RenderThreadImpl::Init"); 638 TRACE_EVENT0("startup", "RenderThreadImpl::Init");
633 639
634 base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex( 640 base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex(
635 base::PlatformThread::CurrentId(), 641 base::PlatformThread::CurrentId(),
636 kTraceEventRendererMainThreadSortIndex); 642 kTraceEventRendererMainThreadSortIndex);
637 643
638 #if defined(USE_EXTERNAL_POPUP_MENU) 644 #if defined(USE_EXTERNAL_POPUP_MENU)
639 // On Mac and Android Java UI, the select popups are rendered by the browser. 645 // On Mac and Android Java UI, the select popups are rendered by the browser.
640 blink::WebView::setUseExternalPopupMenus(true); 646 blink::WebView::setUseExternalPopupMenus(true);
641 #endif 647 #endif
642 648
643 lazy_tls.Pointer()->Set(this); 649 lazy_tls.Pointer()->Set(this);
644 650
645 // Register this object as the main thread. 651 // Register this object as the main thread.
646 ChildProcess::current()->set_main_thread(this); 652 ChildProcess::current()->set_main_thread(this);
647 653
648 #if defined(MOJO_SHELL_CLIENT) 654 #if defined(MOJO_SHELL_CLIENT)
649 if (IsRunningInMash()) { 655 if (IsRunningInMash())
650 auto* shell_connection = ChildThread::Get()->GetMojoShellConnection(); 656 ui::GpuService::Initialize(GetMojoShellConnection()->GetConnector());
651 ui::GpuService::Initialize(shell_connection->GetConnector());
652 }
653 #endif 657 #endif
654 658
655 InitializeWebKit(resource_task_queue); 659 InitializeWebKit(resource_task_queue);
656 660
657 // In single process the single process is all there is. 661 // In single process the single process is all there is.
658 webkit_shared_timer_suspended_ = false; 662 webkit_shared_timer_suspended_ = false;
659 widget_count_ = 0; 663 widget_count_ = 0;
660 hidden_widget_count_ = 0; 664 hidden_widget_count_ = 0;
661 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; 665 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs;
662 idle_notifications_to_skip_ = 0; 666 idle_notifications_to_skip_ = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 720
717 midi_message_filter_ = new MidiMessageFilter(GetIOTaskRunner()); 721 midi_message_filter_ = new MidiMessageFilter(GetIOTaskRunner());
718 AddFilter(midi_message_filter_.get()); 722 AddFilter(midi_message_filter_.get());
719 723
720 AddFilter((new IndexedDBMessageFilter(thread_safe_sender()))->GetFilter()); 724 AddFilter((new IndexedDBMessageFilter(thread_safe_sender()))->GetFilter());
721 725
722 AddFilter((new CacheStorageMessageFilter(thread_safe_sender()))->GetFilter()); 726 AddFilter((new CacheStorageMessageFilter(thread_safe_sender()))->GetFilter());
723 727
724 AddFilter((new ServiceWorkerContextMessageFilter())->GetFilter()); 728 AddFilter((new ServiceWorkerContextMessageFilter())->GetFilter());
725 729
730 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA)
731 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
732 switches::kUseMusInRenderer)) {
733 CreateRenderWidgetWindowTreeClientFactory(GetMojoShellConnection());
734 }
735 #endif
736
737 // Must be called before RenderThreadStarted() below.
738 StartMojoShellConnection();
739
726 GetContentClient()->renderer()->RenderThreadStarted(); 740 GetContentClient()->renderer()->RenderThreadStarted();
727 741
728 InitSkiaEventTracer(); 742 InitSkiaEventTracer();
729 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 743 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
730 skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr); 744 skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr);
731 745
732 const base::CommandLine& command_line = 746 const base::CommandLine& command_line =
733 *base::CommandLine::ForCurrentProcess(); 747 *base::CommandLine::ForCurrentProcess();
734 748
735 #if defined(ENABLE_IPC_FUZZER) 749 #if defined(ENABLE_IPC_FUZZER)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 // See crbug.com/503724. 855 // See crbug.com/503724.
842 base::DiscardableMemoryAllocator::SetInstance( 856 base::DiscardableMemoryAllocator::SetInstance(
843 ChildThreadImpl::discardable_shared_memory_manager()); 857 ChildThreadImpl::discardable_shared_memory_manager());
844 858
845 GetContentClient()->renderer()->ExposeInterfacesToBrowser( 859 GetContentClient()->renderer()->ExposeInterfacesToBrowser(
846 GetInterfaceRegistry()); 860 GetInterfaceRegistry());
847 861
848 GetInterfaceRegistry()->AddInterface(base::Bind(CreateFrameFactory)); 862 GetInterfaceRegistry()->AddInterface(base::Bind(CreateFrameFactory));
849 GetInterfaceRegistry()->AddInterface(base::Bind(CreateEmbeddedWorkerSetup)); 863 GetInterfaceRegistry()->AddInterface(base::Bind(CreateEmbeddedWorkerSetup));
850 864
851 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA)
852 // We may not have a MojoShellConnection object in tests that directly
853 // instantiate a RenderThreadImpl.
854 if (ChildThread::Get()->GetMojoShellConnection() &&
855 base::CommandLine::ForCurrentProcess()->HasSwitch(
856 switches::kUseMusInRenderer))
857 CreateRenderWidgetWindowTreeClientFactory();
858 #endif
859
860 GetRemoteInterfaces()->GetInterface( 865 GetRemoteInterfaces()->GetInterface(
861 mojo::GetProxy(&storage_partition_service_)); 866 mojo::GetProxy(&storage_partition_service_));
862 867
863 is_renderer_suspended_ = false; 868 is_renderer_suspended_ = false;
864 } 869 }
865 870
866 RenderThreadImpl::~RenderThreadImpl() { 871 RenderThreadImpl::~RenderThreadImpl() {
867 } 872 }
868 873
869 void RenderThreadImpl::Shutdown() { 874 void RenderThreadImpl::Shutdown() {
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 bool use_software, 1820 bool use_software,
1816 int routing_id, 1821 int routing_id,
1817 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, 1822 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue,
1818 const GURL& url) { 1823 const GURL& url) {
1819 const base::CommandLine& command_line = 1824 const base::CommandLine& command_line =
1820 *base::CommandLine::ForCurrentProcess(); 1825 *base::CommandLine::ForCurrentProcess();
1821 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) 1826 if (command_line.HasSwitch(switches::kDisableGpuCompositing))
1822 use_software = true; 1827 use_software = true;
1823 1828
1824 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) 1829 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA)
1825 if (ChildThread::Get()->GetMojoShellConnection() && !use_software && 1830 if (GetMojoShellConnection() && !use_software &&
1826 command_line.HasSwitch(switches::kUseMusInRenderer)) { 1831 command_line.HasSwitch(switches::kUseMusInRenderer)) {
1827 RenderWidgetMusConnection* connection = 1832 RenderWidgetMusConnection* connection =
1828 RenderWidgetMusConnection::GetOrCreate(routing_id); 1833 RenderWidgetMusConnection::GetOrCreate(routing_id);
1829 return connection->CreateOutputSurface(); 1834 return connection->CreateOutputSurface();
1830 } 1835 }
1831 #endif 1836 #endif
1832 1837
1833 uint32_t output_surface_id = g_next_output_surface_id++; 1838 uint32_t output_surface_id = g_next_output_surface_id++;
1834 1839
1835 if (command_line.HasSwitch(switches::kEnableVulkan)) { 1840 if (command_line.HasSwitch(switches::kEnableVulkan)) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) 2228 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical)
2224 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; 2229 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate;
2225 2230
2226 blink::mainThreadIsolate()->MemoryPressureNotification( 2231 blink::mainThreadIsolate()->MemoryPressureNotification(
2227 v8_memory_pressure_level); 2232 v8_memory_pressure_level);
2228 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2233 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2229 v8_memory_pressure_level); 2234 v8_memory_pressure_level);
2230 } 2235 }
2231 2236
2232 } // namespace content 2237 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mus/render_widget_window_tree_client_factory.cc ('k') | content/renderer/renderer_blink_platform_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698