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

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: Forward declare MetadataList Created 3 years, 11 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
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 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 void FakePhysicalWebDataSource::StopDiscovery() { 68 void FakePhysicalWebDataSource::StopDiscovery() {
69 // Ignored. 69 // Ignored.
70 } 70 }
71 71
72 std::unique_ptr<base::ListValue> FakePhysicalWebDataSource::GetMetadata() { 72 std::unique_ptr<base::ListValue> FakePhysicalWebDataSource::GetMetadata() {
73 return metadata_->CreateDeepCopy(); 73 return metadata_->CreateDeepCopy();
74 } 74 }
75 75
76 std::unique_ptr<MetadataList> FakePhysicalWebDataSource::GetMetadataList() {
77 return base::MakeUnique<MetadataList>(*metadata_list_.get());
78 }
79
76 bool FakePhysicalWebDataSource::HasUnresolvedDiscoveries() { 80 bool FakePhysicalWebDataSource::HasUnresolvedDiscoveries() {
77 return false; 81 return false;
78 } 82 }
79 83
80 void FakePhysicalWebDataSource::RegisterListener( 84 void FakePhysicalWebDataSource::RegisterListener(
81 PhysicalWebListener* physical_web_listener) { 85 PhysicalWebListener* physical_web_listener) {
82 observer_list_.AddObserver(physical_web_listener); 86 observer_list_.AddObserver(physical_web_listener);
83 } 87 }
84 88
85 void FakePhysicalWebDataSource::UnregisterListener( 89 void FakePhysicalWebDataSource::UnregisterListener(
86 PhysicalWebListener* physical_web_listener) { 90 PhysicalWebListener* physical_web_listener) {
87 observer_list_.RemoveObserver(physical_web_listener); 91 observer_list_.RemoveObserver(physical_web_listener);
88 } 92 }
89 93
90 void FakePhysicalWebDataSource::SetMetadata( 94 void FakePhysicalWebDataSource::SetMetadata(
91 std::unique_ptr<ListValue> metadata) { 95 std::unique_ptr<ListValue> metadata) {
92 metadata_ = std::move(metadata); 96 metadata_ = std::move(metadata);
93 } 97 }
94 98
99 void FakePhysicalWebDataSource::SetMetadataList(
100 std::unique_ptr<MetadataList> metadata_list) {
101 metadata_list_ = std::move(metadata_list);
102 }
103
95 void FakePhysicalWebDataSource::NotifyOnFound(const GURL& url) { 104 void FakePhysicalWebDataSource::NotifyOnFound(const GURL& url) {
96 for (PhysicalWebListener& observer : observer_list_) 105 for (PhysicalWebListener& observer : observer_list_)
97 observer.OnFound(url); 106 observer.OnFound(url);
98 } 107 }
99 108
100 void FakePhysicalWebDataSource::NotifyOnLost(const GURL& url) { 109 void FakePhysicalWebDataSource::NotifyOnLost(const GURL& url) {
101 for (PhysicalWebListener& observer : observer_list_) 110 for (PhysicalWebListener& observer : observer_list_)
102 observer.OnLost(url); 111 observer.OnLost(url);
103 } 112 }
104 113
105 void FakePhysicalWebDataSource::NotifyOnDistanceChanged( 114 void FakePhysicalWebDataSource::NotifyOnDistanceChanged(
106 const GURL& url, 115 const GURL& url,
107 double distance_estimate) { 116 double distance_estimate) {
108 for (PhysicalWebListener& observer : observer_list_) 117 for (PhysicalWebListener& observer : observer_list_)
109 observer.OnDistanceChanged(url, distance_estimate); 118 observer.OnDistanceChanged(url, distance_estimate);
110 } 119 }
111 120
112 } // namespace physical_web 121 } // namespace physical_web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698