diff options
Diffstat (limited to 'src/core/content_utility_client_qt.cpp')
-rw-r--r-- | src/core/content_utility_client_qt.cpp | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/src/core/content_utility_client_qt.cpp b/src/core/content_utility_client_qt.cpp index 0b2dbd08e..12a538a07 100644 --- a/src/core/content_utility_client_qt.cpp +++ b/src/core/content_utility_client_qt.cpp @@ -39,9 +39,8 @@ #include "content_utility_client_qt.h" -#include "base/bind.h" -#include "content/public/utility/utility_thread.h" -#include "services/proxy_resolver/proxy_resolver_service.h" +#include "base/no_destructor.h" +#include "services/proxy_resolver/proxy_resolver_factory_impl.h" namespace QtWebEngineCore { @@ -51,41 +50,12 @@ ContentUtilityClientQt::ContentUtilityClientQt() ContentUtilityClientQt::~ContentUtilityClientQt() = default; -namespace { - -std::unique_ptr<service_manager::Service> CreateProxyResolverService(service_manager::mojom::ServiceRequest request) +void ContentUtilityClientQt::RunIOThreadService(mojo::GenericPendingReceiver *receiver) { - return std::make_unique<proxy_resolver::ProxyResolverService>(std::move(request)); -} - -using ServiceFactory = base::OnceCallback<std::unique_ptr<service_manager::Service>()>; -void RunServiceOnIOThread(ServiceFactory factory) -{ - base::OnceClosure terminate_process = base::BindOnce( - base::IgnoreResult(&base::SequencedTaskRunner::PostTask), - base::SequencedTaskRunnerHandle::Get(), FROM_HERE, - base::BindOnce([] { content::UtilityThread::Get()->ReleaseProcess(); })); - content::ChildThread::Get()->GetIOTaskRunner()->PostTask( - FROM_HERE, - base::BindOnce( - [](ServiceFactory factory, base::OnceClosure terminate_process) { - service_manager::Service::RunAsyncUntilTermination( - std::move(factory).Run(), std::move(terminate_process)); - }, - std::move(factory), std::move(terminate_process))); -} - -} // namespace - -bool ContentUtilityClientQt::HandleServiceRequest(const std::string &service_name, - service_manager::mojom::ServiceRequest request) -{ - if (service_name == proxy_resolver::mojom::kProxyResolverServiceName) { - RunServiceOnIOThread(base::BindOnce(&CreateProxyResolverService, std::move(request))); - return true; + if (auto factory_receiver = receiver->As<proxy_resolver::mojom::ProxyResolverFactory>()) { + static base::NoDestructor<proxy_resolver::ProxyResolverFactoryImpl> factory(std::move(factory_receiver)); + return; } - - return false; } } // namespace |