Commit c3085800 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Block sync commits if updates pending encryption

ModelTypeWorker::GetContribution() should also be blocked if some
updates are pending a decryption key, otherwise a DCHECK is hit:
[32730:356:1120/142053.301971:FATAL:model_type_worker.cc(471)] Check failed: entries_pending_decryption_.empty().

Since this codepath was the only remaining user of BlockForEncryption()
that didn't verify entries_pending_decryption_ being empty, we change
BlockForEncryption() itself to also require that condition.

Bug: 873902,873494
Change-Id: Ic9f841380da5f81dd440d39698902a6fe2966be4
Reviewed-on: https://chromium-review.googlesource.com/c/1346392
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610095}
parent 04849ae1
...@@ -392,9 +392,11 @@ void ModelTypeWorker::EncryptionAcceptedMaybeApplyUpdates() { ...@@ -392,9 +392,11 @@ void ModelTypeWorker::EncryptionAcceptedMaybeApplyUpdates() {
} }
void ModelTypeWorker::ApplyPendingUpdates() { void ModelTypeWorker::ApplyPendingUpdates() {
if (!entries_pending_decryption_.empty()) if (BlockForEncryption())
return; return;
DCHECK(entries_pending_decryption_.empty());
DVLOG(1) << ModelTypeToString(type_) << ": " DVLOG(1) << ModelTypeToString(type_) << ": "
<< base::StringPrintf("Delivering %" PRIuS " applicable updates.", << base::StringPrintf("Delivering %" PRIuS " applicable updates.",
pending_updates_.size()); pending_updates_.size());
...@@ -538,6 +540,9 @@ bool ModelTypeWorker::CanCommitItems() const { ...@@ -538,6 +540,9 @@ bool ModelTypeWorker::CanCommitItems() const {
} }
bool ModelTypeWorker::BlockForEncryption() const { bool ModelTypeWorker::BlockForEncryption() const {
if (!entries_pending_decryption_.empty())
return true;
// Should be using encryption, but we do not have the keys. // Should be using encryption, but we do not have the keys.
return cryptographer_ && !cryptographer_->is_ready(); return cryptographer_ && !cryptographer_->is_ready();
} }
......
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