Commit ed65b245 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Make MultiplexedChannel::IsDisconnect{ing|ed}() const.

Additionally, add the ability for FakeMultiplexedChannel to run a
callback in its destructor.

Bug: 824568, 752273
Change-Id: I1dd571d79c3e73228481efb2b68b210dbeb041f1
Reviewed-on: https://chromium-review.googlesource.com/1072164Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561577}
parent dd978e31
......@@ -10,10 +10,15 @@ namespace secure_channel {
FakeMultiplexedChannel::FakeMultiplexedChannel(
Delegate* delegate,
ConnectionDetails connection_details)
: MultiplexedChannel(delegate, connection_details) {}
FakeMultiplexedChannel::~FakeMultiplexedChannel() = default;
ConnectionDetails connection_details,
base::OnceCallback<void(const ConnectionDetails&)> destructor_callback)
: MultiplexedChannel(delegate, connection_details),
destructor_callback_(std::move(destructor_callback)) {}
FakeMultiplexedChannel::~FakeMultiplexedChannel() {
if (destructor_callback_)
std::move(destructor_callback_).Run(connection_details());
}
void FakeMultiplexedChannel::SetDisconnecting() {
DCHECK(!is_disconnected_);
......@@ -27,11 +32,11 @@ void FakeMultiplexedChannel::SetDisconnected() {
is_disconnected_ = true;
}
bool FakeMultiplexedChannel::IsDisconnecting() {
bool FakeMultiplexedChannel::IsDisconnecting() const {
return is_disconnecting_;
}
bool FakeMultiplexedChannel::IsDisconnected() {
bool FakeMultiplexedChannel::IsDisconnected() const {
return is_disconnected_;
}
......
......@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
#include "chromeos/services/secure_channel/client_connection_parameters.h"
#include "chromeos/services/secure_channel/connection_details.h"
......@@ -21,8 +22,11 @@ namespace secure_channel {
// Test MultiplexedChannel implementation.
class FakeMultiplexedChannel : public MultiplexedChannel {
public:
FakeMultiplexedChannel(Delegate* delegate,
ConnectionDetails connection_details);
FakeMultiplexedChannel(
Delegate* delegate,
ConnectionDetails connection_details,
base::OnceCallback<void(const ConnectionDetails&)> destructor_callback =
base::OnceCallback<void(const ConnectionDetails&)>());
~FakeMultiplexedChannel() override;
std::vector<ClientConnectionParameters>& added_clients() {
......@@ -37,8 +41,8 @@ class FakeMultiplexedChannel : public MultiplexedChannel {
private:
// MultiplexedChannel:
bool IsDisconnecting() override;
bool IsDisconnected() override;
bool IsDisconnecting() const override;
bool IsDisconnected() const override;
void PerformAddClientToChannel(
ClientConnectionParameters client_connection_parameters) override;
......@@ -47,6 +51,8 @@ class FakeMultiplexedChannel : public MultiplexedChannel {
std::vector<ClientConnectionParameters> added_clients_;
base::OnceCallback<void(const ConnectionDetails&)> destructor_callback_;
DISALLOW_COPY_AND_ASSIGN(FakeMultiplexedChannel);
};
......
......@@ -30,8 +30,8 @@ class MultiplexedChannel {
virtual ~MultiplexedChannel();
virtual bool IsDisconnecting() = 0;
virtual bool IsDisconnected() = 0;
virtual bool IsDisconnecting() const = 0;
virtual bool IsDisconnected() const = 0;
// Shares this channel with an additional client. Returns whether this action
// was successful; all calls are expected to succeed unless the channel is
......
......@@ -75,11 +75,11 @@ MultiplexedChannelImpl::~MultiplexedChannelImpl() {
authenticated_channel_->RemoveObserver(this);
}
bool MultiplexedChannelImpl::IsDisconnecting() {
bool MultiplexedChannelImpl::IsDisconnecting() const {
return is_disconnecting_;
}
bool MultiplexedChannelImpl::IsDisconnected() {
bool MultiplexedChannelImpl::IsDisconnected() const {
return is_disconnected_;
}
......
......@@ -58,8 +58,8 @@ class MultiplexedChannelImpl : public MultiplexedChannel,
ConnectionDetails connection_details);
// MultiplexedChannel:
bool IsDisconnecting() override;
bool IsDisconnected() override;
bool IsDisconnecting() const override;
bool IsDisconnected() const override;
void PerformAddClientToChannel(
ClientConnectionParameters client_connection_parameters) override;
......
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