OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "modules/geolocation/GeolocationWatchers.h" |
| 7 |
| 8 #include "modules/geolocation/GeoNotifier.h" |
| 9 |
| 10 namespace WebCore { |
| 11 |
| 12 void GeolocationWatchers::trace(Visitor* visitor) |
| 13 { |
| 14 visitor->trace(m_idToNotifierMap); |
| 15 visitor->trace(m_notifierToIdMap); |
| 16 } |
| 17 |
| 18 bool GeolocationWatchers::add(int id, GeoNotifier* notifier) |
| 19 { |
| 20 ASSERT(id > 0); |
| 21 if (!m_idToNotifierMap.add(id, notifier).isNewEntry) |
| 22 return false; |
| 23 m_notifierToIdMap.set(notifier, id); |
| 24 return true; |
| 25 } |
| 26 |
| 27 GeoNotifier* GeolocationWatchers::find(int id) |
| 28 { |
| 29 ASSERT(id > 0); |
| 30 IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); |
| 31 if (iter == m_idToNotifierMap.end()) |
| 32 return 0; |
| 33 return iter->value.get(); |
| 34 } |
| 35 |
| 36 void GeolocationWatchers::remove(int id) |
| 37 { |
| 38 ASSERT(id > 0); |
| 39 IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); |
| 40 if (iter == m_idToNotifierMap.end()) |
| 41 return; |
| 42 m_notifierToIdMap.remove(iter->value); |
| 43 m_idToNotifierMap.remove(iter); |
| 44 } |
| 45 |
| 46 void GeolocationWatchers::remove(GeoNotifier* notifier) |
| 47 { |
| 48 NotifierToIdMap::iterator iter = m_notifierToIdMap.find(notifier); |
| 49 if (iter == m_notifierToIdMap.end()) |
| 50 return; |
| 51 m_idToNotifierMap.remove(iter->value); |
| 52 m_notifierToIdMap.remove(iter); |
| 53 } |
| 54 |
| 55 bool GeolocationWatchers::contains(GeoNotifier* notifier) const |
| 56 { |
| 57 return m_notifierToIdMap.contains(notifier); |
| 58 } |
| 59 |
| 60 void GeolocationWatchers::clear() |
| 61 { |
| 62 m_idToNotifierMap.clear(); |
| 63 m_notifierToIdMap.clear(); |
| 64 } |
| 65 |
| 66 bool GeolocationWatchers::isEmpty() const |
| 67 { |
| 68 return m_idToNotifierMap.isEmpty(); |
| 69 } |
| 70 |
| 71 void GeolocationWatchers::getNotifiersVector(HeapVector<Member<GeoNotifier> >& c
opy) const |
| 72 { |
| 73 copyValuesToVector(m_idToNotifierMap, copy); |
| 74 } |
| 75 |
| 76 } // namespace WebCore |
OLD | NEW |