Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 * | 25 * |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef ContextLifecycleNotifier_h | 28 #ifndef ContextLifecycleNotifier_h |
| 29 #define ContextLifecycleNotifier_h | 29 #define ContextLifecycleNotifier_h |
| 30 | 30 |
| 31 #include "platform/LifecycleNotifier.h" | 31 #include "platform/LifecycleNotifier.h" |
| 32 #include "wtf/HashSet.h" | 32 #include "wtf/HashSet.h" |
| 33 #include "wtf/PassOwnPtr.h" | |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 class ActiveDOMObject; | 36 class ActiveDOMObject; |
| 37 class ContextLifecycleObserver; | |
| 38 class ExecutionContext; | 38 class ExecutionContext; |
| 39 | 39 |
| 40 class ContextLifecycleNotifier : public LifecycleNotifier<ExecutionContext> { | 40 class ContextLifecycleNotifier : public LifecycleNotifier<ExecutionContext, Cont extLifecycleObserver> { |
| 41 public: | 41 public: |
| 42 typedef HashSet<ActiveDOMObject*> ActiveDOMObjectSet; | 42 void addObserver(ContextLifecycleObserver*); |
| 43 | 43 void removeObserver(ContextLifecycleObserver*); |
| 44 const ActiveDOMObjectSet& activeDOMObjects() const { return m_activeDOMObjec ts; } | |
| 45 | |
| 46 virtual void addObserver(Observer*) override; | |
| 47 virtual void removeObserver(Observer*) override; | |
| 48 | 44 |
| 49 void notifyResumingActiveDOMObjects(); | 45 void notifyResumingActiveDOMObjects(); |
| 50 void notifySuspendingActiveDOMObjects(); | 46 void notifySuspendingActiveDOMObjects(); |
| 51 void notifyStoppingActiveDOMObjects(); | 47 void notifyStoppingActiveDOMObjects(); |
| 52 | 48 |
| 49 using ActiveDOMObjectSet = HashSet<ActiveDOMObject*>; | |
| 50 | |
| 51 const ActiveDOMObjectSet& activeDOMObjects() const { return m_activeDOMObjec ts; } | |
|
haraken
2015/03/01 09:18:39
Why do we need to keep m_activeDOMObjects while we
sof
2015/03/01 10:00:39
We can remove it also if we accept iterating over
haraken
2015/03/01 10:47:56
Sure. Also I'm wondering if a right fix would be t
sof
2015/03/01 17:21:37
Once this change has proven itself and settled wel
| |
| 53 bool contains(ActiveDOMObject* object) const { return m_activeDOMObjects.con tains(object); } | 52 bool contains(ActiveDOMObject* object) const { return m_activeDOMObjects.con tains(object); } |
| 54 bool hasPendingActivity() const; | 53 bool hasPendingActivity() const; |
| 55 | 54 |
| 56 protected: | 55 protected: |
| 57 explicit ContextLifecycleNotifier(ExecutionContext*); | 56 explicit ContextLifecycleNotifier(ExecutionContext*); |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 ActiveDOMObjectSet m_activeDOMObjects; | 59 ActiveDOMObjectSet m_activeDOMObjects; |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 } // namespace blink | 62 } // namespace blink |
| 64 | 63 |
| 65 #endif // ContextLifecycleNotifier_h | 64 #endif // ContextLifecycleNotifier_h |
| OLD | NEW |