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_PHYSICAL_WEB_DATA_SOURCE_H_ | 5 #ifndef COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ | 6 #define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | |
10 #include <vector> | |
9 | 11 |
10 namespace base { | 12 namespace base { |
11 class ListValue; | 13 class ListValue; |
12 } | 14 } |
13 | 15 |
14 namespace physical_web { | 16 namespace physical_web { |
15 | 17 |
16 class PhysicalWebListener; | 18 class PhysicalWebListener; |
17 | 19 |
18 // Dictionary keys for reading Physical Web URL metadata. | 20 // Dictionary keys for reading Physical Web URL metadata. |
21 // TODO(cco3): Remove these when we are no longer dependent. | |
19 extern const char kDescriptionKey[]; | 22 extern const char kDescriptionKey[]; |
20 extern const char kDistanceEstimateKey[]; | 23 extern const char kDistanceEstimateKey[]; |
21 extern const char kGroupIdKey[]; | 24 extern const char kGroupIdKey[]; |
22 extern const char kIconUrlKey[]; | 25 extern const char kIconUrlKey[]; |
23 extern const char kResolvedUrlKey[]; | 26 extern const char kResolvedUrlKey[]; |
24 extern const char kScanTimestampKey[]; | 27 extern const char kScanTimestampKey[]; |
25 extern const char kScannedUrlKey[]; | 28 extern const char kScannedUrlKey[]; |
26 extern const char kTitleKey[]; | 29 extern const char kTitleKey[]; |
27 | 30 |
31 // Metadata struct for associating data with Physical Web URLs. | |
32 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.
| |
33 Metadata(); | |
34 Metadata(const Metadata& other); | |
35 ~Metadata(); | |
36 std::string scanned_url; | |
37 std::string resolved_url; | |
38 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.
| |
39 std::string title; | |
40 std::string description; | |
41 std::string group_id; | |
42 double distance_estimate; | |
43 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.
| |
44 }; | |
45 | |
46 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.
| |
47 | |
28 // Helper class for accessing Physical Web metadata and controlling the scanner. | 48 // Helper class for accessing Physical Web metadata and controlling the scanner. |
29 class PhysicalWebDataSource { | 49 class PhysicalWebDataSource { |
mattreynolds
2016/12/07 19:55:31
Two more PhysicalWebDataSource implementations tha
cco3
2016/12/08 23:52:51
Done.
| |
30 public: | 50 public: |
31 virtual ~PhysicalWebDataSource() {} | 51 virtual ~PhysicalWebDataSource() {} |
32 | 52 |
33 // Starts scanning for Physical Web URLs. If |network_request_enabled| is | 53 // Starts scanning for Physical Web URLs. If |network_request_enabled| is |
34 // true, discovered URLs will be sent to a resolution service. | 54 // true, discovered URLs will be sent to a resolution service. |
35 virtual void StartDiscovery(bool network_request_enabled) = 0; | 55 virtual void StartDiscovery(bool network_request_enabled) = 0; |
36 | 56 |
37 // Stops scanning for Physical Web URLs and clears cached URL content. | 57 // Stops scanning for Physical Web URLs and clears cached URL content. |
38 virtual void StopDiscovery() = 0; | 58 virtual void StopDiscovery() = 0; |
39 | 59 |
40 // Returns a list of resolved URLs and associated page metadata. If network | 60 // Returns a list of resolved URLs and associated page metadata. If network |
41 // requests are disabled or if discovery is not active, the list will be | 61 // requests are disabled or if discovery is not active, the list will be |
42 // empty. The method can be called at any time to receive the current metadata | 62 // empty. The method can be called at any time to receive the current metadata |
43 // list. | 63 // list. |
44 virtual std::unique_ptr<base::ListValue> GetMetadata() = 0; | 64 virtual std::unique_ptr<MetadataList> GetMetadata() = 0; |
65 | |
66 // Returns a list of resolved URLs and associated page metadata. If network | |
67 // requests are disabled or if discovery is not active, the list will be | |
68 // empty. The method can be called at any time to receive the current metadata | |
69 // list. | |
70 // TODO(cco3): Remove this when we are no longer dependent on it. | |
71 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.
| |
45 | 72 |
46 // Returns boolean |true| if network requests are disabled and there are one | 73 // Returns boolean |true| if network requests are disabled and there are one |
47 // or more discovered URLs that have not been sent to the resolution service. | 74 // or more discovered URLs that have not been sent to the resolution service. |
48 // The method can be called at any time to check for unresolved discoveries. | 75 // The method can be called at any time to check for unresolved discoveries. |
49 // If discovery is inactive or network requests are enabled, it will always | 76 // If discovery is inactive or network requests are enabled, it will always |
50 // return false. | 77 // return false. |
51 virtual bool HasUnresolvedDiscoveries() = 0; | 78 virtual bool HasUnresolvedDiscoveries() = 0; |
52 | 79 |
53 // Register for changes to Physical Web URLs and associated page metadata. | 80 // Register for changes to Physical Web URLs and associated page metadata. |
54 virtual void RegisterListener(PhysicalWebListener* physical_web_listener) = 0; | 81 virtual void RegisterListener(PhysicalWebListener* physical_web_listener) = 0; |
55 | 82 |
56 // Unregister for changes to Physical Web URLs and associated page metadata. | 83 // Unregister for changes to Physical Web URLs and associated page metadata. |
57 virtual void UnregisterListener( | 84 virtual void UnregisterListener( |
58 PhysicalWebListener* physical_web_listener) = 0; | 85 PhysicalWebListener* physical_web_listener) = 0; |
59 }; | 86 }; |
60 | 87 |
61 } // namespace physical_web | 88 } // namespace physical_web |
62 | 89 |
63 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ | 90 #endif // COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_ |
OLD | NEW |