diff options
author | maniscalco <maniscalco@chromium.org> | 2014-10-22 11:42:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-22 18:44:13 +0000 |
commit | 043302b06fcd0d0d18132db3b67df6105b54cf8e (patch) | |
tree | 19bae8daf3342e97d74f4477b0d6e864c69a46b5 /components/sync_driver | |
parent | 14a2cacd3a7b4c047b9c434af604d52ea9bb6488 (diff) | |
download | chromium_src-043302b06fcd0d0d18132db3b67df6105b54cf8e.zip chromium_src-043302b06fcd0d0d18132db3b67df6105b54cf8e.tar.gz chromium_src-043302b06fcd0d0d18132db3b67df6105b54cf8e.tar.bz2 |
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}
Diffstat (limited to 'components/sync_driver')
-rw-r--r-- | components/sync_driver/shared_change_processor.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/components/sync_driver/shared_change_processor.cc b/components/sync_driver/shared_change_processor.cc index c1cf407..ce49430 100644 --- a/components/sync_driver/shared_change_processor.cc +++ b/components/sync_driver/shared_change_processor.cc @@ -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_); } } |