| 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 20 matching lines...) Expand all Loading... |
| 31 #include "wtf/AutoReset.h" | 31 #include "wtf/AutoReset.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 void ContextLifecycleNotifier::notifyResumingSuspendableObjects() { | 35 void ContextLifecycleNotifier::notifyResumingSuspendableObjects() { |
| 36 AutoReset<IterationState> scope(&m_iterationState, AllowingNone); | 36 AutoReset<IterationState> scope(&m_iterationState, AllowingNone); |
| 37 for (ContextLifecycleObserver* observer : m_observers) { | 37 for (ContextLifecycleObserver* observer : m_observers) { |
| 38 if (observer->observerType() != | 38 if (observer->observerType() != |
| 39 ContextLifecycleObserver::SuspendableObjectType) | 39 ContextLifecycleObserver::SuspendableObjectType) |
| 40 continue; | 40 continue; |
| 41 SuspendableObject* activeDOMObject = | 41 SuspendableObject* suspendableObject = |
| 42 static_cast<SuspendableObject*>(observer); | 42 static_cast<SuspendableObject*>(observer); |
| 43 #if DCHECK_IS_ON() | 43 #if DCHECK_IS_ON() |
| 44 DCHECK_EQ(activeDOMObject->getExecutionContext(), context()); | 44 DCHECK_EQ(suspendableObject->getExecutionContext(), context()); |
| 45 DCHECK(activeDOMObject->suspendIfNeededCalled()); | 45 DCHECK(suspendableObject->suspendIfNeededCalled()); |
| 46 #endif | 46 #endif |
| 47 activeDOMObject->resume(); | 47 suspendableObject->resume(); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ContextLifecycleNotifier::notifySuspendingSuspendableObjects() { | 51 void ContextLifecycleNotifier::notifySuspendingSuspendableObjects() { |
| 52 AutoReset<IterationState> scope(&m_iterationState, AllowingNone); | 52 AutoReset<IterationState> scope(&m_iterationState, AllowingNone); |
| 53 for (ContextLifecycleObserver* observer : m_observers) { | 53 for (ContextLifecycleObserver* observer : m_observers) { |
| 54 if (observer->observerType() != | 54 if (observer->observerType() != |
| 55 ContextLifecycleObserver::SuspendableObjectType) | 55 ContextLifecycleObserver::SuspendableObjectType) |
| 56 continue; | 56 continue; |
| 57 SuspendableObject* activeDOMObject = | 57 SuspendableObject* suspendableObject = |
| 58 static_cast<SuspendableObject*>(observer); | 58 static_cast<SuspendableObject*>(observer); |
| 59 #if DCHECK_IS_ON() | 59 #if DCHECK_IS_ON() |
| 60 DCHECK_EQ(activeDOMObject->getExecutionContext(), context()); | 60 DCHECK_EQ(suspendableObject->getExecutionContext(), context()); |
| 61 DCHECK(activeDOMObject->suspendIfNeededCalled()); | 61 DCHECK(suspendableObject->suspendIfNeededCalled()); |
| 62 #endif | 62 #endif |
| 63 activeDOMObject->suspend(); | 63 suspendableObject->suspend(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 unsigned ContextLifecycleNotifier::activeDOMObjectCount() const { | 67 unsigned ContextLifecycleNotifier::suspendableObjectCount() const { |
| 68 DCHECK(!isIteratingOverObservers()); | 68 DCHECK(!isIteratingOverObservers()); |
| 69 unsigned activeDOMObjects = 0; | 69 unsigned suspendableObjects = 0; |
| 70 for (ContextLifecycleObserver* observer : m_observers) { | 70 for (ContextLifecycleObserver* observer : m_observers) { |
| 71 if (observer->observerType() != | 71 if (observer->observerType() != |
| 72 ContextLifecycleObserver::SuspendableObjectType) | 72 ContextLifecycleObserver::SuspendableObjectType) |
| 73 continue; | 73 continue; |
| 74 activeDOMObjects++; | 74 suspendableObjects++; |
| 75 } | 75 } |
| 76 return activeDOMObjects; | 76 return suspendableObjects; |
| 77 } | 77 } |
| 78 | 78 |
| 79 #if DCHECK_IS_ON() | 79 #if DCHECK_IS_ON() |
| 80 bool ContextLifecycleNotifier::contains(SuspendableObject* object) const { | 80 bool ContextLifecycleNotifier::contains(SuspendableObject* object) const { |
| 81 DCHECK(!isIteratingOverObservers()); | 81 DCHECK(!isIteratingOverObservers()); |
| 82 for (ContextLifecycleObserver* observer : m_observers) { | 82 for (ContextLifecycleObserver* observer : m_observers) { |
| 83 if (observer->observerType() != | 83 if (observer->observerType() != |
| 84 ContextLifecycleObserver::SuspendableObjectType) | 84 ContextLifecycleObserver::SuspendableObjectType) |
| 85 continue; | 85 continue; |
| 86 SuspendableObject* activeDOMObject = | 86 SuspendableObject* suspendableObject = |
| 87 static_cast<SuspendableObject*>(observer); | 87 static_cast<SuspendableObject*>(observer); |
| 88 if (activeDOMObject == object) | 88 if (suspendableObject == object) |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 #endif | 93 #endif |
| 94 | 94 |
| 95 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |