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

Issue 2094143002: Avoid snapshotting ContextLifecycleObservers when iterating. (Closed)

Created:
4 years, 5 months ago by sof
Modified:
4 years, 5 months ago
CC:
blink-reviews, blink-reviews-dom_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Avoid snapshotting ContextLifecycleObservers when iterating. To allow safe iteration over the set of ExecutionContext observers, a snapshot of the set was taken before iterating over it. So as to allow observers to unregister themselves while being notified. Apart from PostMessageTimer unregistering itself while being stop()ed, the ContextLifecycleObservers do not mutate the observer set, hence we can avoid the snapshot step and iterate directly over the observers. Attempts to remove an observer while iterating is caught and asserted for. As the observer set is a set of weak references, some care is needed to keep those references strong while iterating. That and other details surrounding observer iteration is now handled by the auxiliary scope object LifecycleNotifier<>::IterationScope. Should the constraint of not being allowed to remove observers while iterating prove too cumbersome, supporting lazy removal of observers (post iteration) would be straightforward. R= BUG=451132 Committed: https://crrev.com/5b0b4e4f357e9348870dd5612b663a35894b49f3 Cr-Commit-Position: refs/heads/master@{#402141}

Patch Set 1 #

Patch Set 2 : record removals when iterating stopped observers also #

Patch Set 3 : avoid removing PostMessageTimers when stop-iterating #

Patch Set 4 : just disallow all adds + removals during ContextLifecycleNotifier iterations #

Patch Set 5 : tidy up further #

Patch Set 6 : msvc compile fix.. #

Total comments: 5

Patch Set 7 : remove IterationScope, indirection not needed #

Unified diffs Side-by-side diffs Delta from patch set Stats (+52 lines, -71 lines) Patch
M third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp View 1 2 3 4 5 6 1 chunk +25 lines, -46 lines 0 comments Download
M third_party/WebKit/Source/core/frame/DOMWindowLifecycleNotifier.cpp View 1 2 3 4 5 6 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp View 1 2 1 chunk +2 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/frame/LocalFrameLifecycleNotifier.cpp View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/page/PageLifecycleNotifier.cpp View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/LifecycleNotifier.h View 1 2 3 4 5 6 3 chunks +19 lines, -15 lines 0 comments Download

Messages

Total messages: 26 (15 generated)
sof
please take a look.
4 years, 5 months ago (2016-06-26 18:33:39 UTC) #13
dominicc (has gone to gerrit)
Thank you for taking over https://codereview.chromium.org/2091023004 and cleaning up these FIXMEs? Are you now disallowing ...
4 years, 5 months ago (2016-06-27 00:44:00 UTC) #14
haraken
LGTM with comments. https://codereview.chromium.org/2094143002/diff/170007/third_party/WebKit/Source/platform/LifecycleNotifier.h File third_party/WebKit/Source/platform/LifecycleNotifier.h (right): https://codereview.chromium.org/2094143002/diff/170007/third_party/WebKit/Source/platform/LifecycleNotifier.h#newcode80 third_party/WebKit/Source/platform/LifecycleNotifier.h:80: explicit IterationScope(LifecycleNotifier* notifier, IterationState allowable = ...
4 years, 5 months ago (2016-06-27 01:06:34 UTC) #15
sof
https://codereview.chromium.org/2094143002/diff/170007/third_party/WebKit/Source/platform/LifecycleNotifier.h File third_party/WebKit/Source/platform/LifecycleNotifier.h (right): https://codereview.chromium.org/2094143002/diff/170007/third_party/WebKit/Source/platform/LifecycleNotifier.h#newcode80 third_party/WebKit/Source/platform/LifecycleNotifier.h:80: explicit IterationScope(LifecycleNotifier* notifier, IterationState allowable = AllowingNone) On 2016/06/27 ...
4 years, 5 months ago (2016-06-27 05:14:15 UTC) #16
sof
On 2016/06/27 00:44:00, dominicc wrote: > Thank you for taking over https://codereview.chromium.org/2091023004 and > cleaning ...
4 years, 5 months ago (2016-06-27 06:34:13 UTC) #17
sof
Suggestions welcome for alternate naming of the IterationState enum tags. https://codereview.chromium.org/2094143002/diff/170007/third_party/WebKit/Source/platform/LifecycleNotifier.h File third_party/WebKit/Source/platform/LifecycleNotifier.h (right): https://codereview.chromium.org/2094143002/diff/170007/third_party/WebKit/Source/platform/LifecycleNotifier.h#newcode93 ...
4 years, 5 months ago (2016-06-27 06:36:54 UTC) #18
haraken
LGTM
4 years, 5 months ago (2016-06-27 06:37:32 UTC) #19
sof
Sorry for jumping in a bit on dominicc@'s efforts, but the possibility of removing all ...
4 years, 5 months ago (2016-06-27 08:05:32 UTC) #20
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/2094143002/230001
4 years, 5 months ago (2016-06-27 08:06:03 UTC) #22
commit-bot: I haz the power
Committed patchset #7 (id:230001)
4 years, 5 months ago (2016-06-27 09:02:57 UTC) #24
commit-bot: I haz the power
4 years, 5 months ago (2016-06-27 09:04:57 UTC) #26
Message was sent while issue was closed.
Patchset 7 (id:??) landed as
https://crrev.com/5b0b4e4f357e9348870dd5612b663a35894b49f3
Cr-Commit-Position: refs/heads/master@{#402141}

Powered by Google App Engine
This is Rietveld 408576698