Commit 8e79fa3a authored by Ryo Hashimoto's avatar Ryo Hashimoto Committed by Commit Bot

arc: Remove ArcBridgeInstance

Use the message pipe attached to the invitation for ArcBridgeHost.
This requires Android version which includes the corresponding change.

BUG=b:151063537
TEST=Launch Play Store

Change-Id: Id326252882bdd3f845f4a126a91a8f5fb2b77b5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094840Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756897}
parent de7582f5
......@@ -229,10 +229,3 @@ interface ArcBridgeHost {
// Notifies Chrome that the WallpaperInstance interface is ready.
[MinVersion=18] OnWallpaperInstanceReady@124(WallpaperInstance instance_ptr);
};
interface ArcBridgeInstance {
// Establishes full-duplex communication with the host.
// |host_ptr| is the MessagePipe endpoint that is bound to the
// ArcBridgeHostPtr binding.
Init@0(ArcBridgeHost host_ptr);
};
......@@ -69,17 +69,12 @@ namespace arc {
ArcBridgeHostImpl::ArcBridgeHostImpl(
ArcBridgeService* arc_bridge_service,
mojo::PendingRemote<mojom::ArcBridgeInstance> instance)
mojo::PendingReceiver<mojom::ArcBridgeHost> pending_receiver)
: arc_bridge_service_(arc_bridge_service),
receiver_(this),
instance_(std::move(instance)) {
receiver_(this, std::move(pending_receiver)) {
DCHECK(arc_bridge_service_);
DCHECK(instance_.is_bound());
instance_.set_disconnect_handler(
receiver_.set_disconnect_handler(
base::BindOnce(&ArcBridgeHostImpl::OnClosed, base::Unretained(this)));
mojom::ArcBridgeHostPtr host_proxy;
receiver_.Bind(mojo::MakeRequest(&host_proxy));
instance_->Init(std::move(host_proxy));
}
ArcBridgeHostImpl::~ArcBridgeHostImpl() {
......@@ -364,9 +359,7 @@ void ArcBridgeHostImpl::OnClosed() {
// Close all mojo channels.
mojo_channels_.clear();
instance_.reset();
if (receiver_.is_bound())
receiver_.reset();
receiver_.reset();
arc_bridge_service_->ObserveAfterArcBridgeClosed();
}
......
......@@ -23,9 +23,9 @@ class ArcBridgeService;
class MojoChannelBase;
// Implementation of the ArcBridgeHost.
// The lifetime of ArcBridgeHost and ArcBridgeInstance mojo channels are tied
// to this instance. Also, any ARC related Mojo channel will be closed if
// either ArcBridgeHost or ArcBridgeInstance Mojo channels is closed on error.
// The lifetime of ArcBridgeHost mojo channel is tied to this instance.
// Also, any ARC related Mojo channel will be closed if ArcBridgeHost Mojo
// channel is closed on error.
// When ARC Instance (not Host) Mojo channel gets ready (= passed via
// OnFooInstanceReady(), and the QueryVersion() gets completed), then this sets
// the raw pointer to the ArcBridgeService so that other services can access
......@@ -33,8 +33,9 @@ class MojoChannelBase;
// Note that ArcBridgeService must be alive while ArcBridgeHostImpl is alive.
class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
public:
ArcBridgeHostImpl(ArcBridgeService* arc_bridge_service,
mojo::PendingRemote<mojom::ArcBridgeInstance> instance);
ArcBridgeHostImpl(
ArcBridgeService* arc_bridge_service,
mojo::PendingReceiver<mojom::ArcBridgeHost> pending_receiver);
~ArcBridgeHostImpl() override;
// ArcBridgeHost overrides.
......@@ -141,7 +142,6 @@ class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
ArcBridgeService* const arc_bridge_service_;
mojo::Receiver<mojom::ArcBridgeHost> receiver_;
mojo::Remote<mojom::ArcBridgeInstance> instance_;
// Put as a last member to ensure that any callback tied to the elements
// is not invoked.
......
......@@ -277,11 +277,16 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal(
std::vector<base::ScopedFD> fds;
fds.emplace_back(channel.TakeRemoteEndpoint().TakePlatformHandle().TakeFD());
// Version of protocol chrome is using.
uint8_t protocol_version = 0;
// We need to send the length of the message as a single byte, so make sure it
// fits.
DCHECK_LT(token.size(), 256u);
uint8_t message_length = static_cast<uint8_t>(token.size());
struct iovec iov[] = {{&message_length, sizeof(message_length)},
struct iovec iov[] = {{&protocol_version, sizeof(protocol_version)},
{&message_length, sizeof(message_length)},
{const_cast<char*>(token.c_str()), token.size()}};
ssize_t result = mojo::SendmsgWithHandles(connection_fd.get(), iov,
sizeof(iov) / sizeof(iov[0]), fds);
......@@ -303,8 +308,8 @@ void ArcSessionDelegateImpl::OnMojoConnected(
}
std::move(callback).Run(std::make_unique<ArcBridgeHostImpl>(
arc_bridge_service_, mojo::PendingRemote<mojom::ArcBridgeInstance>(
std::move(server_pipe), 0u)));
arc_bridge_service_,
mojo::PendingReceiver<mojom::ArcBridgeHost>(std::move(server_pipe))));
}
} // namespace
......
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