Commit cc5c6348 authored by sebsg's avatar sebsg Committed by Commit Bot

[AF] Add nullcheck for the server database when clearing all server data

There is a small window where it can be null before the sync service is
done initializing.

Not clearing the data then doesn't matter, since the server db either
points to the local db which is cleaned next, or to an in memory server
db which doesn't exist yet, so there is nothing to clear.

This code is less than ideal and will be refactored along with the
database helper and the personalDataManager in the coming weeks.

Bug: 883713
Change-Id: I9e754985bf5c14750100dee57efe4ed1a3e252d8
Reviewed-on: https://chromium-review.googlesource.com/1231916Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592158}
parent 2df78d1c
......@@ -1027,10 +1027,14 @@ void PersonalDataManager::ClearAllServerData() {
// database on startup, and it could get called when the wallet pref is
// off (meaning this class won't even query for the server data) so don't
// check the server_credit_cards_/profiles_ before posting to the DB.
DCHECK(database_helper_->GetServerDatabase())
<< "Updating server card metadata without server storage.";
database_helper_->GetServerDatabase()->ClearAllServerData();
// TODO(crbug.com/864519): Move this nullcheck logic to the database helper.
// The server database can be null for a limited amount of time before the
// sync service gets initialize. Not clearing it does not matter in that case
// since it will either point to the local database (cleared next), or not
// have been created yet (nothing to clear).
if (database_helper_->GetServerDatabase())
database_helper_->GetServerDatabase()->ClearAllServerData();
// TODO(crbug.com/864519): Remove this call once addresses support account
// storage, and also use the database_helper_->GetServerDatabase()
......
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