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

Issue 2782573002: [Sync] Refactor ModelSafeWorker::DoWorkAndWaitUntilDone() to avoid code duplication. (Closed)

Created:
3 years, 8 months ago by fdoray
Modified:
3 years, 8 months ago
Reviewers:
dvadym, brettw, skym
CC:
chromium-reviews, gcasto+watchlist_chromium.org, vabr+watchlistpasswordmanager_chromium.org, sync-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[Sync] Refactor ModelSafeWorker::DoWorkAndWaitUntilDone() to avoid code duplication. Before this CL, logic to wait for a WorkCallback to run or be abandoned was duplicated in multiple ModelSafeWorker::DoWorkAndWaitUntilDoneImpl() implementations. With this CL, ModelSafeWorker::DoWorkAndWaitUntilDoneImpl() is replaced with ModelSafeWorker::ScheduleWork(). Implementations are merely responsible for scheduling the callback that they receive; they don't have to wait for it to run or be abandoned. The logic to wait for the callback to run or be abandoned is moved into ModelSafeWorker::DoWorkAndWaitUntilDone(). ModelSafeWorker::DoWorkAndWaitUntilDone() calls ModelSafeWorker::ScheduleWork(). Then, it waits until either the callback that it passed to ModelSafeWorker::ScheduleWork() is deleted (may or may not have run) or ModelSafeWorker::RequestStop() is called before the callback has started to run. Additionnaly, calling ModelSafeWorker::RequestStop() transforms into no-op further invocations of callbacks passed to ModelSafeWorker::ScheduleWork(). Unblocking ModelSafeWorker::DoWorkAndWaitUntilDone() when ModelSafeWorker::RequestStop() is called is important to prevent deadlocks in workers that schedule work on the UI thread. Indeed, in Chrome, no tasks are scheduled on the UI thread after ModelSafeWorker::RequestStop() is called and pending UI tasks are not scheduled until after the sync thread is joined. BUG=663600 Review-Url: https://codereview.chromium.org/2782573002 Cr-Original-Commit-Position: refs/heads/master@{#463413} Committed: https://chromium.googlesource.com/chromium/src/+/316c08f3692150ac1c416c67391768622cc6a77f Review-Url: https://codereview.chromium.org/2782573002 Cr-Commit-Position: refs/heads/master@{#465229} Committed: https://chromium.googlesource.com/chromium/src/+/eeeb0d0ec28227aba875195e0f20076414fc4596

Patch Set 1 #

Patch Set 2 : self-review #

Patch Set 3 : self-review #

Patch Set 4 : fix build error #

Patch Set 5 : fix build error #

Patch Set 6 : fix build error #

Patch Set 7 : fix build error #

Patch Set 8 : fix-test-error #

Patch Set 9 : fix-test-error #

Total comments: 16

Patch Set 10 : CR-skym-42 #

Patch Set 11 : self-review #

