Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Issue 2471183003: Do not observe MessageLoop destruction from ModelSafeWorker. (Closed)

Created:
4 years, 1 month ago by fdoray
Modified:
4 years, 1 month ago
CC:
chromium-reviews, gcasto+watchlist_chromium.org, vabr+watchlistpasswordmanager_chromium.org, sync-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Do not observe MessageLoop destruction from ModelSafeWorker. BrowserThreads are being migrated to TaskScheduler which doesn't support MessageLoop destruction observers. Destruction observers currently serve two purposes in ModelSafeWorker: 1. Set a "stopped" flag to true. When this flag is true, DoWorkAndWaitUntilDone() returns CANNOT_DO_WORK immediately. -> This is useless because all DoWorkAndWaitUntilDoneImpl() implementations already return CANNOT_DO_WORK when they are unable to schedule a task. For example, in BrowserThreadModelWorker::DoWorkAndWaitUntilDoneImpl(): // Note: PostTask returns false once the MessageLoop // running on the BrowserThread is destroyed. if (!runner_->PostTask( FROM_HERE, base::Bind(...))) { DLOG(WARNING) << "Failed to post task to runner " << runner_; error = CANNOT_DO_WORK; return error; } 2. Notify SyncBackendRegistrar that the MessageLoop was destroyed so that it can move the ModelSafeWorker to an inactive list. When all ModelSafeWorkers have been moved to the inactive list, SyncBackendRegistrar deletes itself. -> There is no reason to keep SyncBackendRegistrar alive after both SyncManager and SyncBackendHostImpl have cleared their pointer/unique_ptr to it. With this CL, SyncBackendRegistrar is deleted by a DeleteSoon task posted from SyncBackendHostImpl::Shutdown(). -> Deleting SyncBackendRegistrar causes the ModelSafeWorker references kept in |stopped_workers_| to be released. This is not dangerous since any object that still needs to use a ModelSafeWorker should have its own reference to it. BUG=650723 Committed: https://crrev.com/ea7a7eca75b39bfc9cbf72aed8a4dffa1d77f1e2 Cr-Commit-Position: refs/heads/master@{#430293}

Patch Set 1 #

Patch Set 2 : self-review #

Total comments: 7

Patch Set 3 : CR maxbogue #22 #

Total comments: 4

