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 { ...@@ -229,10 +229,3 @@ interface ArcBridgeHost {
// Notifies Chrome that the WallpaperInstance interface is ready. // Notifies Chrome that the WallpaperInstance interface is ready.
[MinVersion=18] OnWallpaperInstanceReady@124(WallpaperInstance instance_ptr); [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 { ...@@ -69,17 +69,12 @@ namespace arc {
ArcBridgeHostImpl::ArcBridgeHostImpl( ArcBridgeHostImpl::ArcBridgeHostImpl(
ArcBridgeService* arc_bridge_service, ArcBridgeService* arc_bridge_service,
mojo::PendingRemote<mojom::ArcBridgeInstance> instance) mojo::PendingReceiver<mojom::ArcBridgeHost> pending_receiver)
: arc_bridge_service_(arc_bridge_service), : arc_bridge_service_(arc_bridge_service),
receiver_(this), receiver_(this, std::move(pending_receiver)) {
instance_(std::move(instance)) {
DCHECK(arc_bridge_service_); DCHECK(arc_bridge_service_);
DCHECK(instance_.is_bound()); receiver_.set_disconnect_handler(
instance_.set_disconnect_handler(
base::BindOnce(&ArcBridgeHostImpl::OnClosed, base::Unretained(this))); 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() { ArcBridgeHostImpl::~ArcBridgeHostImpl() {
...@@ -364,9 +359,7 @@ void ArcBridgeHostImpl::OnClosed() { ...@@ -364,9 +359,7 @@ void ArcBridgeHostImpl::OnClosed() {
// Close all mojo channels. // Close all mojo channels.
mojo_channels_.clear(); mojo_channels_.clear();
instance_.reset(); receiver_.reset();
if (receiver_.is_bound())
receiver_.reset();
arc_bridge_service_->ObserveAfterArcBridgeClosed(); arc_bridge_service_->ObserveAfterArcBridgeClosed();
} }
......
...@@ -23,9 +23,9 @@ class ArcBridgeService; ...@@ -23,9 +23,9 @@ class ArcBridgeService;
class MojoChannelBase; class MojoChannelBase;
// Implementation of the ArcBridgeHost. // Implementation of the ArcBridgeHost.
// The lifetime of ArcBridgeHost and ArcBridgeInstance mojo channels are tied // The lifetime of ArcBridgeHost mojo channel is tied to this instance.
// to this instance. Also, any ARC related Mojo channel will be closed if // Also, any ARC related Mojo channel will be closed if ArcBridgeHost Mojo
// either ArcBridgeHost or ArcBridgeInstance Mojo channels is closed on error. // channel is closed on error.
// When ARC Instance (not Host) Mojo channel gets ready (= passed via // When ARC Instance (not Host) Mojo channel gets ready (= passed via
// OnFooInstanceReady(), and the QueryVersion() gets completed), then this sets // OnFooInstanceReady(), and the QueryVersion() gets completed), then this sets
// the raw pointer to the ArcBridgeService so that other services can access // the raw pointer to the ArcBridgeService so that other services can access
...@@ -33,8 +33,9 @@ class MojoChannelBase; ...@@ -33,8 +33,9 @@ class MojoChannelBase;
// Note that ArcBridgeService must be alive while ArcBridgeHostImpl is alive. // Note that ArcBridgeService must be alive while ArcBridgeHostImpl is alive.
class ArcBridgeHostImpl : public mojom::ArcBridgeHost { class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
public: public:
ArcBridgeHostImpl(ArcBridgeService* arc_bridge_service, ArcBridgeHostImpl(
mojo::PendingRemote<mojom::ArcBridgeInstance> instance); ArcBridgeService* arc_bridge_service,
mojo::PendingReceiver<mojom::ArcBridgeHost> pending_receiver);
~ArcBridgeHostImpl() override; ~ArcBridgeHostImpl() override;
// ArcBridgeHost overrides. // ArcBridgeHost overrides.
...@@ -141,7 +142,6 @@ class ArcBridgeHostImpl : public mojom::ArcBridgeHost { ...@@ -141,7 +142,6 @@ class ArcBridgeHostImpl : public mojom::ArcBridgeHost {
ArcBridgeService* const arc_bridge_service_; ArcBridgeService* const arc_bridge_service_;
mojo::Receiver<mojom::ArcBridgeHost> receiver_; mojo::Receiver<mojom::ArcBridgeHost> receiver_;
mojo::Remote<mojom::ArcBridgeInstance> instance_;
// Put as a last member to ensure that any callback tied to the elements // Put as a last member to ensure that any callback tied to the elements
// is not invoked. // is not invoked.
......
...@@ -277,11 +277,16 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal( ...@@ -277,11 +277,16 @@ mojo::ScopedMessagePipeHandle ArcSessionDelegateImpl::ConnectMojoInternal(
std::vector<base::ScopedFD> fds; std::vector<base::ScopedFD> fds;
fds.emplace_back(channel.TakeRemoteEndpoint().TakePlatformHandle().TakeFD()); 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 // We need to send the length of the message as a single byte, so make sure it
// fits. // fits.
DCHECK_LT(token.size(), 256u); DCHECK_LT(token.size(), 256u);
uint8_t message_length = static_cast<uint8_t>(token.size()); 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()}}; {const_cast<char*>(token.c_str()), token.size()}};
ssize_t result = mojo::SendmsgWithHandles(connection_fd.get(), iov, ssize_t result = mojo::SendmsgWithHandles(connection_fd.get(), iov,
sizeof(iov) / sizeof(iov[0]), fds); sizeof(iov) / sizeof(iov[0]), fds);
...@@ -303,8 +308,8 @@ void ArcSessionDelegateImpl::OnMojoConnected( ...@@ -303,8 +308,8 @@ void ArcSessionDelegateImpl::OnMojoConnected(
} }
std::move(callback).Run(std::make_unique<ArcBridgeHostImpl>( std::move(callback).Run(std::make_unique<ArcBridgeHostImpl>(
arc_bridge_service_, mojo::PendingRemote<mojom::ArcBridgeInstance>( arc_bridge_service_,
std::move(server_pipe), 0u))); mojo::PendingReceiver<mojom::ArcBridgeHost>(std::move(server_pipe))));
} }
} // namespace } // 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