OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 ContextLifecycleNotifier::ContextLifecycleNotifier(ScriptExecutionContext* conte
xt) | 36 ContextLifecycleNotifier::ContextLifecycleNotifier(ScriptExecutionContext* conte
xt) |
37 : m_context(context) | 37 : m_context(context) |
38 , m_iterating(IteratingNone) | 38 , m_iterating(IteratingNone) |
39 , m_inDestructor(false) | 39 , m_inDestructor(false) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 ContextLifecycleNotifier::~ContextLifecycleNotifier() | 43 ContextLifecycleNotifier::~ContextLifecycleNotifier() |
44 { | 44 { |
45 m_inDestructor = true; | 45 m_inDestructor = true; |
46 for (ContextObserverSet::iterator iter = m_destructionObservers.begin(); ite
r != m_destructionObservers.end(); iter = m_destructionObservers.begin()) { | 46 for (ContextObserverSet::iterator iter = m_contextObservers.begin(); iter !=
m_contextObservers.end(); iter = m_contextObservers.begin()) { |
47 ContextDestructionObserver* observer = *iter; | 47 ContextLifecycleObserver* observer = *iter; |
48 m_destructionObservers.remove(observer); | 48 m_contextObservers.remove(observer); |
49 ASSERT(observer->scriptExecutionContext() == m_context); | 49 ASSERT(observer->scriptExecutionContext() == m_context); |
50 observer->contextDestroyed(); | 50 observer->contextDestroyed(); |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void ContextLifecycleNotifier::addObserver(ContextDestructionObserver* observer,
ContextDestructionObserver::Type as) | 54 void ContextLifecycleNotifier::addObserver(ContextLifecycleObserver* observer, C
ontextLifecycleObserver::Type as) |
55 { | 55 { |
56 RELEASE_ASSERT(!m_inDestructor); | 56 RELEASE_ASSERT(!m_inDestructor); |
57 RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); | 57 RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); |
58 m_destructionObservers.add(observer); | 58 m_contextObservers.add(observer); |
59 if (as == ContextDestructionObserver::ActiveDOMObjectType) { | 59 if (as == ContextLifecycleObserver::ActiveDOMObjectType) { |
60 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); | 60 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); |
61 m_activeDOMObjects.add(static_cast<ActiveDOMObject*>(observer)); | 61 m_activeDOMObjects.add(static_cast<ActiveDOMObject*>(observer)); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 void ContextLifecycleNotifier::removeObserver(ContextDestructionObserver* observ
er, ContextDestructionObserver::Type as) | 65 void ContextLifecycleNotifier::removeObserver(ContextLifecycleObserver* observer
, ContextLifecycleObserver::Type as) |
66 { | 66 { |
67 RELEASE_ASSERT(!m_inDestructor); | 67 RELEASE_ASSERT(!m_inDestructor); |
68 RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); | 68 RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); |
69 m_destructionObservers.remove(observer); | 69 m_contextObservers.remove(observer); |
70 if (as == ContextDestructionObserver::ActiveDOMObjectType) { | 70 if (as == ContextLifecycleObserver::ActiveDOMObjectType) { |
71 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); | 71 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); |
72 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer)); | 72 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer)); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() | 76 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() |
77 { | 77 { |
78 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD
OMObjects); | 78 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD
OMObjects); |
79 ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end(); | 79 ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end(); |
80 for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter !=
activeObjectsEnd; ++iter) { | 80 for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter !=
activeObjectsEnd; ++iter) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void ContextLifecycleNotifier::reportMemoryUsage(WTF::MemoryObjectInfo* memoryOb
jectInfo) const | 134 void ContextLifecycleNotifier::reportMemoryUsage(WTF::MemoryObjectInfo* memoryOb
jectInfo) const |
135 { | 135 { |
136 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); | 136 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); |
137 ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end(); | 137 ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end(); |
138 for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter !=
activeObjectsEnd; ++iter) | 138 for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter !=
activeObjectsEnd; ++iter) |
139 info.addMember(*iter, "activeDOMObject", WTF::RetainingPointer); | 139 info.addMember(*iter, "activeDOMObject", WTF::RetainingPointer); |
140 } | 140 } |
141 | 141 |
142 } // namespace WebCore | 142 } // namespace WebCore |
143 | 143 |
OLD | NEW |