OLD | NEW |
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 Loading... |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/page/PageLifecycleNotifier.h" | 28 #include "core/page/PageLifecycleNotifier.h" |
29 | 29 |
30 #include "core/page/PageLifecycleObserver.h" | 30 #include "core/page/PageLifecycleObserver.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 void PageLifecycleNotifier::notifyPageVisibilityChanged() | 34 void PageLifecycleNotifier::notifyPageVisibilityChanged() |
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<PageLifecycleObserver>> snapshotOfObservers; |
| 44 copyToVector(m_observers, snapshotOfObservers); |
| 45 for (PageLifecycleObserver* observer : snapshotOfObservers) { |
| 46 if (m_observers.contains(observer)) |
| 47 observer->pageVisibilityChanged(); |
| 48 } |
| 49 #else |
37 for (PageLifecycleObserver* observer : m_observers) | 50 for (PageLifecycleObserver* observer : m_observers) |
38 observer->pageVisibilityChanged(); | 51 observer->pageVisibilityChanged(); |
| 52 #endif |
39 } | 53 } |
40 | 54 |
41 void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame) | 55 void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame) |
42 { | 56 { |
43 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); | 57 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 58 #if !ENABLE(OILPAN) |
| 59 // Notifications perform unknown amounts of heap allocations, |
| 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<PageLifecycleObserver>> snapshotOfObservers; |
| 65 copyToVector(m_observers, snapshotOfObservers); |
| 66 for (PageLifecycleObserver* observer : snapshotOfObservers) { |
| 67 if (m_observers.contains(observer)) |
| 68 observer->didCommitLoad(frame); |
| 69 } |
| 70 #else |
44 for (PageLifecycleObserver* observer : m_observers) | 71 for (PageLifecycleObserver* observer : m_observers) |
45 observer->didCommitLoad(frame); | 72 observer->didCommitLoad(frame); |
| 73 #endif |
46 } | 74 } |
47 | 75 |
48 } // namespace blink | 76 } // namespace blink |
OLD | NEW |