Commit bd784801 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Pass approprite task runners to AssociatedBinding::Bind via AssociateInterfaceProviderImpl

This is part of efforts to replace base::ThreadTaskRunnerHandle::Get()
and SequencedTaskRunnerHandle::Get() with other appropriate task runners
in the renderer.

Bug: 786332
Change-Id: Id56592620375d8a62825511a93a825e135c28f60
Reviewed-on: https://chromium-review.googlesource.com/980015
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546778}
parent d5e1f8bf
......@@ -12,10 +12,12 @@ namespace content {
class AssociatedInterfaceProviderImpl::LocalProvider
: public mojom::AssociatedInterfaceProvider {
public:
explicit LocalProvider(mojom::AssociatedInterfaceProviderAssociatedPtr* proxy)
LocalProvider(mojom::AssociatedInterfaceProviderAssociatedPtr* proxy,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: associated_interface_provider_binding_(this) {
associated_interface_provider_binding_.Bind(
mojo::MakeRequestAssociatedWithDedicatedPipe(proxy));
mojo::MakeRequestAssociatedWithDedicatedPipe(proxy),
std::move(task_runner));
}
~LocalProvider() override {}
......@@ -46,13 +48,16 @@ class AssociatedInterfaceProviderImpl::LocalProvider
};
AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl(
mojom::AssociatedInterfaceProviderAssociatedPtr proxy)
: proxy_(std::move(proxy)) {
mojom::AssociatedInterfaceProviderAssociatedPtr proxy,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: proxy_(std::move(proxy)), task_runner_(std::move(task_runner)) {
DCHECK(proxy_.is_bound());
}
AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl()
: local_provider_(std::make_unique<LocalProvider>(&proxy_)) {}
AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: local_provider_(std::make_unique<LocalProvider>(&proxy_, task_runner)),
task_runner_(std::move(task_runner)) {}
AssociatedInterfaceProviderImpl::~AssociatedInterfaceProviderImpl() {}
......@@ -69,7 +74,7 @@ void AssociatedInterfaceProviderImpl::OverrideBinderForTesting(
if (!local_provider_) {
DCHECK(proxy_.is_bound());
proxy_.reset();
local_provider_ = std::make_unique<LocalProvider>(&proxy_);
local_provider_ = std::make_unique<LocalProvider>(&proxy_, task_runner_);
}
local_provider_->SetBinderForName(name, binder);
}
......
......@@ -19,12 +19,21 @@ class AssociatedInterfaceProviderImpl
: public blink::AssociatedInterfaceProvider {
public:
// Binds this to a remote mojom::AssociatedInterfaceProvider.
//
// |task_runner| must belong to the same thread. It will be used to dispatch
// all callbacks and connection error notification.
explicit AssociatedInterfaceProviderImpl(
mojom::AssociatedInterfaceProviderAssociatedPtr proxy);
mojom::AssociatedInterfaceProviderAssociatedPtr proxy,
scoped_refptr<base::SingleThreadTaskRunner> task_runner = nullptr);
// Constructs a local provider with no remote interfaces. This is useful in
// conjunction with OverrideBinderForTesting(), in test environments where
// there may not be a remote |mojom::AssociatedInterfaceProvider| available.
AssociatedInterfaceProviderImpl();
//
// |task_runner| must belong to the same thread. It will be used to dispatch
// all callbacks and connection error notification.
explicit AssociatedInterfaceProviderImpl(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~AssociatedInterfaceProviderImpl() override;
// AssociatedInterfaceProvider:
......@@ -41,6 +50,7 @@ class AssociatedInterfaceProviderImpl
mojom::AssociatedInterfaceProviderAssociatedPtr proxy_;
std::unique_ptr<LocalProvider> local_provider_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceProviderImpl);
};
......
......@@ -2910,13 +2910,14 @@ RenderFrameImpl::GetRemoteAssociatedInterfaces() {
mojom::AssociatedInterfaceProviderAssociatedPtr remote_interfaces;
thread->GetRemoteRouteProvider()->GetRoute(
routing_id_, mojo::MakeRequest(&remote_interfaces));
remote_associated_interfaces_.reset(
new AssociatedInterfaceProviderImpl(std::move(remote_interfaces)));
remote_associated_interfaces_.reset(new AssociatedInterfaceProviderImpl(
std::move(remote_interfaces),
GetTaskRunner(blink::TaskType::kInternalIPC)));
} else {
// In some tests the thread may be null,
// so set up a self-contained interface provider instead.
remote_associated_interfaces_.reset(
new AssociatedInterfaceProviderImpl());
remote_associated_interfaces_.reset(new AssociatedInterfaceProviderImpl(
GetTaskRunner(blink::TaskType::kInternalIPC)));
}
}
return remote_associated_interfaces_.get();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment