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

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

Issue 2648973004: Remove GetMetadata from PhysicalWebDataSource and PhysicalWebScanner (Closed)
Patch Set: nil -> null 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"
9 #include "components/physical_web/data_source/physical_web_listener.h" 8 #include "components/physical_web/data_source/physical_web_listener.h"
10 #include "url/gurl.h" 9 #include "url/gurl.h"
11 10
12 using base::ListValue;
13 using base::DictionaryValue;
14
15 namespace physical_web { 11 namespace physical_web {
16 12
17 std::unique_ptr<Metadata> CreatePhysicalWebPage( 13 std::unique_ptr<Metadata> CreatePhysicalWebPage(
18 const std::string& resolved_url, 14 const std::string& resolved_url,
19 double distance_estimate, 15 double distance_estimate,
20 const std::string& group_id, 16 const std::string& group_id,
21 int scan_timestamp, 17 int scan_timestamp,
22 const std::string& title, 18 const std::string& title,
23 const std::string& description, 19 const std::string& description,
24 const std::string& scanned_url) { 20 const std::string& scanned_url) {
(...skipping 26 matching lines...) Expand all
51 for (int id : ids) { 47 for (int id : ids) {
52 std::unique_ptr<Metadata> page = 48 std::unique_ptr<Metadata> page =
53 CreateDummyPhysicalWebPage(id, distance, timestamp); 49 CreateDummyPhysicalWebPage(id, distance, timestamp);
54 list->push_back(*page); 50 list->push_back(*page);
55 ++distance; 51 ++distance;
56 --timestamp; 52 --timestamp;
57 } 53 }
58 return list; 54 return list;
59 } 55 }
60 56
61 FakePhysicalWebDataSource::FakePhysicalWebDataSource() 57 FakePhysicalWebDataSource::FakePhysicalWebDataSource() {}
62 : metadata_(base::MakeUnique<base::ListValue>()) {}
63 58
64 FakePhysicalWebDataSource::~FakePhysicalWebDataSource() = default; 59 FakePhysicalWebDataSource::~FakePhysicalWebDataSource() = default;
65 60
66 void FakePhysicalWebDataSource::StartDiscovery(bool network_request_enabled) { 61 void FakePhysicalWebDataSource::StartDiscovery(bool network_request_enabled) {
67 // Ignored. 62 // Ignored.
68 } 63 }
69 64
70 void FakePhysicalWebDataSource::StopDiscovery() { 65 void FakePhysicalWebDataSource::StopDiscovery() {
71 // Ignored. 66 // Ignored.
72 } 67 }
73 68
74 std::unique_ptr<base::ListValue> FakePhysicalWebDataSource::GetMetadata() {
75 return metadata_->CreateDeepCopy();
76 }
77
78 std::unique_ptr<MetadataList> FakePhysicalWebDataSource::GetMetadataList() { 69 std::unique_ptr<MetadataList> FakePhysicalWebDataSource::GetMetadataList() {
79 return base::MakeUnique<MetadataList>(*metadata_list_.get()); 70 return base::MakeUnique<MetadataList>(*metadata_list_.get());
80 } 71 }
81 72
82 bool FakePhysicalWebDataSource::HasUnresolvedDiscoveries() { 73 bool FakePhysicalWebDataSource::HasUnresolvedDiscoveries() {
83 return false; 74 return false;
84 } 75 }
85 76
86 void FakePhysicalWebDataSource::RegisterListener( 77 void FakePhysicalWebDataSource::RegisterListener(
87 PhysicalWebListener* physical_web_listener) { 78 PhysicalWebListener* physical_web_listener) {
88 observer_list_.AddObserver(physical_web_listener); 79 observer_list_.AddObserver(physical_web_listener);
89 } 80 }
90 81
91 void FakePhysicalWebDataSource::UnregisterListener( 82 void FakePhysicalWebDataSource::UnregisterListener(
92 PhysicalWebListener* physical_web_listener) { 83 PhysicalWebListener* physical_web_listener) {
93 observer_list_.RemoveObserver(physical_web_listener); 84 observer_list_.RemoveObserver(physical_web_listener);
94 } 85 }
95 86
96 void FakePhysicalWebDataSource::SetMetadata(
97 std::unique_ptr<ListValue> metadata) {
98 metadata_ = std::move(metadata);
99 }
100
101 void FakePhysicalWebDataSource::SetMetadataList( 87 void FakePhysicalWebDataSource::SetMetadataList(
102 std::unique_ptr<MetadataList> metadata_list) { 88 std::unique_ptr<MetadataList> metadata_list) {
103 metadata_list_ = std::move(metadata_list); 89 metadata_list_ = std::move(metadata_list);
104 } 90 }
105 91
106 void FakePhysicalWebDataSource::NotifyOnFound(const GURL& url) { 92 void FakePhysicalWebDataSource::NotifyOnFound(const GURL& url) {
107 for (PhysicalWebListener& observer : observer_list_) 93 for (PhysicalWebListener& observer : observer_list_)
108 observer.OnFound(url); 94 observer.OnFound(url);
109 } 95 }
110 96
111 void FakePhysicalWebDataSource::NotifyOnLost(const GURL& url) { 97 void FakePhysicalWebDataSource::NotifyOnLost(const GURL& url) {
112 for (PhysicalWebListener& observer : observer_list_) 98 for (PhysicalWebListener& observer : observer_list_)
113 observer.OnLost(url); 99 observer.OnLost(url);
114 } 100 }
115 101
116 void FakePhysicalWebDataSource::NotifyOnDistanceChanged( 102 void FakePhysicalWebDataSource::NotifyOnDistanceChanged(
117 const GURL& url, 103 const GURL& url,
118 double distance_estimate) { 104 double distance_estimate) {
119 for (PhysicalWebListener& observer : observer_list_) 105 for (PhysicalWebListener& observer : observer_list_)
120 observer.OnDistanceChanged(url, distance_estimate); 106 observer.OnDistanceChanged(url, distance_estimate);
121 } 107 }
122 108
123 } // namespace physical_web 109 } // namespace physical_web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698