summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-05-21 18:46:12 +0100
committerSteve Block <steveblock@google.com>2012-05-22 14:17:23 +0100
commitb80d1c52ad334f34843b52138f0ea684f2683904 (patch)
treef59653f9a5249f3f413a987693a9aa236c4695aa /Source/WebKit/android/WebCoreSupport
parent5c36c4ca9214cbbe65d12f6b138aef9618d41a99 (diff)
downloadexternal_webkit-b80d1c52ad334f34843b52138f0ea684f2683904.zip
external_webkit-b80d1c52ad334f34843b52138f0ea684f2683904.tar.gz
external_webkit-b80d1c52ad334f34843b52138f0ea684f2683904.tar.bz2
Always call back to new Geolocation requests
This change makes sure we always call back to new Geolocation requests, even when other requests are ongoing. Note that it requires an Android-specific change to WebCore to fix https://bugs.webkit.org/show_bug.cgi?id=87030. Bug: 6511338 Change-Id: If46d2ef0eb8e81925ae51ed2e8f2d16a9fa6c997
Diffstat (limited to 'Source/WebKit/android/WebCoreSupport')
-rw-r--r--Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.cpp29
-rw-r--r--Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.h3
2 files changed, 29 insertions, 3 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.cpp b/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.cpp
index fce0e37..4e53d08 100644
--- a/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.cpp
+++ b/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.cpp
@@ -41,6 +41,7 @@
using WebCore::Geolocation;
using WebCore::GeolocationError;
using WebCore::GeolocationPosition;
+using WebCore::Timer;
using namespace std;
@@ -78,6 +79,7 @@ namespace android {
GeolocationClientImpl::GeolocationClientImpl(WebViewCore* webViewCore)
: m_webViewCore(webViewCore)
+ , m_timer(this, &GeolocationClientImpl::timerFired)
, m_isSuspended(false)
, m_useGps(false)
{
@@ -94,9 +96,17 @@ void GeolocationClientImpl::geolocationDestroyed()
void GeolocationClientImpl::startUpdating()
{
+ // This method is called every time a new watch or one-shot position request
+ // is started. If we already have a position or an error, call back
+ // immediately.
+ if (m_lastPosition || m_lastError) {
+ m_timer.startOneShot(0);
+ }
+
// Lazilly create the Java object.
- ASSERT(!m_javaBridge);
- m_javaBridge.set(new GeolocationServiceBridge(this, m_webViewCore));
+ bool haveJavaBridge = m_javaBridge;
+ if (!haveJavaBridge)
+ m_javaBridge.set(new GeolocationServiceBridge(this, m_webViewCore));
ASSERT(m_javaBridge);
// Set whether to use GPS before we start the implementation.
@@ -104,7 +114,7 @@ void GeolocationClientImpl::startUpdating()
// If we're suspended, don't start the service. It will be started when we
// get the call to resume().
- if (!m_isSuspended)
+ if (!haveJavaBridge && !m_isSuspended)
m_javaBridge->start();
}
@@ -116,6 +126,9 @@ void GeolocationClientImpl::stopUpdating()
// new position from the client when a request is first made.
m_lastPosition = 0;
m_lastError = 0;
+
+ if (m_timer.isActive())
+ m_timer.stop();
}
void GeolocationClientImpl::setEnableHighAccuracy(bool enableHighAccuracy)
@@ -196,4 +209,14 @@ GeolocationPermissions* GeolocationClientImpl::permissions() const
return m_permissions.get();
}
+void GeolocationClientImpl::timerFired(Timer<GeolocationClientImpl>* timer)
+{
+ ASSERT(&m_timer == timer);
+ ASSERT(m_lastPosition || m_lastError);
+ if (m_lastPosition)
+ m_webViewCore->mainFrame()->page()->geolocationController()->positionChanged(m_lastPosition.get());
+ else
+ m_webViewCore->mainFrame()->page()->geolocationController()->errorOccurred(m_lastError.get());
+}
+
} // namespace android
diff --git a/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.h b/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.h
index 81a6db3..26e6c0c 100644
--- a/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.h
+++ b/Source/WebKit/android/WebCoreSupport/GeolocationClientImpl.h
@@ -30,6 +30,7 @@
#include "GeolocationClient.h"
#include "GeolocationPermissions.h"
+#include <Timer.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
@@ -68,12 +69,14 @@ public:
private:
GeolocationPermissions* permissions() const;
+ void timerFired(WebCore::Timer<GeolocationClientImpl>*);
WebViewCore* m_webViewCore;
RefPtr<WebCore::GeolocationPosition> m_lastPosition;
RefPtr<WebCore::GeolocationError> m_lastError;
OwnPtr<GeolocationServiceBridge> m_javaBridge;
mutable OwnPtr<GeolocationPermissions> m_permissions;
+ WebCore::Timer<GeolocationClientImpl> m_timer;
bool m_isSuspended;
bool m_useGps;
};