Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/frame/DOMWindowLifecycleNotifier.h" | 28 #include "core/frame/DOMWindowLifecycleNotifier.h" |
| 29 | 29 |
| 30 #include "core/frame/DOMWindowLifecycleObserver.h" | 30 #include "core/frame/DOMWindowLifecycleObserver.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 DOMWindowLifecycleNotifier::DOMWindowLifecycleNotifier(LocalDOMWindow* context) | 34 DOMWindowLifecycleNotifier::DOMWindowLifecycleNotifier(LocalDOMWindow* context) |
| 35 : LifecycleNotifier<LocalDOMWindow>(context) | 35 : LifecycleNotifier<LocalDOMWindow, DOMWindowLifecycleObserver>(context) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void DOMWindowLifecycleNotifier::addObserver(DOMWindowLifecycleNotifier::Observe r* observer) | 39 void DOMWindowLifecycleNotifier::addObserver(DOMWindowLifecycleObserver* observe r) |
| 40 { | 40 { |
| 41 if (observer->observerType() == Observer::DOMWindowLifecycleObserverType) { | 41 LifecycleNotifier<LocalDOMWindow, DOMWindowLifecycleObserver>::addObserver(o bserver); |
| 42 RELEASE_ASSERT(m_iterating != IteratingOverDOMWindowObservers); | |
| 43 m_windowObservers.add(static_cast<DOMWindowLifecycleObserver*>(observer) ); | |
| 44 } | |
| 45 | |
| 46 LifecycleNotifier<LocalDOMWindow>::addObserver(observer); | |
| 47 } | 42 } |
| 48 | 43 |
| 49 void DOMWindowLifecycleNotifier::removeObserver(DOMWindowLifecycleNotifier::Obse rver* observer) | 44 void DOMWindowLifecycleNotifier::removeObserver(DOMWindowLifecycleObserver* obse rver) |
| 50 { | 45 { |
| 51 if (observer->observerType() == Observer::DOMWindowLifecycleObserverType) { | 46 LifecycleNotifier<LocalDOMWindow, DOMWindowLifecycleObserver>::removeObserve r(observer); |
| 52 RELEASE_ASSERT(m_iterating != IteratingOverDOMWindowObservers); | |
| 53 m_windowObservers.remove(static_cast<DOMWindowLifecycleObserver*>(observ er)); | |
| 54 } | |
| 55 | |
| 56 LifecycleNotifier<LocalDOMWindow>::removeObserver(observer); | |
| 57 } | 47 } |
| 58 | 48 |
| 59 void DOMWindowLifecycleNotifier::notifyAddEventListener(LocalDOMWindow* window, const AtomicString& eventType) | 49 void DOMWindowLifecycleNotifier::notifyAddEventListener(LocalDOMWindow* window, const AtomicString& eventType) |
| 60 { | 50 { |
| 61 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverDOMWind owObservers); | 51 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 62 for (const auto& windowObserver : m_windowObservers) | 52 for (DOMWindowLifecycleObserver* observer : m_observers) |
| 63 windowObserver->didAddEventListener(window, eventType); | 53 observer->didAddEventListener(window, eventType); |
| 64 } | 54 } |
| 65 | 55 |
| 66 void DOMWindowLifecycleNotifier::notifyRemoveEventListener(LocalDOMWindow* windo w, const AtomicString& eventType) | 56 void DOMWindowLifecycleNotifier::notifyRemoveEventListener(LocalDOMWindow* windo w, const AtomicString& eventType) |
| 67 { | 57 { |
| 68 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverDOMWind owObservers); | 58 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 69 for (const auto& windowObserver : m_windowObservers) | 59 for (DOMWindowLifecycleObserver* observer : m_observers) |
| 70 windowObserver->didRemoveEventListener(window, eventType); | 60 static_cast<DOMWindowLifecycleObserver*>(observer)->didRemoveEventListen er(window, eventType); |
|
sof
2015/03/01 17:50:20
Will tidy up this redundant cast.
| |
| 71 } | 61 } |
| 72 | 62 |
| 73 void DOMWindowLifecycleNotifier::notifyRemoveAllEventListeners(LocalDOMWindow* w indow) | 63 void DOMWindowLifecycleNotifier::notifyRemoveAllEventListeners(LocalDOMWindow* w indow) |
| 74 { | 64 { |
| 75 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverDOMWind owObservers); | 65 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 76 for (const auto& windowObserver : m_windowObservers) | 66 for (DOMWindowLifecycleObserver* observer : m_observers) |
| 77 windowObserver->didRemoveAllEventListeners(window); | 67 static_cast<DOMWindowLifecycleObserver*>(observer)->didRemoveAllEventLis teners(window); |
| 78 } | 68 } |
| 79 | 69 |
| 80 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |