Skip to content

Commit

Permalink
[Sync] Fix model_type_state if cache guid mismatches
Browse files Browse the repository at this point in the history
In case when cache GUID mismatches the model_type_state must be dropped
and created again. In other case ModelTypeProcessor will be in invalid
state when it dropped all metadata but initial_sync_done is still true.

Bug: 947044
Change-Id: I7ed96cac1e326c3e2568e051576ac3964b659e9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100812
Reviewed-by: Mikel Astiz <mastiz@chromium.org>
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Cr-Commit-Position: refs/heads/master@{#749791}
  • Loading branch information
Rushan Suleymanov authored and Commit Bot committed Mar 12, 2020
1 parent 2908f61 commit 21e77bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ void ClientTagBasedModelTypeProcessor::ConnectIfReady() {
ModelTypeHistogramValue(type_));
}
ClearMetadataAndResetState();
model_type_state = entity_tracker_->model_type_state();

// The model is still ready to sync (with the same |bridge_|) - replay
// the initialization.
model_ready_to_sync_ = true;
// Notify the bridge sync is starting to simulate an enable event.
bridge_->OnSyncStarting(activation_request_);

DCHECK(!model_type_state.initial_sync_done());
}

// Cache GUID verification earlier above guarantees the user is the same.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,7 @@ TEST_F(ClientTagBasedModelTypeProcessorTest,
EXPECT_NE(nullptr, worker());
// Upon a mismatch, metadata should have been cleared.
EXPECT_EQ(0U, db()->metadata_count());
EXPECT_FALSE(type_processor()->IsTrackingMetadata());
}

TEST_F(ClientTagBasedModelTypeProcessorTest,
Expand Down

0 comments on commit 21e77bf

Please sign in to comment.