diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/content/browser/browser_main_loop.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/content/browser/browser_main_loop.cc')
-rw-r--r-- | chromium/content/browser/browser_main_loop.cc | 126 |
1 files changed, 36 insertions, 90 deletions
diff --git a/chromium/content/browser/browser_main_loop.cc b/chromium/content/browser/browser_main_loop.cc index d014ef7e1d8..4ada8596176 100644 --- a/chromium/content/browser/browser_main_loop.cc +++ b/chromium/content/browser/browser_main_loop.cc @@ -39,7 +39,6 @@ #include "base/strings/string_split.h" #include "base/synchronization/waitable_event.h" #include "base/system/system_monitor.h" -#include "base/task/post_task.h" #include "base/task/thread_pool/initialization_util.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" @@ -112,6 +111,7 @@ #include "content/public/common/main_function_params.h" #include "content/public/common/result_codes.h" #include "content/public/common/service_names.mojom.h" +#include "content/public/common/zygote/zygote_buildflags.h" #include "device/fido/hid/fido_hid_discovery.h" #include "device/gamepad/gamepad_service.h" #include "media/audio/audio_manager.h" @@ -134,7 +134,6 @@ #include "services/content/public/cpp/navigable_contents_view.h" #include "services/data_decoder/public/cpp/service_provider.h" #include "services/network/transitional_url_loader_factory_owner.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "skia/ext/event_tracer_impl.h" #include "skia/ext/skia_memory_dump_provider.h" #include "sql/sql_memory_dump_provider.h" @@ -182,7 +181,6 @@ #include "content/browser/renderer_host/dwrite_font_lookup_table_builder_win.h" #include "net/base/winsock_init.h" #include "services/service_manager/sandbox/win/sandbox_win.h" -#include "ui/display/win/screen_win.h" #endif #if defined(OS_CHROMEOS) @@ -225,6 +223,7 @@ #if defined(USE_X11) #include "gpu/config/gpu_driver_bug_workaround_type.h" +#include "ui/base/ui_base_features.h" #include "ui/base/x/x11_util_internal.h" // nogncheck #include "ui/gfx/x/x11_types.h" // nogncheck #endif @@ -419,8 +418,8 @@ class OopDataDecoder : public data_decoder::ServiceProvider { void BindHidManager(mojo::PendingReceiver<device::mojom::HidManager> receiver) { #if !defined(OS_ANDROID) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&BindHidManager, std::move(receiver))); + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BindHidManager, std::move(receiver))); return; } @@ -454,7 +453,8 @@ class GpuDataManagerVisualProxy : public GpuDataManagerObserver { if (!ui::XVisualManager::GetInstance()->OnGPUInfoChanged( gpu_info.software_rendering || !gpu_data_manager_->GpuAccessAllowed(nullptr), - gpu_extra_info.system_visual, gpu_extra_info.rgba_visual)) { + static_cast<x11::VisualId>(gpu_extra_info.system_visual), + static_cast<x11::VisualId>(gpu_extra_info.rgba_visual))) { // The GPU process sent back bad visuals, which should never happen. auto* gpu_process_host = GpuProcessHost::Get(GPU_PROCESS_KIND_SANDBOXED, false); @@ -474,49 +474,6 @@ class GpuDataManagerVisualProxy : public GpuDataManagerObserver { } // namespace internal #endif -#if defined(OS_WIN) -namespace { - -// Provides a bridge whereby display::win::ScreenWin can ask the GPU process -// about the HDR status of the system. -class HDRProxy { - public: - static void Initialize() { - display::win::ScreenWin::SetRequestHDRStatusCallback( - base::BindRepeating(&HDRProxy::RequestHDRStatus)); - } - - static void RequestHDRStatus() { - // The request must be sent to the GPU process from the IO thread. - base::PostTask(FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&HDRProxy::RequestOnIOThread)); - } - - private: - static void RequestOnIOThread() { - auto* gpu_process_host = - GpuProcessHost::Get(GPU_PROCESS_KIND_SANDBOXED, false); - if (gpu_process_host) { - auto* gpu_service = gpu_process_host->gpu_host()->gpu_service(); - gpu_service->RequestHDRStatus( - base::BindOnce(&HDRProxy::GotResultOnIOThread)); - } else { - bool hdr_enabled = false; - GotResultOnIOThread(hdr_enabled); - } - } - static void GotResultOnIOThread(bool hdr_enabled) { - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&HDRProxy::GotResult, hdr_enabled)); - } - static void GotResult(bool hdr_enabled) { - display::win::ScreenWin::SetHDREnabled(hdr_enabled); - } -}; - -} // namespace -#endif - // The currently-running BrowserMainLoop. There can be one or zero. BrowserMainLoop* g_current_browser_main_loop = nullptr; @@ -612,10 +569,9 @@ int BrowserMainLoop::EarlyInitialization() { #endif #if defined(USE_X11) - if (UsingInProcessGpu()) { - if (!gfx::GetXDisplay()) { - LOG(ERROR) << "Failed to open an X11 connection."; - } + if (!features::IsUsingOzonePlatform() && UsingInProcessGpu() && + !gfx::GetXDisplay()) { + LOG(ERROR) << "Failed to open an X11 connection."; } #endif @@ -766,10 +722,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() { online_state_observer_.reset(new BrowserOnlineStateObserver); } - { - base::SetRecordActionTaskRunner( - base::CreateSingleThreadTaskRunner({BrowserThread::UI})); - } + { base::SetRecordActionTaskRunner(GetUIThreadTaskRunner({})); } // TODO(boliu): kSingleProcess check is a temporary workaround for // in-process Android WebView. crbug.com/503724 tracks proper fix. @@ -818,10 +771,11 @@ void BrowserMainLoop::PostMainMessageLoopStart() { } int BrowserMainLoop::PreCreateThreads() { + TRACE_EVENT0("startup", "BrowserMainLoop::PreCreateThreads"); + // Make sure no accidental call to initialize GpuDataManager earlier. DCHECK(!GpuDataManagerImpl::Initialized()); if (parts_) { - TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PreCreateThreads"); result_code_ = parts_->PreCreateThreads(); } @@ -834,7 +788,7 @@ int BrowserMainLoop::PreCreateThreads() { // but must be created on the main thread. The service ctor is // inexpensive and does not invoke the io_thread() accessor. { - TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService"); + TRACE_EVENT0("startup", "BrowserMainLoop::PluginService"); PluginService::GetInstance()->Init(); } #endif @@ -863,8 +817,11 @@ int BrowserMainLoop::PreCreateThreads() { DCHECK(GpuDataManagerImpl::Initialized()); #if defined(USE_X11) - gpu_data_manager_visual_proxy_.reset(new internal::GpuDataManagerVisualProxy( - GpuDataManagerImpl::GetInstance())); + if (!features::IsUsingOzonePlatform()) { + gpu_data_manager_visual_proxy_.reset( + new internal::GpuDataManagerVisualProxy( + GpuDataManagerImpl::GetInstance())); + } #endif #if !BUILDFLAG(GOOGLE_CHROME_BRANDING) || defined(OS_ANDROID) @@ -898,8 +855,7 @@ void BrowserMainLoop::CreateStartupTasks() { startup_task_runner_ = std::make_unique<StartupTaskRunner>( base::BindOnce(&BrowserStartupComplete), - base::CreateSingleThreadTaskRunner( - {BrowserThread::UI, BrowserTaskType::kBootstrap})); + GetUIThreadTaskRunner({BrowserTaskType::kBootstrap})); #else startup_task_runner_ = std::make_unique<StartupTaskRunner>( base::OnceCallback<void(int)>(), base::ThreadTaskRunnerHandle::Get()); @@ -1015,8 +971,7 @@ int BrowserMainLoop::PreMainMessageLoopRun() { #endif if (parts_) { - TRACE_EVENT0("startup", - "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); + TRACE_EVENT0("startup", "BrowserMainLoop::PreMainMessageLoopRun"); parts_->PreMainMessageLoopRun(); } @@ -1042,18 +997,12 @@ int BrowserMainLoop::PreMainMessageLoopRun() { } void BrowserMainLoop::RunMainMessageLoopParts() { - // Don't use the TRACE_EVENT0 macro because the tracing infrastructure doesn't - // expect synchronous events around the main loop of a thread. - TRACE_EVENT_ASYNC_BEGIN0("toplevel", "BrowserMain:MESSAGE_LOOP", this); - bool ran_main_loop = false; if (parts_) ran_main_loop = parts_->MainMessageLoopRun(&result_code_); if (!ran_main_loop) MainMessageLoopRun(); - - TRACE_EVENT_ASYNC_END0("toplevel", "BrowserMain:MESSAGE_LOOP", this); } void BrowserMainLoop::ShutdownThreadsAndCleanUp() { @@ -1066,8 +1015,8 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { // Teardown may start in PostMainMessageLoopRun, and during teardown we // need to be able to perform IO. base::ThreadRestrictions::SetIOAllowed(true); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), true)); @@ -1077,8 +1026,8 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { // no persistent work is being done after ThreadPoolInstance::Shutdown() in // order to move towards atomic shutdown. base::ThreadRestrictions::SetWaitAllowed(true); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( base::IgnoreResult(&base::ThreadRestrictions::SetWaitAllowed), true)); @@ -1254,13 +1203,12 @@ int BrowserMainLoop::BrowserThreadsStarted() { // Initialize the GPU shader cache. This needs to be initialized before // BrowserGpuChannelHostFactory below, since that depends on an initialized // ShaderCacheFactory. - InitShaderCacheFactorySingleton( - base::CreateSingleThreadTaskRunner({BrowserThread::IO})); + InitShaderCacheFactorySingleton(GetIOThreadTaskRunner({})); // Initialize the FontRenderParams on IO thread. This needs to be initialized // before gpu process initialization below. - base::PostTask(FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&viz::GpuHostImpl::InitFontRenderParams, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&viz::GpuHostImpl::InitFontRenderParams, gfx::GetFontRenderParams( gfx::FontRenderParamsQuery(), nullptr))); @@ -1322,7 +1270,6 @@ int BrowserMainLoop::BrowserThreadsStarted() { } #if defined(OS_WIN) - HDRProxy::Initialize(); system_message_window_.reset(new media::SystemMessageWindowWin); #elif defined(OS_LINUX) && defined(USE_UDEV) device_monitor_linux_ = std::make_unique<media::DeviceMonitorLinux>(); @@ -1402,8 +1349,8 @@ int BrowserMainLoop::BrowserThreadsStarted() { !established_gpu_channel && always_uses_gpu) { TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process", TRACE_EVENT_SCOPE_THREAD); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(base::IgnoreResult(&GpuProcessHost::Get), GPU_PROCESS_KIND_SANDBOXED, true /* force_create */)); } @@ -1464,7 +1411,8 @@ bool BrowserMainLoop::InitializeToolkit() { #if defined(USE_AURA) #if defined(USE_X11) - if (!parsed_command_line_.HasSwitch(switches::kHeadless) && + if (!features::IsUsingOzonePlatform() && + !parsed_command_line_.HasSwitch(switches::kHeadless) && !gfx::GetXDisplay()) { LOG(ERROR) << "Unable to open X display."; return false; @@ -1553,13 +1501,11 @@ void BrowserMainLoop::InitializeAudio() { if (base::FeatureList::IsEnabled(features::kAudioServiceLaunchOnStartup)) { // Schedule the audio service startup on the main thread. - base::PostTask( - FROM_HERE, - {content::BrowserThread::UI, base::TaskPriority::BEST_EFFORT}, - base::BindOnce([]() { - TRACE_EVENT0("audio", "Starting audio service"); - GetAudioService(); - })); + content::GetUIThreadTaskRunner({base::TaskPriority::BEST_EFFORT}) + ->PostTask(FROM_HERE, base::BindOnce([]() { + TRACE_EVENT0("audio", "Starting audio service"); + GetAudioService(); + })); } audio_system_ = CreateAudioSystemForAudioService(); |