Commit 69309ed8 authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[CrOS Multidevice] Remove secure_channel::ClientChannel::Disconnect() method.

This method is unnecessary; if clients wish to disconnect a ClientChannel,
they simply need to delete the object.

Bug: 824568, 752273
Change-Id: I5ba7268743f8aabb208bc4add9ed849a982c7465
Reviewed-on: https://chromium-review.googlesource.com/1105609Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568340}
parent d201cbeb
...@@ -35,12 +35,6 @@ bool ClientChannel::SendMessage(const std::string& payload, ...@@ -35,12 +35,6 @@ bool ClientChannel::SendMessage(const std::string& payload,
return true; return true;
} }
void ClientChannel::Disconnect() {
// Clients should not attempt to disconnect an already-disconnected channel.
DCHECK(!is_disconnected_);
PerformDisconnection();
}
void ClientChannel::AddObserver(Observer* observer) { void ClientChannel::AddObserver(Observer* observer) {
observer_list_.AddObserver(observer); observer_list_.AddObserver(observer);
} }
......
...@@ -19,6 +19,9 @@ namespace secure_channel { ...@@ -19,6 +19,9 @@ namespace secure_channel {
// A full-duplex communication channel which is guaranteed to be authenticated // A full-duplex communication channel which is guaranteed to be authenticated
// (i.e., the two sides of the channel both belong to the same underlying user). // (i.e., the two sides of the channel both belong to the same underlying user).
// All messages sent and received over the channel are encrypted. // All messages sent and received over the channel are encrypted.
//
// If clients wish to disconnect the channel, they simply need to delete the
// object.
class ClientChannel { class ClientChannel {
public: public:
class Observer { class Observer {
...@@ -40,11 +43,6 @@ class ClientChannel { ...@@ -40,11 +43,6 @@ class ClientChannel {
bool SendMessage(const std::string& payload, bool SendMessage(const std::string& payload,
base::OnceClosure on_sent_callback); base::OnceClosure on_sent_callback);
// Disconnects this channel. Note that disconnection is an asynchronous
// operation; observers will be notified when disconnection completes via the
// OnDisconnected() callback.
void Disconnect();
bool is_disconnected() const { return is_disconnected_; } bool is_disconnected() const { return is_disconnected_; }
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
...@@ -62,11 +60,6 @@ class ClientChannel { ...@@ -62,11 +60,6 @@ class ClientChannel {
virtual void PerformGetConnectionMetadata( virtual void PerformGetConnectionMetadata(
base::OnceCallback<void(mojom::ConnectionMetadata)> callback) = 0; base::OnceCallback<void(mojom::ConnectionMetadata)> callback) = 0;
// Performs the actual logic of disconnecting. By the time this function is
// called, it has already been confirmed that the channel is still indeed
// connected.
virtual void PerformDisconnection() = 0;
void NotifyDisconnected(); void NotifyDisconnected();
void NotifyMessageReceived(const std::string& payload); void NotifyMessageReceived(const std::string& payload);
......
...@@ -72,12 +72,6 @@ void ClientChannelImpl::PerformSendMessage(const std::string& payload, ...@@ -72,12 +72,6 @@ void ClientChannelImpl::PerformSendMessage(const std::string& payload,
channel_->SendMessage(payload, std::move(on_sent_callback)); channel_->SendMessage(payload, std::move(on_sent_callback));
} }
void ClientChannelImpl::PerformDisconnection() {
channel_.reset();
binding_.Close();
NotifyDisconnected();
}
void ClientChannelImpl::OnChannelDisconnected( void ClientChannelImpl::OnChannelDisconnected(
uint32_t disconnection_reason, uint32_t disconnection_reason,
const std::string& disconnection_description) { const std::string& disconnection_description) {
...@@ -86,7 +80,9 @@ void ClientChannelImpl::OnChannelDisconnected( ...@@ -86,7 +80,9 @@ void ClientChannelImpl::OnChannelDisconnected(
<< disconnection_description; << disconnection_description;
} }
PerformDisconnection(); channel_.reset();
binding_.Close();
NotifyDisconnected();
} }
void ClientChannelImpl::FlushForTesting() { void ClientChannelImpl::FlushForTesting() {
......
...@@ -44,7 +44,6 @@ class ClientChannelImpl : public ClientChannel, public mojom::MessageReceiver { ...@@ -44,7 +44,6 @@ class ClientChannelImpl : public ClientChannel, public mojom::MessageReceiver {
base::OnceCallback<void(mojom::ConnectionMetadata)> callback) override; base::OnceCallback<void(mojom::ConnectionMetadata)> callback) override;
void PerformSendMessage(const std::string& payload, void PerformSendMessage(const std::string& payload,
base::OnceClosure on_sent_callback) override; base::OnceClosure on_sent_callback) override;
void PerformDisconnection() override;
// MessageReceiver: // MessageReceiver:
void OnMessageReceived(const std::string& message) override; void OnMessageReceived(const std::string& message) override;
......
...@@ -166,12 +166,6 @@ TEST_F(SecureChannelClientChannelImplTest, TestReceiveMessage) { ...@@ -166,12 +166,6 @@ TEST_F(SecureChannelClientChannelImplTest, TestReceiveMessage) {
EXPECT_EQ("payload", fake_observer_->received_messages()[0]); EXPECT_EQ("payload", fake_observer_->received_messages()[0]);
} }
TEST_F(SecureChannelClientChannelImplTest, TestDisconnectByClient) {
client_channel_->Disconnect();
VerifyChannelDisconnected();
}
TEST_F(SecureChannelClientChannelImplTest, TestDisconnectRemotely) { TEST_F(SecureChannelClientChannelImplTest, TestDisconnectRemotely) {
fake_channel_->DisconnectGeneratedPtr(); fake_channel_->DisconnectGeneratedPtr();
......
...@@ -25,10 +25,6 @@ void FakeClientChannel::PerformSendMessage(const std::string& payload, ...@@ -25,10 +25,6 @@ void FakeClientChannel::PerformSendMessage(const std::string& payload,
std::make_pair(payload, std::move(on_sent_callback))); std::make_pair(payload, std::move(on_sent_callback)));
} }
void FakeClientChannel::PerformDisconnection() {
NotifyDisconnected();
}
} // namespace secure_channel } // namespace secure_channel
} // namespace chromeos } // namespace chromeos
...@@ -38,7 +38,6 @@ class FakeClientChannel : public ClientChannel { ...@@ -38,7 +38,6 @@ class FakeClientChannel : public ClientChannel {
base::OnceCallback<void(mojom::ConnectionMetadata)> callback) override; base::OnceCallback<void(mojom::ConnectionMetadata)> callback) override;
void PerformSendMessage(const std::string& payload, void PerformSendMessage(const std::string& payload,
base::OnceClosure on_sent_callback) override; base::OnceClosure on_sent_callback) override;
void PerformDisconnection() override;
mojom::ConnectionMetadata connection_metadata_; mojom::ConnectionMetadata connection_metadata_;
std::vector<std::pair<std::string, base::OnceClosure>> sent_messages_; std::vector<std::pair<std::string, base::OnceClosure>> sent_messages_;
......
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