Commit 959d24f1 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Ignore team drive change events if the list is not initialised

Bug: 1049067
Change-Id: I40e6ddb338061f7f58563af48ef5203c133ba07f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2086384Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747135}
parent 0c37f576
......@@ -58,7 +58,9 @@ class DriveFsHost::MountState : public DriveFsSession,
~MountState() override {
DCHECK_CALLED_ON_VALID_SEQUENCE(host_->sequence_checker_);
if (team_drives_fetched_) {
host_->delegate_->GetDriveNotificationManager().RemoveObserver(this);
}
if (is_mounted()) {
for (auto& observer : host_->observers_) {
observer.OnUnmounted();
......@@ -131,10 +133,14 @@ class DriveFsHost::MountState : public DriveFsSession,
host_->delegate_->GetDriveNotificationManager().UpdateTeamDriveIds(
std::set<std::string>(team_drive_ids.begin(), team_drive_ids.end()),
{});
team_drives_fetched_ = true;
}
void OnTeamDriveChanged(const std::string& team_drive_id,
CreateOrDelete change_type) override {
if (!team_drives_fetched_) {
return;
}
std::set<std::string> additions;
std::set<std::string> removals;
if (change_type == mojom::DriveFsDelegate::CreateOrDelete::kCreated) {
......@@ -168,6 +174,7 @@ class DriveFsHost::MountState : public DriveFsSession,
std::unique_ptr<DriveFsSearch> search_;
bool token_fetch_attempted_ = false;
bool team_drives_fetched_ = false;
DISALLOW_COPY_AND_ASSIGN(MountState);
};
......
......@@ -552,6 +552,28 @@ TEST_F(DriveFsHostTest, TeamDriveTracking) {
host_delegate_->GetDriveNotificationManager().team_drive_ids_for_test());
}
TEST_F(DriveFsHostTest, TeamDriveTrackingIgnoreChanges) {
ASSERT_NO_FATAL_FAILURE(DoMount());
EXPECT_EQ(
std::set<std::string>(),
host_delegate_->GetDriveNotificationManager().team_drive_ids_for_test());
delegate_->OnTeamDriveChanged(
"a", mojom::DriveFsDelegate::CreateOrDelete::kCreated);
delegate_.FlushForTesting();
EXPECT_EQ(
std::set<std::string>(),
host_delegate_->GetDriveNotificationManager().team_drive_ids_for_test());
delegate_->OnTeamDriveChanged(
"b", mojom::DriveFsDelegate::CreateOrDelete::kDeleted);
delegate_.FlushForTesting();
EXPECT_EQ(
std::set<std::string>(),
host_delegate_->GetDriveNotificationManager().team_drive_ids_for_test());
}
TEST_F(DriveFsHostTest, Invalidation) {
ASSERT_NO_FATAL_FAILURE(DoMount());
......
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