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

Side by Side Diff: Source/core/dom/DocumentLifecycleNotifier.cpp

Issue 1214963002: Oilpan: support observer retirement during lifetime notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/frame/DOMWindowLifecycleNotifier.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 #include "config.h" 27 #include "config.h"
28 #include "core/dom/DocumentLifecycleNotifier.h" 28 #include "core/dom/DocumentLifecycleNotifier.h"
29 29
30 #include "core/dom/DocumentLifecycleObserver.h" 30 #include "core/dom/DocumentLifecycleObserver.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 void DocumentLifecycleNotifier::notifyDocumentWasDetached() 34 void DocumentLifecycleNotifier::notifyDocumentWasDetached()
35 { 35 {
36 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); 36 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
37 #if !ENABLE(OILPAN)
38 // Notifications perform unknown amounts of heap allocations,
39 // which might trigger (conservative) GCs. This will flush out
40 // dead observers, causing the _non-heap_ set be updated. Snapshot
41 // the observers and explicitly check if they're still alive before
42 // notifying.
43 Vector<RawPtr<DocumentLifecycleObserver>> snapshotOfObservers;
44 copyToVector(m_observers, snapshotOfObservers);
45 for (DocumentLifecycleObserver* observer : snapshotOfObservers) {
46 if (m_observers.contains(observer))
47 observer->documentWasDetached();
48 }
49 #else
37 for (DocumentLifecycleObserver* observer : m_observers) 50 for (DocumentLifecycleObserver* observer : m_observers)
38 observer->documentWasDetached(); 51 observer->documentWasDetached();
52 #endif
39 } 53 }
40 54
41 #if !ENABLE(OILPAN) 55 #if !ENABLE(OILPAN)
42 void DocumentLifecycleNotifier::notifyDocumentWasDisposed() 56 void DocumentLifecycleNotifier::notifyDocumentWasDisposed()
43 { 57 {
44 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); 58 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
45 for (DocumentLifecycleObserver* observer : m_observers) 59 // Notifications perform unknown amounts of heap allocations,
46 observer->documentWasDisposed(); 60 // which might trigger (conservative) GCs. This will flush out
61 // dead observers, causing the _non-heap_ set be updated. Snapshot
62 // the observers and explicitly check if they're still alive before
63 // notifying.
64 Vector<RawPtr<DocumentLifecycleObserver>> snapshotOfObservers;
65 copyToVector(m_observers, snapshotOfObservers);
66 for (DocumentLifecycleObserver* observer : snapshotOfObservers) {
67 if (m_observers.contains(observer))
68 observer->documentWasDisposed();
69 }
47 } 70 }
48 #endif 71 #endif
49 72
50 } // namespace blink 73 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/DOMWindowLifecycleNotifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698