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( ...@@ -69,18 +69,12 @@ DriveFsConnection::DriveFsConnection(
&DriveFsConnection::OnMojoConnectionError, base::Unretained(this))); &DriveFsConnection::OnMojoConnectionError, base::Unretained(this)));
} }
DriveFsConnection::~DriveFsConnection() { DriveFsConnection::~DriveFsConnection() = default;
CleanUp();
}
void DriveFsConnection::CleanUp() { void DriveFsConnection::OnMojoConnectionError() {
if (on_disconnected_ && bootstrap_listener_->is_connected()) { if (on_disconnected_ && bootstrap_listener_->is_connected()) {
std::move(on_disconnected_).Run(); std::move(on_disconnected_).Run();
} }
} }
void DriveFsConnection::OnMojoConnectionError() {
CleanUp();
}
} // namespace drivefs } // namespace drivefs
...@@ -63,7 +63,6 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsConnection { ...@@ -63,7 +63,6 @@ class COMPONENT_EXPORT(DRIVEFS) DriveFsConnection {
mojom::DriveFs* drivefs_interface() const { return drivefs_.get(); } mojom::DriveFs* drivefs_interface() const { return drivefs_.get(); }
private: private:
void CleanUp();
void OnMojoConnectionError(); void OnMojoConnectionError();
std::unique_ptr<DriveFsBootstrapListener> bootstrap_listener_; std::unique_ptr<DriveFsBootstrapListener> bootstrap_listener_;
......
...@@ -137,7 +137,7 @@ TEST_F(DriveFsBootstrapTest, Listen_Connect_Destroy) { ...@@ -137,7 +137,7 @@ TEST_F(DriveFsBootstrapTest, Listen_Connect_Destroy) {
auto token = ListenForConnection(); auto token = ListenForConnection();
EXPECT_CALL(*this, OnInit()); EXPECT_CALL(*this, OnInit());
WaitForConnection(token); WaitForConnection(token);
EXPECT_CALL(*this, OnDisconnect()); EXPECT_CALL(*this, OnDisconnect()).Times(0);
connection_.reset(); connection_.reset();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ASSERT_FALSE( ASSERT_FALSE(
......
...@@ -371,6 +371,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap { ...@@ -371,6 +371,7 @@ class DriveFsHostTest : public ::testing::Test, public mojom::DriveFsBootstrap {
} }
void DoUnmount() { void DoUnmount() {
EXPECT_CALL(*host_delegate_, OnUnmounted(_)).Times(0);
host_->Unmount(); host_->Unmount();
binding_.Unbind(); binding_.Unbind();
bootstrap_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