Commit ca7f9958 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert mojom::SecureChannel to new Mojo types

This CL converts SecureChannelPtr and SecureChannelRequest
to new Mojo types using PendingRemote or Remote,
PendingReceiver, and ReceiverSet.

Bug: 955171
Change-Id: Ida5773b8787a11018f1305f338d37cc17b79706d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1820920
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#700192}
parent 1960a8e2
......@@ -30,7 +30,7 @@ SecureChannelClient* SecureChannelClientProvider::GetClient() {
}()};
mojo::PendingRemote<mojom::SecureChannel> channel;
(*instance)->BindRequest(channel.InitWithNewPipeAndPassReceiver());
(*instance)->BindReceiver(channel.InitWithNewPipeAndPassReceiver());
secure_channel_client_ =
SecureChannelClientImpl::Factory::Get()->BuildInstance(
std::move(channel));
......
......@@ -45,7 +45,7 @@ SecureChannelClientImpl::Factory::BuildInstance(
SecureChannelClientImpl::SecureChannelClientImpl(
mojo::PendingRemote<mojom::SecureChannel> channel,
scoped_refptr<base::TaskRunner> task_runner)
: secure_channel_ptr_(std::move(channel)), task_runner_(task_runner) {}
: secure_channel_remote_(std::move(channel)), task_runner_(task_runner) {}
SecureChannelClientImpl::~SecureChannelClientImpl() = default;
......@@ -98,7 +98,7 @@ void SecureChannelClientImpl::PerformInitiateConnectionToDevice(
const std::string& feature,
ConnectionPriority connection_priority,
mojo::PendingRemote<mojom::ConnectionDelegate> connection_delegate_remote) {
secure_channel_ptr_->InitiateConnectionToDevice(
secure_channel_remote_->InitiateConnectionToDevice(
device_to_connect.GetRemoteDevice(), local_device.GetRemoteDevice(),
feature, connection_priority, std::move(connection_delegate_remote));
}
......@@ -109,13 +109,13 @@ void SecureChannelClientImpl::PerformListenForConnectionFromDevice(
const std::string& feature,
ConnectionPriority connection_priority,
mojo::PendingRemote<mojom::ConnectionDelegate> connection_delegate_remote) {
secure_channel_ptr_->ListenForConnectionFromDevice(
secure_channel_remote_->ListenForConnectionFromDevice(
device_to_connect.GetRemoteDevice(), local_device.GetRemoteDevice(),
feature, connection_priority, std::move(connection_delegate_remote));
}
void SecureChannelClientImpl::FlushForTesting() {
secure_channel_ptr_.FlushForTesting();
secure_channel_remote_.FlushForTesting();
}
} // namespace secure_channel
......
......@@ -9,6 +9,7 @@
#include "chromeos/services/secure_channel/public/cpp/client/secure_channel_client.h"
#include "chromeos/services/secure_channel/public/mojom/secure_channel.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace base {
class TaskRunner;
......@@ -72,7 +73,7 @@ class SecureChannelClientImpl : public SecureChannelClient {
void FlushForTesting();
mojom::SecureChannelPtr secure_channel_ptr_;
mojo::Remote<mojom::SecureChannel> secure_channel_remote_;
scoped_refptr<base::TaskRunner> task_runner_;
......
......@@ -150,7 +150,7 @@ class SecureChannelClientImplTest : public testing::Test {
test_task_runner_);
mojo::PendingRemote<mojom::SecureChannel> channel;
service_->BindRequest(channel.InitWithNewPipeAndPassReceiver());
service_->BindReceiver(channel.InitWithNewPipeAndPassReceiver());
client_ = SecureChannelClientImpl::Factory::Get()->BuildInstance(
std::move(channel), test_task_runner_);
}
......
......@@ -12,8 +12,9 @@ SecureChannelBase::SecureChannelBase() = default;
SecureChannelBase::~SecureChannelBase() = default;
void SecureChannelBase::BindRequest(mojom::SecureChannelRequest request) {
bindings_.AddBinding(this, std::move(request));
void SecureChannelBase::BindReceiver(
mojo::PendingReceiver<mojom::SecureChannel> receiver) {
receivers_.Add(this, std::move(receiver));
}
} // namespace secure_channel
......
......@@ -7,7 +7,8 @@
#include "base/macros.h"
#include "chromeos/services/secure_channel/public/mojom/secure_channel.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
namespace chromeos {
......@@ -18,15 +19,15 @@ class SecureChannelBase : public mojom::SecureChannel {
public:
~SecureChannelBase() override;
// Binds a request to this implementation. Should be called each time that the
// service receives a request.
void BindRequest(mojom::SecureChannelRequest request);
// Binds a receiver to this implementation. Should be called each time that
// the service receives a receiver.
void BindReceiver(mojo::PendingReceiver<mojom::SecureChannel> receiver);
protected:
SecureChannelBase();
private:
mojo::BindingSet<mojom::SecureChannel> bindings_;
mojo::ReceiverSet<mojom::SecureChannel> receivers_;
DISALLOW_COPY_AND_ASSIGN(SecureChannelBase);
};
......
......@@ -34,6 +34,7 @@
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
......@@ -379,8 +380,8 @@ class SecureChannelServiceTest : public testing::Test {
fake_client_connection_parameters_factory_.get());
service_ = SecureChannelInitializer::Factory::Get()->BuildInstance();
service_->BindRequest(mojo::MakeRequest(&secure_channel_ptr_));
secure_channel_ptr_.FlushForTesting();
service_->BindReceiver(secure_channel_remote_.BindNewPipeAndPassReceiver());
secure_channel_remote_.FlushForTesting();
}
void TearDown() override {
......@@ -804,16 +805,16 @@ class SecureChannelServiceTest : public testing::Test {
FakeConnectionDelegate fake_connection_delegate;
if (is_listener) {
secure_channel_ptr_->ListenForConnectionFromDevice(
secure_channel_remote_->ListenForConnectionFromDevice(
device_to_connect, local_device, feature, connection_priority,
fake_connection_delegate.GenerateRemote());
} else {
secure_channel_ptr_->InitiateConnectionToDevice(
secure_channel_remote_->InitiateConnectionToDevice(
device_to_connect, local_device, feature, connection_priority,
fake_connection_delegate.GenerateRemote());
}
secure_channel_ptr_.FlushForTesting();
secure_channel_remote_.FlushForTesting();
}
FakeActiveConnectionManager* fake_active_connection_manager() {
......@@ -866,7 +867,7 @@ class SecureChannelServiceTest : public testing::Test {
bool is_adapter_powered_;
bool is_adapter_present_;
mojom::SecureChannelPtr secure_channel_ptr_;
mojo::Remote<mojom::SecureChannel> secure_channel_remote_;
DISALLOW_COPY_AND_ASSIGN(SecureChannelServiceTest);
};
......
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