diff options
Diffstat (limited to 'src/core/web_engine_context_threads.cpp')
-rw-r--r-- | src/core/web_engine_context_threads.cpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/src/core/web_engine_context_threads.cpp b/src/core/web_engine_context_threads.cpp deleted file mode 100644 index 2d0f8a90c..000000000 --- a/src/core/web_engine_context_threads.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include "web_engine_context.h" - -#include "base/bind.h" -#include "base/task/post_task.h" -#include "base/threading/platform_thread.h" -#include "base/threading/thread_restrictions.h" -#include "content/browser/gpu/gpu_main_thread_factory.h" -#include "content/browser/renderer_host/render_process_host_impl.h" -#include "content/browser/utility_process_host.h" -#include "content/gpu/gpu_child_thread.h" -#include "content/gpu/gpu_process.h" -#include "content/gpu/in_process_gpu_thread.h" -#include "content/public/browser/browser_task_traits.h" -#include "content/public/browser/browser_thread.h" -#include "content/renderer/in_process_renderer_thread.h" -#include "content/utility/in_process_utility_thread.h" -#include "gpu/ipc/service/gpu_init.h" - -#include <memory> - -#include <QEventLoop> - -namespace QtWebEngineCore { - -struct GpuThreadControllerQt : content::GpuThreadController -{ - GpuThreadControllerQt(const content::InProcessChildThreadParams ¶ms, const gpu::GpuPreferences &gpuPreferences) - { - base::PostTask( - FROM_HERE, { content::BrowserThread::UI }, - base::BindOnce(&GpuThreadControllerQt::createGpuProcess, params, gpuPreferences)); - } - ~GpuThreadControllerQt() override - { - base::PostTask( - FROM_HERE, { content::BrowserThread::UI }, - base::BindOnce(&GpuThreadControllerQt::destroyGpuProcess)); - } - - static void createGpuProcess( - const content::InProcessChildThreadParams ¶ms, - const gpu::GpuPreferences &gpuPreferences) - { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (s_gpuProcessDestroyed) - return; - - s_gpuProcess = std::make_unique<content::GpuProcess>(base::ThreadPriority::NORMAL); - auto gpuInit = std::make_unique<gpu::GpuInit>(); - gpuInit->InitializeInProcess(base::CommandLine::ForCurrentProcess(), gpuPreferences); - auto childThread = new content::GpuChildThread(params, std::move(gpuInit)); - childThread->Init(base::Time::Now()); - s_gpuProcess->set_main_thread(childThread); - } - - static void destroyGpuProcess() - { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (s_gpuProcessDestroyed) - return; - - // viz::GpuServiceImpl::~GpuServiceImpl waits for io task. - base::ScopedAllowBaseSyncPrimitivesForTesting allow; - s_gpuProcess.reset(); - s_gpuProcessDestroyed = true; - } - - static std::unique_ptr<content::GpuProcess> s_gpuProcess; - static bool s_gpuProcessDestroyed; -}; - -std::unique_ptr<content::GpuProcess> GpuThreadControllerQt::s_gpuProcess; -bool GpuThreadControllerQt::s_gpuProcessDestroyed = false; - -static std::unique_ptr<content::GpuThreadController> createGpuThreadController( - const content::InProcessChildThreadParams ¶ms, - const gpu::GpuPreferences &gpuPreferences) -{ - return std::make_unique<GpuThreadControllerQt>(params, gpuPreferences); -} - -// static -void WebEngineContext::destroyGpuProcess() -{ - GpuThreadControllerQt::destroyGpuProcess(); -} - -// static -void WebEngineContext::registerMainThreadFactories() -{ - content::UtilityProcessHost::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread); - content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread); - if (!isGpuServiceOnUIThread()) - content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread); - else - content::RegisterGpuMainThreadFactory(createGpuThreadController); -} - -} // namespace QtWebEngineCore |