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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/geolocation/GeolocationWatchers.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/geolocation/GeolocationWatchers.cpp
diff --git a/Source/modules/geolocation/GeolocationWatchers.cpp b/Source/modules/geolocation/GeolocationWatchers.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b783c6459518c08c6b41081534a8ac0cff4354a8
--- /dev/null
+++ b/Source/modules/geolocation/GeolocationWatchers.cpp
@@ -0,0 +1,76 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/geolocation/GeolocationWatchers.h"
+
+#include "modules/geolocation/GeoNotifier.h"
+
+namespace WebCore {
+
+void GeolocationWatchers::trace(Visitor* visitor)
+{
+ visitor->trace(m_idToNotifierMap);
+ visitor->trace(m_notifierToIdMap);
+}
+
+bool GeolocationWatchers::add(int id, GeoNotifier* notifier)
+{
+ ASSERT(id > 0);
+ if (!m_idToNotifierMap.add(id, notifier).isNewEntry)
+ return false;
+ m_notifierToIdMap.set(notifier, id);
+ return true;
+}
+
+GeoNotifier* GeolocationWatchers::find(int id)
+{
+ ASSERT(id > 0);
+ IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id);
+ if (iter == m_idToNotifierMap.end())
+ return 0;
+ return iter->value.get();
+}
+
+void GeolocationWatchers::remove(int id)
+{
+ ASSERT(id > 0);
+ IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id);
+ if (iter == m_idToNotifierMap.end())
+ return;
+ m_notifierToIdMap.remove(iter->value);
+ m_idToNotifierMap.remove(iter);
+}
+
+void GeolocationWatchers::remove(GeoNotifier* notifier)
+{
+ NotifierToIdMap::iterator iter = m_notifierToIdMap.find(notifier);
+ if (iter == m_notifierToIdMap.end())
+ return;
+ m_idToNotifierMap.remove(iter->value);
+ m_notifierToIdMap.remove(iter);
+}
+
+bool GeolocationWatchers::contains(GeoNotifier* notifier) const
+{
+ return m_notifierToIdMap.contains(notifier);
+}
+
+void GeolocationWatchers::clear()
+{
+ m_idToNotifierMap.clear();
+ m_notifierToIdMap.clear();
+}
+
+bool GeolocationWatchers::isEmpty() const
+{
+ return m_idToNotifierMap.isEmpty();
+}
+
+void GeolocationWatchers::getNotifiersVector(HeapVector<Member<GeoNotifier> >& copy) const
+{
+ copyValuesToVector(m_idToNotifierMap, copy);
+}
+
+} // namespace WebCore
« 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