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

Unified Diff: components/physical_web/data_source/physical_web_data_source.h

Issue 2561493002: Pass Physical Web metadata through a struct (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/physical_web/data_source/physical_web_data_source.h
diff --git a/components/physical_web/data_source/physical_web_data_source.h b/components/physical_web/data_source/physical_web_data_source.h
index c6310396ce1a25c4ac2a767975182c3def46f550..0a2fe174596e73fb632b7afca13e60f6f7240c58 100644
--- a/components/physical_web/data_source/physical_web_data_source.h
+++ b/components/physical_web/data_source/physical_web_data_source.h
@@ -6,6 +6,8 @@
#define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_
#include <memory>
+#include <string>
+#include <vector>
namespace base {
class ListValue;
@@ -16,6 +18,7 @@ namespace physical_web {
class PhysicalWebListener;
// Dictionary keys for reading Physical Web URL metadata.
+// TODO(cco3): Remove these when we are no longer dependent.
extern const char kDescriptionKey[];
extern const char kDistanceEstimateKey[];
extern const char kGroupIdKey[];
@@ -25,6 +28,23 @@ extern const char kScanTimestampKey[];
extern const char kScannedUrlKey[];
extern const char kTitleKey[];
+// Metadata struct for associating data with Physical Web URLs.
+struct Metadata {
vitaliii 2016/12/07 10:14:05 Why not commenting each field? E.g. guarantees (is
cco3 2016/12/08 23:52:51 Done.
+ Metadata();
+ Metadata(const Metadata& other);
+ ~Metadata();
+ std::string scanned_url;
+ std::string resolved_url;
+ std::string icon_url;
vitaliii 2016/12/07 10:14:04 It would be nice to have these as GURL, but it see
cco3 2016/12/08 23:52:50 Done.
+ std::string title;
+ std::string description;
+ std::string group_id;
+ double distance_estimate;
+ long scan_timestamp;
vitaliii 2016/12/07 10:14:04 As far as I know, |long| in Java is 64 bits, but i
cco3 2016/12/08 23:52:50 Done.
+};
+
+using MetadataList = std::vector<Metadata>;
vitaliii 2016/12/07 10:14:04 Nit: This name somewhat collides with |ListValue|
cco3 2016/12/08 23:52:50 I think it's fine to leave it. The confusion will
vitaliii 2016/12/09 09:52:49 Acknowledged.
+
// Helper class for accessing Physical Web metadata and controlling the scanner.
class PhysicalWebDataSource {
mattreynolds 2016/12/07 19:55:31 Two more PhysicalWebDataSource implementations tha
cco3 2016/12/08 23:52:51 Done.
public:
@@ -41,7 +61,14 @@ class PhysicalWebDataSource {
// requests are disabled or if discovery is not active, the list will be
// empty. The method can be called at any time to receive the current metadata
// list.
- virtual std::unique_ptr<base::ListValue> GetMetadata() = 0;
+ virtual std::unique_ptr<MetadataList> GetMetadata() = 0;
+
+ // Returns a list of resolved URLs and associated page metadata. If network
+ // requests are disabled or if discovery is not active, the list will be
+ // empty. The method can be called at any time to receive the current metadata
+ // list.
+ // TODO(cco3): Remove this when we are no longer dependent on it.
+ virtual std::unique_ptr<base::ListValue> GetMetadataListValue() = 0;
vitaliii 2016/12/07 10:14:04 Explicitly say that this is deprecated and new use
cco3 2016/12/08 23:52:51 Done.
// Returns boolean |true| if network requests are disabled and there are one
// or more discovered URLs that have not been sent to the resolution service.

Powered by Google App Engine
This is Rietveld 408576698