| 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 #include "device/geolocation/location_api_adapter_android.h" | 5 #include "device/geolocation/location_api_adapter_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | |
| 8 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/location.h" | 10 #include "base/location.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "device/geolocation/location_provider_android.h" | 12 #include "device/geolocation/location_provider_android.h" |
| 14 #include "jni/LocationProviderAdapter_jni.h" | 13 #include "jni/LocationProviderAdapter_jni.h" |
| 15 | 14 |
| 16 using base::android::AttachCurrentThread; | 15 using base::android::AttachCurrentThread; |
| 17 using base::android::JavaParamRef; | 16 using base::android::JavaParamRef; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 47 bool high_accuracy) { | 46 bool high_accuracy) { |
| 48 DCHECK(thread_checker_.CalledOnValidThread()); | 47 DCHECK(thread_checker_.CalledOnValidThread()); |
| 49 DCHECK(on_geoposition_callback); | 48 DCHECK(on_geoposition_callback); |
| 50 | 49 |
| 51 JNIEnv* env = AttachCurrentThread(); | 50 JNIEnv* env = AttachCurrentThread(); |
| 52 | 51 |
| 53 if (!on_geoposition_callback_) { | 52 if (!on_geoposition_callback_) { |
| 54 on_geoposition_callback_ = on_geoposition_callback; | 53 on_geoposition_callback_ = on_geoposition_callback; |
| 55 | 54 |
| 56 DCHECK(java_location_provider_adapter_.is_null()); | 55 DCHECK(java_location_provider_adapter_.is_null()); |
| 57 java_location_provider_adapter_.Reset(Java_LocationProviderAdapter_create( | 56 java_location_provider_adapter_.Reset( |
| 58 env, base::android::GetApplicationContext())); | 57 Java_LocationProviderAdapter_create(env)); |
| 59 } | 58 } |
| 60 | 59 |
| 61 // At this point we should have all our pre-conditions ready, and they'd only | 60 // At this point we should have all our pre-conditions ready, and they'd only |
| 62 // change in Stop() which must be called on the same thread as here. We'll | 61 // change in Stop() which must be called on the same thread as here. We'll |
| 63 // start receiving notifications from java in the main thread looper until | 62 // start receiving notifications from java in the main thread looper until |
| 64 // Stop() is called. | 63 // Stop() is called. |
| 65 DCHECK(!java_location_provider_adapter_.is_null()); | 64 DCHECK(!java_location_provider_adapter_.is_null()); |
| 66 return Java_LocationProviderAdapter_start( | 65 return Java_LocationProviderAdapter_start( |
| 67 env, java_location_provider_adapter_, high_accuracy); | 66 env, java_location_provider_adapter_, high_accuracy); |
| 68 } | 67 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 141 } |
| 143 | 142 |
| 144 void LocationApiAdapterAndroid::NotifyNewGeoposition( | 143 void LocationApiAdapterAndroid::NotifyNewGeoposition( |
| 145 const Geoposition& geoposition) { | 144 const Geoposition& geoposition) { |
| 146 DCHECK(thread_checker_.CalledOnValidThread()); | 145 DCHECK(thread_checker_.CalledOnValidThread()); |
| 147 if (on_geoposition_callback_) | 146 if (on_geoposition_callback_) |
| 148 on_geoposition_callback_.Run(geoposition); | 147 on_geoposition_callback_.Run(geoposition); |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace device | 150 } // namespace device |
| OLD | NEW |