Unified diffs Side-by-side diffs Delta from patch set Stats (+559 lines, -483 lines) Patch
M components/history/core/browser/BUILD.gn View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M components/history/core/browser/history_model_worker.h View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -4 lines 0 comments Download
M components/history/core/browser/history_model_worker.cc View 1 2 3 4 5 6 7 8 9 5 chunks +17 lines, -72 lines 0 comments Download
A components/history/core/browser/history_model_worker_unittest.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +227 lines, -0 lines 0 comments Download
M components/password_manager/sync/browser/password_model_worker.h View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -4 lines 0 comments Download
M components/password_manager/sync/browser/password_model_worker.cc View 1 2 3 4 5 6 7 8 9 2 chunks +11 lines, -44 lines 0 comments Download
M components/sync/BUILD.gn View 1 2 chunks +0 lines, -3 lines 0 comments Download
D components/sync/base/scoped_event_signal.h View 1 1 chunk +0 lines, -40 lines 0 comments Download
D components/sync/base/scoped_event_signal.cc View 1 1 chunk +0 lines, -34 lines 0 comments Download
D components/sync/base/scoped_event_signal_unittest.cc View 1 1 chunk +0 lines, -84 lines 0 comments Download
M components/sync/engine/browser_thread_model_worker.h View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -9 lines 0 comments Download
M components/sync/engine/browser_thread_model_worker.cc View 1 2 3 4 5 6 7 8 9 2 chunks +6 lines, -39 lines 0 comments Download
M components/sync/engine/browser_thread_model_worker_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -3 lines 0 comments Download
M components/sync/engine/model_safe_worker.h View 1 2 3 4 5 6 7 8 9 4 chunks +30 lines, -16 lines 0 comments Download
M components/sync/engine/model_safe_worker.cc View 1 2 3 4 5 6 7 8 9 2 chunks +76 lines, -11 lines 0 comments Download
M components/sync/engine/model_safe_worker_unittest.cc View 1 2 3 4 5 6 7 8 9 2 chunks +163 lines, -2 lines 0 comments Download
M components/sync/engine/passive_model_worker.h View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -4 lines 0 comments Download
M components/sync/engine/passive_model_worker.cc View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -5 lines 0 comments Download
M components/sync/engine/ui_model_worker.h View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -20 lines 0 comments Download
M components/sync/engine/ui_model_worker.cc View 1 2 3 4 5 6 7 8 9 2 chunks +5 lines, -80 lines 0 comments Download
M components/sync/engine/ui_model_worker_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M components/sync/engine_impl/directory_update_handler.cc View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -1 line 0 comments Download
M components/sync/test/engine/fake_model_worker.h View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -3 lines 0 comments Download
M components/sync/test/engine/fake_model_worker.cc View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -4 lines 0 comments Download

Messages

Total messages: 68 (54 generated)
fdoray
PTAL This CL replaces https://codereview.chromium.org/2757193003/. It has less complexity and less code duplication + better ...
3 years, 8 months ago (2017-04-03 19:23:27 UTC) #39
brettw
I don't have much experience with these sync classes. Is there a sync reviewer you ...
3 years, 8 months ago (2017-04-05 23:28:09 UTC) #40
skym
The refactor lgtm. But reading this CLs comment, it isn't clear to me why this ...
3 years, 8 months ago (2017-04-06 00:34:55 UTC) #42
fdoray
sky@: Please review changes in components/history/ dvadym@: Please review changes in components/password_manager/ HistoryModelWorkerTest.DoWorkAndWaitUntilDoneRequestStopBeforeUITaskRun is the ...
3 years, 8 months ago (2017-04-06 18:10:55 UTC) #49
sky
My understanding is Brett is willing to do an owners review of components/history, butg wanted ...
3 years, 8 months ago (2017-04-06 20:33:28 UTC) #51
fdoray
On 2017/04/06 20:33:28, sky wrote: > My understanding is Brett is willing to do an ...
3 years, 8 months ago (2017-04-06 20:44:37 UTC) #52
dvadym
components/password_manager/ LGTM
3 years, 8 months ago (2017-04-07 08:27:10 UTC) #53
brettw
lgtm
3 years, 8 months ago (2017-04-10 19:38:21 UTC) #54
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/2782573002/200001
3 years, 8 months ago (2017-04-10 19:41:53 UTC) #57
commit-bot: I haz the power
Committed patchset #11 (id:200001) as https://chromium.googlesource.com/chromium/src/+/316c08f3692150ac1c416c67391768622cc6a77f
3 years, 8 months ago (2017-04-10 22:06:32 UTC) #60
cmumford
A revert of this CL (patchset #11 id:200001) has been created in https://codereview.chromium.org/2820623002/ by cmumford@chromium.org. ...
3 years, 8 months ago (2017-04-13 23:00:49 UTC) #61
fdoray
Relanding on trunk. https://bugs.chromium.org/p/chromium/issues/detail?id=711466 is an M58 build failure, which occurred because a CL on ...
3 years, 8 months ago (2017-04-18 12:56:26 UTC) #63
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/2782573002/200001
3 years, 8 months ago (2017-04-18 12:56:57 UTC) #65
commit-bot: I haz the power
3 years, 8 months ago (2017-04-18 14:26:56 UTC) #68
Message was sent while issue was closed.
Committed patchset #11 (id:200001) as
https://chromium.googlesource.com/chromium/src/+/eeeb0d0ec28227aba875195e0f20...

Powered by Google App Engine
This is Rietveld 408576698