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

Side by Side Diff: chrome/browser/android/physical_web/physical_web_data_source_android.h

Issue 2561493002: Pass Physical Web metadata through a struct (Closed)
Patch Set: Fix missed compile errors 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 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 #ifndef CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_ 5 #ifndef CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_ 6 #define CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "components/physical_web/data_source/physical_web_data_source_impl.h" 12 #include "components/physical_web/data_source/physical_web_data_source_impl.h"
13 13
14 namespace base { 14 namespace base {
15 class ListValue; 15 class ListValue;
16 } 16 }
17 17
18 // A container for Physical Web metadata. This is primarily a wrapper for a 18 // A container for Physical Web metadata. This is primarily a wrapper for a
19 // ListValue so we can append to it over JNI. 19 // ListValue so we can append to it over JNI.
20 class PhysicalWebCollection { 20 class PhysicalWebCollection {
21 public: 21 public:
22 PhysicalWebCollection(); 22 PhysicalWebCollection();
23 ~PhysicalWebCollection(); 23 ~PhysicalWebCollection();
24 24
25 void AppendMetadataItem( 25 void AppendMetadataItem(
26 JNIEnv* env, 26 JNIEnv* env,
27 const base::android::JavaParamRef<jobject>& obj, 27 const base::android::JavaParamRef<jobject>& obj,
28 const base::android::JavaParamRef<jstring>& j_request_url, 28 const base::android::JavaParamRef<jstring>& j_request_url,
29 jdouble distance_estimate, 29 jdouble distance_estimate,
30 jint scan_timestamp, 30 jlong scan_timestamp,
31 const base::android::JavaParamRef<jstring>& j_site_url, 31 const base::android::JavaParamRef<jstring>& j_site_url,
32 const base::android::JavaParamRef<jstring>& j_icon_url, 32 const base::android::JavaParamRef<jstring>& j_icon_url,
33 const base::android::JavaParamRef<jstring>& j_title, 33 const base::android::JavaParamRef<jstring>& j_title,
34 const base::android::JavaParamRef<jstring>& j_description, 34 const base::android::JavaParamRef<jstring>& j_description,
35 const base::android::JavaParamRef<jstring>& j_group_id); 35 const base::android::JavaParamRef<jstring>& j_group_id);
36 36
37 // Returns the metadata list and transfers ownership of the list to the 37 // Returns the metadata list and transfers ownership of the list to the
38 // caller. Call only once. 38 // caller. Call only once.
39 std::unique_ptr<base::ListValue> GetMetadataList(); 39 std::unique_ptr<physical_web::MetadataList> GetMetadataList();
40
41 // Returns the metadata list and transfers ownership of the list to the
42 // caller. Call only once.
43 // DEPRECATED
44 // TODO(cco3): Remove when we no longer rely on this.
45 std::unique_ptr<base::ListValue> GetMetadataListValue();
40 46
41 private: 47 private:
42 std::unique_ptr<base::ListValue> metadata_list_; 48 std::unique_ptr<base::ListValue> dictionary_value_list_;
49 std::unique_ptr<physical_web::MetadataList> metadata_list_;
43 bool accessed_once_; 50 bool accessed_once_;
44 51
45 DISALLOW_COPY_AND_ASSIGN(PhysicalWebCollection); 52 DISALLOW_COPY_AND_ASSIGN(PhysicalWebCollection);
46 }; 53 };
47 54
48 class PhysicalWebDataSourceAndroid 55 class PhysicalWebDataSourceAndroid
49 : public physical_web::PhysicalWebDataSourceImpl { 56 : public physical_web::PhysicalWebDataSourceImpl {
50 public: 57 public:
51 PhysicalWebDataSourceAndroid(); 58 PhysicalWebDataSourceAndroid();
52 ~PhysicalWebDataSourceAndroid() override; 59 ~PhysicalWebDataSourceAndroid() override;
53 60
54 static bool RegisterPhysicalWebDataSource(JNIEnv* env); 61 static bool RegisterPhysicalWebDataSource(JNIEnv* env);
55 62
56 void Initialize(); 63 void Initialize();
57 64
58 void StartDiscovery(bool network_request_enabled) override; 65 void StartDiscovery(bool network_request_enabled) override;
59 void StopDiscovery() override; 66 void StopDiscovery() override;
60 67
61 std::unique_ptr<base::ListValue> GetMetadata() override; 68 std::unique_ptr<base::ListValue> GetMetadata() override;
69 std::unique_ptr<physical_web::MetadataList> GetMetadataList() override;
nyquist 2016/12/13 18:13:25 The naming of these methods do not seem consistent
cco3 2016/12/16 19:17:53 Good catch. The whole ListValue thing is temporar
62 bool HasUnresolvedDiscoveries() override; 70 bool HasUnresolvedDiscoveries() override;
63 71
64 void OnFound(JNIEnv* env, 72 void OnFound(JNIEnv* env,
65 const base::android::JavaParamRef<jobject>& obj, 73 const base::android::JavaParamRef<jobject>& obj,
66 const base::android::JavaParamRef<jstring>& j_url); 74 const base::android::JavaParamRef<jstring>& j_url);
67 void OnLost(JNIEnv* env, 75 void OnLost(JNIEnv* env,
68 const base::android::JavaParamRef<jobject>& obj, 76 const base::android::JavaParamRef<jobject>& obj,
69 const base::android::JavaParamRef<jstring>& j_url); 77 const base::android::JavaParamRef<jstring>& j_url);
70 void OnDistanceChanged(JNIEnv* env, 78 void OnDistanceChanged(JNIEnv* env,
71 const base::android::JavaParamRef<jobject>& obj, 79 const base::android::JavaParamRef<jobject>& obj,
72 const base::android::JavaParamRef<jstring>& j_url, 80 const base::android::JavaParamRef<jstring>& j_url,
73 jdouble distance_estimate); 81 jdouble distance_estimate);
74 82
75 private: 83 private:
76 // A reference to the Java UrlManager singleton. 84 // A reference to the Java UrlManager singleton.
77 base::android::ScopedJavaGlobalRef<jobject> url_manager_; 85 base::android::ScopedJavaGlobalRef<jobject> url_manager_;
78 86
79 DISALLOW_COPY_AND_ASSIGN(PhysicalWebDataSourceAndroid); 87 DISALLOW_COPY_AND_ASSIGN(PhysicalWebDataSourceAndroid);
80 }; 88 };
81 89
82 #endif // CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_ H_ 90 #endif // CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698