Commit 043302b0 authored by maniscalco's avatar maniscalco Committed by Commit bot

Delete GenericChangeProcessor synchronously when possible.

ShareChangeProcessor is responsible for deleting GenericChangeProcessor.
Because ShareChangeProcessor's dtor may be invoked by either the UI
thread or the model type thread, it must take care to ensure
GenericChangeProcessor is destroyed on the model type thread.

For some model types, the model type thread *is* the UI thread.  In this
case it's preferable to destroy the GenericChangeProcessor directly in
ShareChangeProcessor's dtor.  Why does it matter?  It matters because we
want to ensure a model type's GenericChangeProcessor and its resources
have been destroyed before the model type completes its
KeyedService::Shutdown method.

BUG=425781

Review URL: https://codereview.chromium.org/671603005

Cr-Commit-Position: refs/heads/master@{#300720}
parent 14a2cacd
......@@ -24,21 +24,20 @@ SharedChangeProcessor::SharedChangeProcessor()
SharedChangeProcessor::~SharedChangeProcessor() {
// We can either be deleted when the DTC is destroyed (on UI
// thread), or when the syncer::SyncableService stop's syncing (datatype
// thread), or when the syncer::SyncableService stops syncing (datatype
// thread). |generic_change_processor_|, if non-NULL, must be
// deleted on |backend_loop_|.
if (frontend_loop_->BelongsToCurrentThread()) {
if (backend_loop_.get()) {
if (backend_loop_.get()) {
if (backend_loop_->BelongsToCurrentThread()) {
delete generic_change_processor_;
} else {
DCHECK(frontend_loop_->BelongsToCurrentThread());
if (!backend_loop_->DeleteSoon(FROM_HERE, generic_change_processor_)) {
NOTREACHED();
}
} else {
DCHECK(!generic_change_processor_);
}
} else {
DCHECK(backend_loop_.get());
DCHECK(backend_loop_->BelongsToCurrentThread());
delete generic_change_processor_;
DCHECK(!generic_change_processor_);
}
}
......
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