Commit 07f72c5a authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Skip calling |on_disconnected_| when disconnected by being destructed.

Calling |on_disconnected_| is necessary for detecting remote-initiated
disconnects, but for local-initiated disconnects, the code responsible
for disconnecting is already doing its own cleanup - notifying it of its
own action causing a disconnect is unnecessary.

Change-Id: I7ee7cf35140517f7849c30de704bd1a1fda62566
Reviewed-on: https://chromium-review.googlesource.com/c/1460199
Commit-Queue: Sam McNally <sammc@chromium.org>
Commit-Queue: Sergei Datsenko <dats@chromium.org>
Auto-Submit: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarSergei Datsenko <dats@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630163}
parent 21d8581c
......@@ -69,18 +69,12 @@ DriveFsConnection::DriveFsConnection(
&DriveFsConnection::OnMojoConnectionError, base::Unretained(this)));
}
DriveFsConnection::~DriveFsConnection() {
CleanUp();
}
DriveFsConnection::~DriveFsConnection() = default;
void DriveFsConnection::CleanUp() {
void DriveFsConnection::OnMojoConnectionError() {
if (on_disconnected_ && bootstrap_listener_->is_connected()) {
std::move(on_disconnected_).Run();
}
}
void DriveFsConnection::OnMojoConnectionError() {
CleanUp();
}
} // namespace drivefs
......@@ -63,7 +63,6 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsConnection {
mojom::DriveFs* drivefs_interface() const { return drivefs_.get(); }
private:
void CleanUp();
void OnMojoConnectionError();
std::unique_ptr<DriveFsBootstrapListener> bootstrap_listener_;
......
......@@ -137,7 +137,7 @@ TEST_F(DriveFsBootstrapTest, Listen_Connect_Destroy) {
auto token = ListenForConnection();
EXPECT_CALL(*this, OnInit());
WaitForConnection(token);
EXPECT_CALL(*this, OnDisconnect());
EXPECT_CALL(*this, OnDisconnect()).Times(0);
connection_.reset();
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(
......
......@@ -371,6 +371,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap {
}
void DoUnmount() {
EXPECT_CALL(*host_delegate_, OnUnmounted(_)).Times(0);
host_->Unmount();
binding_.Unbind();
bootstrap_binding_.Unbind();
......
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