| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2012 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 18 matching lines...) Expand all Loading... |
| 29 #include "platform/heap/Handle.h" | 29 #include "platform/heap/Handle.h" |
| 30 #include "wtf/Forward.h" | 30 #include "wtf/Forward.h" |
| 31 #include "wtf/HashMap.h" | 31 #include "wtf/HashMap.h" |
| 32 #include "wtf/HashSet.h" | 32 #include "wtf/HashSet.h" |
| 33 #include "wtf/text/StringHash.h" | 33 #include "wtf/text/StringHash.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class IdTargetObserver; | 37 class IdTargetObserver; |
| 38 | 38 |
| 39 class IdTargetObserverRegistry final : public NoBaseWillBeGarbageCollectedFinali
zed<IdTargetObserverRegistry> { | 39 class IdTargetObserverRegistry final : public GarbageCollectedFinalized<IdTarget
ObserverRegistry> { |
| 40 WTF_MAKE_NONCOPYABLE(IdTargetObserverRegistry); | 40 WTF_MAKE_NONCOPYABLE(IdTargetObserverRegistry); |
| 41 USING_FAST_MALLOC_WILL_BE_REMOVED(IdTargetObserverRegistry); | |
| 42 friend class IdTargetObserver; | 41 friend class IdTargetObserver; |
| 43 public: | 42 public: |
| 44 static PassOwnPtrWillBeRawPtr<IdTargetObserverRegistry> create(); | 43 static RawPtr<IdTargetObserverRegistry> create(); |
| 45 DECLARE_TRACE(); | 44 DECLARE_TRACE(); |
| 46 void notifyObservers(const AtomicString& id); | 45 void notifyObservers(const AtomicString& id); |
| 47 bool hasObservers(const AtomicString& id) const; | 46 bool hasObservers(const AtomicString& id) const; |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 IdTargetObserverRegistry() : m_notifyingObserversInSet(nullptr) { } | 49 IdTargetObserverRegistry() : m_notifyingObserversInSet(nullptr) { } |
| 51 void addObserver(const AtomicString& id, IdTargetObserver*); | 50 void addObserver(const AtomicString& id, IdTargetObserver*); |
| 52 void removeObserver(const AtomicString& id, IdTargetObserver*); | 51 void removeObserver(const AtomicString& id, IdTargetObserver*); |
| 53 void notifyObserversInternal(const AtomicString& id); | 52 void notifyObserversInternal(const AtomicString& id); |
| 54 | 53 |
| 55 typedef WillBeHeapHashSet<RawPtrWillBeMember<IdTargetObserver>> ObserverSet; | 54 typedef HeapHashSet<Member<IdTargetObserver>> ObserverSet; |
| 56 typedef WillBeHeapHashMap<StringImpl*, OwnPtrWillBeMember<ObserverSet>> IdTo
ObserverSetMap; | 55 typedef HeapHashMap<StringImpl*, Member<ObserverSet>> IdToObserverSetMap; |
| 57 IdToObserverSetMap m_registry; | 56 IdToObserverSetMap m_registry; |
| 58 RawPtrWillBeMember<ObserverSet> m_notifyingObserversInSet; | 57 Member<ObserverSet> m_notifyingObserversInSet; |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 inline void IdTargetObserverRegistry::notifyObservers(const AtomicString& id) | 60 inline void IdTargetObserverRegistry::notifyObservers(const AtomicString& id) |
| 62 { | 61 { |
| 63 ASSERT(!m_notifyingObserversInSet); | 62 ASSERT(!m_notifyingObserversInSet); |
| 64 if (id.isEmpty() || m_registry.isEmpty()) | 63 if (id.isEmpty() || m_registry.isEmpty()) |
| 65 return; | 64 return; |
| 66 IdTargetObserverRegistry::notifyObserversInternal(id); | 65 IdTargetObserverRegistry::notifyObserversInternal(id); |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace blink | 68 } // namespace blink |
| 70 | 69 |
| 71 #endif // IdTargetObserverRegistry_h | 70 #endif // IdTargetObserverRegistry_h |
| OLD | NEW |