OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 DEVICE_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_ | 5 #ifndef DEVICE_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_ |
6 #define DEVICE_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_ | 6 #define DEVICE_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_ |
7 | 7 |
8 #include "base/android/jni_weak_ref.h" | 8 #include "base/android/jni_weak_ref.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Returns our singleton. | 43 // Returns our singleton. |
44 static AndroidLocationApiAdapter* GetInstance(); | 44 static AndroidLocationApiAdapter* GetInstance(); |
45 | 45 |
46 // Called when initializing chrome_view to obtain a pointer to the java class. | 46 // Called when initializing chrome_view to obtain a pointer to the java class. |
47 static bool RegisterGeolocationService(JNIEnv* env); | 47 static bool RegisterGeolocationService(JNIEnv* env); |
48 | 48 |
49 // Called by JNI on main thread looper. | 49 // Called by JNI on main thread looper. |
50 static void OnNewLocationAvailable(double latitude, | 50 static void OnNewLocationAvailable(double latitude, |
51 double longitude, | 51 double longitude, |
52 double time_stamp, | 52 double time_stamp, |
53 bool has_altitude, double altitude, | 53 bool has_altitude, |
54 bool has_accuracy, double accuracy, | 54 double altitude, |
55 bool has_heading, double heading, | 55 bool has_accuracy, |
56 bool has_speed, double speed); | 56 double accuracy, |
| 57 bool has_heading, |
| 58 double heading, |
| 59 bool has_speed, |
| 60 double speed); |
57 static void OnNewErrorAvailable(JNIEnv* env, jstring message); | 61 static void OnNewErrorAvailable(JNIEnv* env, jstring message); |
58 | 62 |
59 private: | 63 private: |
60 friend struct base::DefaultSingletonTraits<AndroidLocationApiAdapter>; | 64 friend struct base::DefaultSingletonTraits<AndroidLocationApiAdapter>; |
61 AndroidLocationApiAdapter(); | 65 AndroidLocationApiAdapter(); |
62 ~AndroidLocationApiAdapter(); | 66 ~AndroidLocationApiAdapter(); |
63 | 67 |
64 void CreateJavaObject(JNIEnv* env); | 68 void CreateJavaObject(JNIEnv* env); |
65 | 69 |
66 // Called on the JNI main thread looper. | 70 // Called on the JNI main thread looper. |
67 void OnNewGeopositionInternal(const Geoposition& geoposition); | 71 void OnNewGeopositionInternal(const Geoposition& geoposition); |
68 | 72 |
69 /// Called on the Geolocation thread. | 73 /// Called on the Geolocation thread. |
70 static void NotifyProviderNewGeoposition(const Geoposition& geoposition); | 74 static void NotifyProviderNewGeoposition(const Geoposition& geoposition); |
71 | 75 |
72 base::android::ScopedJavaGlobalRef<jobject> | 76 base::android::ScopedJavaGlobalRef<jobject> |
73 java_location_provider_android_object_; | 77 java_location_provider_android_object_; |
74 // TODO(mvanouwerkerk): Use a callback instead of holding a pointer. | 78 // TODO(mvanouwerkerk): Use a callback instead of holding a pointer. |
75 LocationProviderAndroid* location_provider_; // Owned by the arbitrator. | 79 LocationProviderAndroid* location_provider_; // Owned by the arbitrator. |
76 | 80 |
77 // Guards against the following member which is accessed on Geolocation | 81 // Guards against the following member which is accessed on Geolocation |
78 // thread and the JNI main thread looper. | 82 // thread and the JNI main thread looper. |
79 base::Lock lock_; | 83 base::Lock lock_; |
80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 84 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
81 }; | 85 }; |
82 | 86 |
83 } // namespace device | 87 } // namespace device |
84 | 88 |
85 #endif // DEVICE_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_ | 89 #endif // DEVICE_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_ |
OLD | NEW |