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 24 matching lines...) Expand all Loading... |
35 return adoptPtr(new IdTargetObserverRegistry()); | 35 return adoptPtr(new IdTargetObserverRegistry()); |
36 } | 36 } |
37 | 37 |
38 void IdTargetObserverRegistry::addObserver(const AtomicString& id, IdTargetObser
ver* observer) | 38 void IdTargetObserverRegistry::addObserver(const AtomicString& id, IdTargetObser
ver* observer) |
39 { | 39 { |
40 if (id.isEmpty()) | 40 if (id.isEmpty()) |
41 return; | 41 return; |
42 | 42 |
43 IdToObserverSetMap::AddResult result = m_registry.add(id.impl(), nullptr); | 43 IdToObserverSetMap::AddResult result = m_registry.add(id.impl(), nullptr); |
44 if (result.isNewEntry) | 44 if (result.isNewEntry) |
45 result.iterator->value = adoptPtr(new ObserverSet()); | 45 result.storedValue->value = adoptPtr(new ObserverSet()); |
46 | 46 |
47 result.iterator->value->add(observer); | 47 result.storedValue->value->add(observer); |
48 } | 48 } |
49 | 49 |
50 void IdTargetObserverRegistry::removeObserver(const AtomicString& id, IdTargetOb
server* observer) | 50 void IdTargetObserverRegistry::removeObserver(const AtomicString& id, IdTargetOb
server* observer) |
51 { | 51 { |
52 if (id.isEmpty() || m_registry.isEmpty()) | 52 if (id.isEmpty() || m_registry.isEmpty()) |
53 return; | 53 return; |
54 | 54 |
55 IdToObserverSetMap::iterator iter = m_registry.find(id.impl()); | 55 IdToObserverSetMap::iterator iter = m_registry.find(id.impl()); |
56 | 56 |
57 ObserverSet* set = iter->value.get(); | 57 ObserverSet* set = iter->value.get(); |
(...skipping 26 matching lines...) Expand all Loading... |
84 | 84 |
85 bool IdTargetObserverRegistry::hasObservers(const AtomicString& id) const | 85 bool IdTargetObserverRegistry::hasObservers(const AtomicString& id) const |
86 { | 86 { |
87 if (id.isEmpty() || m_registry.isEmpty()) | 87 if (id.isEmpty() || m_registry.isEmpty()) |
88 return false; | 88 return false; |
89 ObserverSet* set = m_registry.get(id.impl()); | 89 ObserverSet* set = m_registry.get(id.impl()); |
90 return set && !set->isEmpty(); | 90 return set && !set->isEmpty(); |
91 } | 91 } |
92 | 92 |
93 } // namespace WebCore | 93 } // namespace WebCore |
OLD | NEW |