summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/android/GeolocationServiceAndroid.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-11-08 07:56:39 +0000
committerSteve Block <steveblock@google.com>2009-11-09 22:10:22 +0000
commit7de0f59ef4a50e0a204f9918636f10b254865d5e (patch)
treef6a560781163bef9625d941229d12927893da66f /WebCore/platform/android/GeolocationServiceAndroid.cpp
parentb9fca1a768e8d5f3948b492fb962210af28d8d23 (diff)
downloadexternal_webkit-7de0f59ef4a50e0a204f9918636f10b254865d5e.zip
external_webkit-7de0f59ef4a50e0a204f9918636f10b254865d5e.tar.gz
external_webkit-7de0f59ef4a50e0a204f9918636f10b254865d5e.tar.bz2
Stop Geolocation service when browser tab is in the background. Do not merge.
This is a fix for bug http://b/issue?id=2211437 This has already been submitted to Eclair MR2 branch. Change-Id: I43c19e84fda6291590ff2f07bbadb18a4f86df5f
Diffstat (limited to 'WebCore/platform/android/GeolocationServiceAndroid.cpp')
-rw-r--r--WebCore/platform/android/GeolocationServiceAndroid.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/WebCore/platform/android/GeolocationServiceAndroid.cpp b/WebCore/platform/android/GeolocationServiceAndroid.cpp
index 782d515..9340053 100644
--- a/WebCore/platform/android/GeolocationServiceAndroid.cpp
+++ b/WebCore/platform/android/GeolocationServiceAndroid.cpp
@@ -51,6 +51,7 @@ public:
~GeolocationServiceBridge();
void start();
+ void stop();
void setEnableGps(bool enable);
// Static wrapper functions to hide JNI nastiness.
@@ -110,6 +111,7 @@ GeolocationServiceBridge::GeolocationServiceBridge(ListenerInterface* listener)
GeolocationServiceBridge::~GeolocationServiceBridge()
{
+ stop();
stopJavaImplementation();
}
@@ -120,6 +122,13 @@ void GeolocationServiceBridge::start()
javaGeolocationServiceClassMethodIDs[GEOLOCATION_SERVICE_METHOD_START]);
}
+void GeolocationServiceBridge::stop()
+{
+ ASSERT(m_javaGeolocationServiceObject);
+ getJNIEnv()->CallVoidMethod(m_javaGeolocationServiceObject,
+ javaGeolocationServiceClassMethodIDs[GEOLOCATION_SERVICE_METHOD_STOP]);
+}
+
void GeolocationServiceBridge::setEnableGps(bool enable)
{
ASSERT(m_javaGeolocationServiceObject);
@@ -254,8 +263,6 @@ void GeolocationServiceBridge::stopJavaImplementation()
{
// Called by GeolocationServiceAndroid on WebKit thread.
ASSERT(m_javaGeolocationServiceObject);
- getJNIEnv()->CallVoidMethod(m_javaGeolocationServiceObject,
- javaGeolocationServiceClassMethodIDs[GEOLOCATION_SERVICE_METHOD_STOP]);
getJNIEnv()->DeleteGlobalRef(m_javaGeolocationServiceObject);
}
@@ -322,6 +329,24 @@ void GeolocationServiceAndroid::stopUpdating()
m_lastError = 0;
}
+void GeolocationServiceAndroid::suspend()
+{
+ // If the Geolocation object has called stopUpdating, and hence the bridge
+ // object has been destroyed, we should not receive calls to this method
+ // until startUpdating is called again and the bridge is recreated.
+ ASSERT(m_javaBridge);
+ m_javaBridge->stop();
+}
+
+void GeolocationServiceAndroid::resume()
+{
+ // If the Geolocation object has called stopUpdating, and hence the bridge
+ // object has been destroyed, we should not receive calls to this method
+ // until startUpdating is called again and the bridge is recreated.
+ ASSERT(m_javaBridge);
+ m_javaBridge->start();
+}
+
// Note that there is no guarantee that subsequent calls to this method offer a
// more accurate or updated position.
void GeolocationServiceAndroid::newPositionAvailable(PassRefPtr<Geoposition> position)