From feee28e61b0337792c7129c54623c71adffc8ed1 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Wed, 2 Sep 2009 16:41:24 +0100 Subject: Updates MockGeolocationService to call back to the Geolocation object only when active. --- WebCore/platform/MockGeolocationService.cpp | 10 ++++++++++ WebCore/platform/MockGeolocationService.h | 3 +++ 2 files changed, 13 insertions(+) (limited to 'WebCore/platform') diff --git a/WebCore/platform/MockGeolocationService.cpp b/WebCore/platform/MockGeolocationService.cpp index 72d85ef..b147f53 100755 --- a/WebCore/platform/MockGeolocationService.cpp +++ b/WebCore/platform/MockGeolocationService.cpp @@ -45,6 +45,7 @@ GeolocationService* MockGeolocationService::create(GeolocationServiceClient* cli MockGeolocationService::MockGeolocationService(GeolocationServiceClient* client) : GeolocationService(client) , m_timer(this, &MockGeolocationService::timerFired) + , m_isActive(false) { s_instances->add(this); } @@ -77,10 +78,16 @@ void MockGeolocationService::setError(PassRefPtr error) bool MockGeolocationService::startUpdating(PositionOptions*) { + m_isActive = true; m_timer.startOneShot(0); return true; } +void MockGeolocationService::stopUpdating() +{ + m_isActive = false; +} + void MockGeolocationService::timerFired(Timer* timer) { ASSERT_UNUSED(timer, timer == &m_timer); @@ -99,6 +106,9 @@ void MockGeolocationService::makeGeolocationCallbackFromAllInstances() void MockGeolocationService::makeGeolocationCallback() { + if (!m_isActive) + return; + if (*s_lastPosition) { positionChanged(); } else if (*s_lastError) { diff --git a/WebCore/platform/MockGeolocationService.h b/WebCore/platform/MockGeolocationService.h index 2f190e6..6cb2493 100755 --- a/WebCore/platform/MockGeolocationService.h +++ b/WebCore/platform/MockGeolocationService.h @@ -47,6 +47,7 @@ class MockGeolocationService : public GeolocationService { virtual ~MockGeolocationService(); virtual bool startUpdating(PositionOptions*); + virtual void stopUpdating(); static void setPosition(PassRefPtr position); static void setError(PassRefPtr position); @@ -70,6 +71,8 @@ class MockGeolocationService : public GeolocationService { static RefPtr* s_lastError; Timer m_timer; + + bool m_isActive; }; } // namespace WebCore -- cgit v1.1