| 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 "content/browser/geolocation/location_api_adapter_android.h" | 5 #include "content/browser/geolocation/location_api_adapter_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| 37 | 37 |
| 38 AndroidLocationApiAdapter::AndroidLocationApiAdapter() | 38 AndroidLocationApiAdapter::AndroidLocationApiAdapter() |
| 39 : location_provider_(NULL) { | 39 : location_provider_(NULL) { |
| 40 } | 40 } |
| 41 | 41 |
| 42 AndroidLocationApiAdapter::~AndroidLocationApiAdapter() { | 42 AndroidLocationApiAdapter::~AndroidLocationApiAdapter() { |
| 43 CHECK(!location_provider_); | 43 CHECK(!location_provider_); |
| 44 CHECK(!message_loop_); | 44 CHECK(!message_loop_.get()); |
| 45 CHECK(java_location_provider_android_object_.is_null()); | 45 CHECK(java_location_provider_android_object_.is_null()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool AndroidLocationApiAdapter::Start( | 48 bool AndroidLocationApiAdapter::Start( |
| 49 LocationProviderAndroid* location_provider, bool high_accuracy) { | 49 LocationProviderAndroid* location_provider, bool high_accuracy) { |
| 50 JNIEnv* env = AttachCurrentThread(); | 50 JNIEnv* env = AttachCurrentThread(); |
| 51 if (!location_provider_) { | 51 if (!location_provider_) { |
| 52 location_provider_ = location_provider; | 52 location_provider_ = location_provider; |
| 53 CHECK(java_location_provider_android_object_.is_null()); | 53 CHECK(java_location_provider_android_object_.is_null()); |
| 54 CreateJavaObject(env); | 54 CreateJavaObject(env); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Create the Java AndroidLocationProvider object. | 144 // Create the Java AndroidLocationProvider object. |
| 145 java_location_provider_android_object_.Reset( | 145 java_location_provider_android_object_.Reset( |
| 146 Java_LocationProvider_create(env, | 146 Java_LocationProvider_create(env, |
| 147 base::android::GetApplicationContext())); | 147 base::android::GetApplicationContext())); |
| 148 CHECK(!java_location_provider_android_object_.is_null()); | 148 CHECK(!java_location_provider_android_object_.is_null()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void AndroidLocationApiAdapter::OnNewGeopositionInternal( | 151 void AndroidLocationApiAdapter::OnNewGeopositionInternal( |
| 152 const Geoposition& geoposition) { | 152 const Geoposition& geoposition) { |
| 153 base::AutoLock lock(lock_); | 153 base::AutoLock lock(lock_); |
| 154 if (!message_loop_) | 154 if (!message_loop_.get()) |
| 155 return; | 155 return; |
| 156 message_loop_->PostTask( | 156 message_loop_->PostTask( |
| 157 FROM_HERE, | 157 FROM_HERE, |
| 158 base::Bind( | 158 base::Bind( |
| 159 &AndroidLocationApiAdapter::NotifyProviderNewGeoposition, | 159 &AndroidLocationApiAdapter::NotifyProviderNewGeoposition, |
| 160 geoposition)); | 160 geoposition)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace content | 163 } // namespace content |
| OLD | NEW |