Patch Set 4 : CR maxbogue #23 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+123 lines, -578 lines) Patch
M chrome/browser/sync/chrome_sync_client.h View 1 chunk +1 line, -2 lines 0 comments Download
M chrome/browser/sync/chrome_sync_client.cc View 1 1 chunk +7 lines, -9 lines 0 comments Download
M components/browser_sync/profile_sync_test_util.cc View 3 chunks +9 lines, -14 lines 0 comments Download
M components/history/core/browser/history_model_worker.h View 1 2 chunks +4 lines, -11 lines 0 comments Download
M components/history/core/browser/history_model_worker.cc View 2 chunks +4 lines, -19 lines 0 comments Download
M components/password_manager/sync/browser/password_model_worker.h View 1 3 chunks +1 line, -9 lines 0 comments Download
M components/password_manager/sync/browser/password_model_worker.cc View 3 chunks +3 lines, -14 lines 0 comments Download
M components/sync/driver/fake_sync_client.h View 1 chunk +1 line, -2 lines 0 comments Download
M components/sync/driver/fake_sync_client.cc View 1 chunk +1 line, -2 lines 0 comments Download
M components/sync/driver/glue/browser_thread_model_worker.h View 1 2 chunks +3 lines, -10 lines 0 comments Download
M components/sync/driver/glue/browser_thread_model_worker.cc View 3 chunks +3 lines, -13 lines 0 comments Download
M components/sync/driver/glue/browser_thread_model_worker_unittest.cc View 1 chunk +1 line, -2 lines 0 comments Download
M components/sync/driver/glue/sync_backend_host.h View 1 2 1 chunk +2 lines, -8 lines 0 comments Download
M components/sync/driver/glue/sync_backend_host_impl.cc View 1 2 3 chunks +10 lines, -12 lines 0 comments Download
M components/sync/driver/glue/sync_backend_host_impl_unittest.cc View 1 chunk +2 lines, -3 lines 0 comments Download
M components/sync/driver/glue/sync_backend_registrar.h View 1 2 3 7 chunks +14 lines, -51 lines 0 comments Download
M components/sync/driver/glue/sync_backend_registrar.cc View 1 3 chunks +3 lines, -46 lines 0 comments Download
M components/sync/driver/glue/sync_backend_registrar_unittest.cc View 6 chunks +15 lines, -140 lines 0 comments Download
M components/sync/driver/glue/ui_model_worker.h View 2 chunks +2 lines, -8 lines 0 comments Download
M components/sync/driver/glue/ui_model_worker.cc View 2 chunks +5 lines, -11 lines 0 comments Download
M components/sync/driver/glue/ui_model_worker_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M components/sync/driver/sync_client.h View 1 chunk +1 line, -2 lines 0 comments Download
M components/sync/engine/model_safe_worker.h View 1 5 chunks +10 lines, -58 lines 0 comments Download
M components/sync/engine/model_safe_worker.cc View 1 2 3 2 chunks +5 lines, -99 lines 0 comments Download
M components/sync/engine/passive_model_worker.h View 1 2 chunks +1 line, -3 lines 0 comments Download
M components/sync/engine/passive_model_worker.cc View 1 chunk +2 lines, -7 lines 0 comments Download
M components/sync/test/engine/fake_model_worker.h View 2 chunks +0 lines, -4 lines 0 comments Download
M components/sync/test/engine/fake_model_worker.cc View 2 chunks +3 lines, -6 lines 0 comments Download
M components/sync/tools/sync_client.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M ios/chrome/browser/sync/ios_chrome_sync_client.h View 1 1 chunk +1 line, -2 lines 0 comments Download
M ios/chrome/browser/sync/ios_chrome_sync_client.mm View 1 1 chunk +7 lines, -9 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 38 (22 generated)
fdoray
zea@: PTAL Disclaimer: I spent a lot of time to analyze the ModelSafeWorker/SyncBackendRegistrar code and ...
4 years, 1 month ago (2016-11-03 12:19:57 UTC) #15
maxbogue
https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc File components/sync/driver/glue/sync_backend_host_impl.cc (right): https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc#newcode272 components/sync/driver/glue/sync_backend_host_impl.cc:272: return released_sync_thread; So my understanding of the current weird ...
4 years, 1 month ago (2016-11-03 17:05:31 UTC) #17
maxbogue
https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc File components/sync/driver/glue/sync_backend_host_impl.cc (right): https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc#newcode272 components/sync/driver/glue/sync_backend_host_impl.cc:272: return released_sync_thread; On 2016/11/03 17:05:31, maxbogue wrote: > So ...
4 years, 1 month ago (2016-11-03 17:10:23 UTC) #18
maxbogue
https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc File components/sync/driver/glue/sync_backend_host_impl.cc (right): https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc#newcode272 components/sync/driver/glue/sync_backend_host_impl.cc:272: return released_sync_thread; On 2016/11/03 17:10:23, maxbogue wrote: > On ...
4 years, 1 month ago (2016-11-03 17:29:11 UTC) #19
fdoray
maxbogue@: PTAnL https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc File components/sync/driver/glue/sync_backend_host_impl.cc (right): https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc#newcode272 components/sync/driver/glue/sync_backend_host_impl.cc:272: return released_sync_thread; On 2016/11/03 17:29:11, maxbogue wrote: ...
4 years, 1 month ago (2016-11-03 19:11:06 UTC) #20
maxbogue
https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc File components/sync/driver/glue/sync_backend_host_impl.cc (right): https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc#newcode272 components/sync/driver/glue/sync_backend_host_impl.cc:272: return released_sync_thread; On 2016/11/03 19:11:05, fdoray wrote: > Before ...
4 years, 1 month ago (2016-11-03 23:48:33 UTC) #21
fdoray
maxbogue@: PTAL https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc File components/sync/driver/glue/sync_backend_host_impl.cc (right): https://codereview.chromium.org/2471183003/diff/20001/components/sync/driver/glue/sync_backend_host_impl.cc#newcode272 components/sync/driver/glue/sync_backend_host_impl.cc:272: return released_sync_thread; On 2016/11/03 23:48:33, maxbogue wrote: ...
4 years, 1 month ago (2016-11-04 12:24:01 UTC) #22
maxbogue
lgtm! After this lands I'll do a cleanup CL to completely remove the sync thread ...
4 years, 1 month ago (2016-11-04 17:34:58 UTC) #23
maxbogue
Whoops, forgot to say: please wait for Nicolas to review as well, as he's more ...
4 years, 1 month ago (2016-11-04 17:42:21 UTC) #25
fdoray
zea@: PTAL sky@: Please review changes in components/history isherman@: Please review changes in components/password_manager https://codereview.chromium.org/2471183003/diff/40001/components/sync/driver/glue/sync_backend_registrar.h ...
4 years, 1 month ago (2016-11-04 17:56:50 UTC) #27
Nicolas Zea
lgtm
4 years, 1 month ago (2016-11-04 18:00:00 UTC) #28
sky
LGTM
4 years, 1 month ago (2016-11-04 20:23:53 UTC) #30
Ilya Sherman
LGTM
4 years, 1 month ago (2016-11-05 01:35:42 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2471183003/60001
4 years, 1 month ago (2016-11-07 15:47:08 UTC) #34
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 1 month ago (2016-11-07 16:35:34 UTC) #36
commit-bot: I haz the power
4 years, 1 month ago (2016-11-07 16:43:04 UTC) #38
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/ea7a7eca75b39bfc9cbf72aed8a4dffa1d77f1e2
Cr-Commit-Position: refs/heads/master@{#430293}

Powered by Google App Engine
This is Rietveld 408576698