| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 IdToObserverSetMap::iterator iter = m_registry.find(id.impl()); | 60 IdToObserverSetMap::iterator iter = m_registry.find(id.impl()); |
| 61 | 61 |
| 62 ObserverSet* set = iter->value.get(); | 62 ObserverSet* set = iter->value.get(); |
| 63 set->remove(observer); | 63 set->remove(observer); |
| 64 if (set->isEmpty() && set != m_notifyingObserversInSet) | 64 if (set->isEmpty() && set != m_notifyingObserversInSet) |
| 65 m_registry.remove(iter); | 65 m_registry.remove(iter); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void IdTargetObserverRegistry::notifyObserversInternal(const AtomicString& id) | 68 void IdTargetObserverRegistry::notifyObserversInternal(const AtomicString& id) |
| 69 { | 69 { |
| 70 ASSERT(!id.isEmpty()); | 70 DCHECK(!id.isEmpty()); |
| 71 ASSERT(!m_registry.isEmpty()); | 71 DCHECK(!m_registry.isEmpty()); |
| 72 | 72 |
| 73 m_notifyingObserversInSet = m_registry.get(id.impl()); | 73 m_notifyingObserversInSet = m_registry.get(id.impl()); |
| 74 if (!m_notifyingObserversInSet) | 74 if (!m_notifyingObserversInSet) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 HeapVector<Member<IdTargetObserver>> copy; | 77 HeapVector<Member<IdTargetObserver>> copy; |
| 78 copyToVector(*m_notifyingObserversInSet, copy); | 78 copyToVector(*m_notifyingObserversInSet, copy); |
| 79 for (const auto& observer : copy) { | 79 for (const auto& observer : copy) { |
| 80 if (m_notifyingObserversInSet->contains(observer)) | 80 if (m_notifyingObserversInSet->contains(observer)) |
| 81 observer->idTargetChanged(); | 81 observer->idTargetChanged(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 if (m_notifyingObserversInSet->isEmpty()) | 84 if (m_notifyingObserversInSet->isEmpty()) |
| 85 m_registry.remove(id.impl()); | 85 m_registry.remove(id.impl()); |
| 86 | 86 |
| 87 m_notifyingObserversInSet = nullptr; | 87 m_notifyingObserversInSet = nullptr; |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool IdTargetObserverRegistry::hasObservers(const AtomicString& id) const | 90 bool IdTargetObserverRegistry::hasObservers(const AtomicString& id) const |
| 91 { | 91 { |
| 92 if (id.isEmpty() || m_registry.isEmpty()) | 92 if (id.isEmpty() || m_registry.isEmpty()) |
| 93 return false; | 93 return false; |
| 94 ObserverSet* set = m_registry.get(id.impl()); | 94 ObserverSet* set = m_registry.get(id.impl()); |
| 95 return set && !set->isEmpty(); | 95 return set && !set->isEmpty(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |