| OLD | NEW |
| 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 #ifndef COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ | 5 #ifndef COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| 6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ | 6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "components/physical_web/data_source/physical_web_data_source.h" | 12 #include "components/physical_web/data_source/physical_web_data_source.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace base { | |
| 17 class ListValue; | |
| 18 } | |
| 19 | |
| 20 namespace physical_web { | 16 namespace physical_web { |
| 21 | 17 |
| 22 std::unique_ptr<Metadata> CreatePhysicalWebPage( | 18 std::unique_ptr<Metadata> CreatePhysicalWebPage( |
| 23 const std::string& resolved_url, | 19 const std::string& resolved_url, |
| 24 double distance_estimate, | 20 double distance_estimate, |
| 25 const std::string& group_id, | 21 const std::string& group_id, |
| 26 int scan_timestamp, | 22 int scan_timestamp, |
| 27 const std::string& title, | 23 const std::string& title, |
| 28 const std::string& description, | 24 const std::string& description, |
| 29 const std::string& scanned_url); | 25 const std::string& scanned_url); |
| 30 | 26 |
| 31 std::unique_ptr<Metadata> | 27 std::unique_ptr<Metadata> |
| 32 CreateDummyPhysicalWebPage(int id, double distance, int timestamp); | 28 CreateDummyPhysicalWebPage(int id, double distance, int timestamp); |
| 33 | 29 |
| 34 std::unique_ptr<MetadataList> CreateDummyPhysicalWebPages( | 30 std::unique_ptr<MetadataList> CreateDummyPhysicalWebPages( |
| 35 const std::vector<int>& ids); | 31 const std::vector<int>& ids); |
| 36 | 32 |
| 37 class FakePhysicalWebDataSource : public PhysicalWebDataSource { | 33 class FakePhysicalWebDataSource : public PhysicalWebDataSource { |
| 38 public: | 34 public: |
| 39 FakePhysicalWebDataSource(); | 35 FakePhysicalWebDataSource(); |
| 40 ~FakePhysicalWebDataSource() override; | 36 ~FakePhysicalWebDataSource() override; |
| 41 | 37 |
| 42 void StartDiscovery(bool network_request_enabled) override; | 38 void StartDiscovery(bool network_request_enabled) override; |
| 43 void StopDiscovery() override; | 39 void StopDiscovery() override; |
| 44 | 40 |
| 45 std::unique_ptr<base::ListValue> GetMetadata() override; | |
| 46 std::unique_ptr<MetadataList> GetMetadataList() override; | 41 std::unique_ptr<MetadataList> GetMetadataList() override; |
| 47 | 42 |
| 48 bool HasUnresolvedDiscoveries() override; | 43 bool HasUnresolvedDiscoveries() override; |
| 49 | 44 |
| 50 void RegisterListener(PhysicalWebListener* physical_web_listener) override; | 45 void RegisterListener(PhysicalWebListener* physical_web_listener) override; |
| 51 void UnregisterListener(PhysicalWebListener* physical_web_listener) override; | 46 void UnregisterListener(PhysicalWebListener* physical_web_listener) override; |
| 52 | 47 |
| 53 // for testing | 48 // for testing |
| 54 void SetMetadata(std::unique_ptr<base::ListValue> metadata); | |
| 55 void SetMetadataList(std::unique_ptr<MetadataList> metadata_list); | 49 void SetMetadataList(std::unique_ptr<MetadataList> metadata_list); |
| 56 void NotifyOnFound(const GURL& url); | 50 void NotifyOnFound(const GURL& url); |
| 57 void NotifyOnLost(const GURL& url); | 51 void NotifyOnLost(const GURL& url); |
| 58 void NotifyOnDistanceChanged(const GURL& url, double distance_estimate); | 52 void NotifyOnDistanceChanged(const GURL& url, double distance_estimate); |
| 59 | 53 |
| 60 private: | 54 private: |
| 61 std::unique_ptr<base::ListValue> metadata_; | |
| 62 std::unique_ptr<MetadataList> metadata_list_; | 55 std::unique_ptr<MetadataList> metadata_list_; |
| 63 base::ObserverList<PhysicalWebListener> observer_list_; | 56 base::ObserverList<PhysicalWebListener> observer_list_; |
| 64 | 57 |
| 65 DISALLOW_COPY_AND_ASSIGN(FakePhysicalWebDataSource); | 58 DISALLOW_COPY_AND_ASSIGN(FakePhysicalWebDataSource); |
| 66 }; | 59 }; |
| 67 | 60 |
| 68 } // namespace physical_web | 61 } // namespace physical_web |
| 69 | 62 |
| 70 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ | 63 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_FAKE_PHYSICAL_WEB_DATA_SOURCE_H_ |
| OLD | NEW |