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

Side by Side Diff: components/physical_web/data_source/fake_physical_web_data_source.cc

Issue 2561493002: Pass Physical Web metadata through a struct (Closed)
Patch Set: Add required/optional comments Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/physical_web/data_source/fake_physical_web_data_source.h" 5 #include "components/physical_web/data_source/fake_physical_web_data_source.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/physical_web/data_source/physical_web_listener.h" 9 #include "components/physical_web/data_source/physical_web_listener.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 void FakePhysicalWebDataSource::StopDiscovery() { 67 void FakePhysicalWebDataSource::StopDiscovery() {
68 // Ignored. 68 // Ignored.
69 } 69 }
70 70
71 std::unique_ptr<base::ListValue> FakePhysicalWebDataSource::GetMetadata() { 71 std::unique_ptr<base::ListValue> FakePhysicalWebDataSource::GetMetadata() {
72 return metadata_->CreateDeepCopy(); 72 return metadata_->CreateDeepCopy();
73 } 73 }
74 74
75 std::unique_ptr<MetadataList> FakePhysicalWebDataSource::GetMetadataList() {
76 return base::MakeUnique<MetadataList>(*metadata_list_.get());
77 }
78
75 bool FakePhysicalWebDataSource::HasUnresolvedDiscoveries() { 79 bool FakePhysicalWebDataSource::HasUnresolvedDiscoveries() {
76 return false; 80 return false;
77 } 81 }
78 82
79 void FakePhysicalWebDataSource::RegisterListener( 83 void FakePhysicalWebDataSource::RegisterListener(
80 PhysicalWebListener* physical_web_listener) { 84 PhysicalWebListener* physical_web_listener) {
81 observer_list_.AddObserver(physical_web_listener); 85 observer_list_.AddObserver(physical_web_listener);
82 } 86 }
83 87
84 void FakePhysicalWebDataSource::UnregisterListener( 88 void FakePhysicalWebDataSource::UnregisterListener(
85 PhysicalWebListener* physical_web_listener) { 89 PhysicalWebListener* physical_web_listener) {
86 observer_list_.RemoveObserver(physical_web_listener); 90 observer_list_.RemoveObserver(physical_web_listener);
87 } 91 }
88 92
89 void FakePhysicalWebDataSource::SetMetadata( 93 void FakePhysicalWebDataSource::SetMetadata(
90 std::unique_ptr<ListValue> metadata) { 94 std::unique_ptr<ListValue> metadata) {
91 metadata_ = std::move(metadata); 95 metadata_ = std::move(metadata);
92 } 96 }
93 97
98 void FakePhysicalWebDataSource::SetMetadataList(
99 std::unique_ptr<MetadataList> metadata_list) {
100 metadata_list_ = std::move(metadata_list);
101 }
102
94 void FakePhysicalWebDataSource::NotifyOnFound(const std::string& url) { 103 void FakePhysicalWebDataSource::NotifyOnFound(const std::string& url) {
95 for (PhysicalWebListener& observer : observer_list_) 104 for (PhysicalWebListener& observer : observer_list_)
96 observer.OnFound(url); 105 observer.OnFound(url);
97 } 106 }
98 107
99 void FakePhysicalWebDataSource::NotifyOnLost(const std::string& url) { 108 void FakePhysicalWebDataSource::NotifyOnLost(const std::string& url) {
100 for (PhysicalWebListener& observer : observer_list_) 109 for (PhysicalWebListener& observer : observer_list_)
101 observer.OnLost(url); 110 observer.OnLost(url);
102 } 111 }
103 112
104 void FakePhysicalWebDataSource::NotifyOnDistanceChanged( 113 void FakePhysicalWebDataSource::NotifyOnDistanceChanged(
105 const std::string& url, 114 const std::string& url,
106 double distance_estimate) { 115 double distance_estimate) {
107 for (PhysicalWebListener& observer : observer_list_) 116 for (PhysicalWebListener& observer : observer_list_)
108 observer.OnDistanceChanged(url, distance_estimate); 117 observer.OnDistanceChanged(url, distance_estimate);
109 } 118 }
110 119
111 } // namespace physical_web 120 } // namespace physical_web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698