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

Unified Diff: components/physical_web/data_source/physical_web_data_source_impl.cc

Issue 2349483002: Implement Physical Web listener registration (Closed)
Patch Set: Add unit tests Created 4 years, 3 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
Index: components/physical_web/data_source/physical_web_data_source_impl.cc
diff --git a/components/physical_web/data_source/physical_web_data_source_impl.cc b/components/physical_web/data_source/physical_web_data_source_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..575f22e0a68ce73068265c9cfd5b1eb757e6c34e
--- /dev/null
+++ b/components/physical_web/data_source/physical_web_data_source_impl.cc
@@ -0,0 +1,41 @@
+// Copyright 2016 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 "base/observer_list.h"
+#include "components/physical_web/data_source/physical_web_data_source.h"
+#include "components/physical_web/data_source/physical_web_data_source_impl.h"
+#include "components/physical_web/data_source/physical_web_listener.h"
+
+PhysicalWebDataSourceImpl::PhysicalWebDataSourceImpl() {
+ // observer_list_* = new ObserverList<PhysicalWebListener>();
cco3 2016/09/20 22:11:33 Is this intentional?
hayesjordan 2016/09/20 22:21:47 No, I forgot to delete it.
+}
+
+PhysicalWebDataSourceImpl::~PhysicalWebDataSourceImpl() {
+ // delete &observer_list_;
+}
+
+void PhysicalWebDataSourceImpl::RegisterListener(
+ PhysicalWebListener* physical_web_listener) {
+ observer_list_.AddObserver(physical_web_listener);
+}
+
+void PhysicalWebDataSourceImpl::UnregisterListener(
+ PhysicalWebListener* physical_web_listener) {
+ observer_list_.RemoveObserver(physical_web_listener);
+}
+
+void PhysicalWebDataSourceImpl::NotifyOnFound(const std::string& url) {
+ FOR_EACH_OBSERVER(PhysicalWebListener, observer_list_, OnFound(url));
+}
+
+void PhysicalWebDataSourceImpl::NotifyOnLost(const std::string& url) {
+ FOR_EACH_OBSERVER(PhysicalWebListener, observer_list_, OnLost(url));
+}
+
+void PhysicalWebDataSourceImpl::NotifyOnDistanceChanged(
+ const std::string& url,
+ double distance_estimate) {
+ FOR_EACH_OBSERVER(PhysicalWebListener, observer_list_,
+ OnDistanceChanged(url, distance_estimate));
+}

Powered by Google App Engine
This is Rietveld 408576698