Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: Source/modules/geolocation/GeolocationWatchers.cpp

Issue 402563002: Separate GeolocationWatchers from Geolocation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/geolocation/GeolocationWatchers.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « Source/modules/geolocation/GeolocationWatchers.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698