diff options
author | Andrei Popescu <andreip@google.com> | 2009-08-20 11:17:03 +0100 |
---|---|---|
committer | Andrei Popescu <andreip@google.com> | 2009-08-20 11:17:03 +0100 |
commit | 49315cdd678492377ae2b9ff511555f106e01323 (patch) | |
tree | 9f643a5de3eaf28323ed7c256239ac504f930df7 /WebCore | |
parent | cabf1bfc240bac8f24ff95e3bcc9d2d01d3b8a37 (diff) | |
parent | 7670c997a41d2188c47daf20281001f79799c1ff (diff) | |
download | external_webkit-49315cdd678492377ae2b9ff511555f106e01323.zip external_webkit-49315cdd678492377ae2b9ff511555f106e01323.tar.gz external_webkit-49315cdd678492377ae2b9ff511555f106e01323.tar.bz2 |
Merge commit 'goog/master' into merge
Diffstat (limited to 'WebCore')
-rwxr-xr-x | WebCore/platform/MockGeolocationService.cpp | 53 | ||||
-rwxr-xr-x | WebCore/platform/MockGeolocationService.h | 13 |
2 files changed, 46 insertions, 20 deletions
diff --git a/WebCore/platform/MockGeolocationService.cpp b/WebCore/platform/MockGeolocationService.cpp index d26e5b2..45e7348 100755 --- a/WebCore/platform/MockGeolocationService.cpp +++ b/WebCore/platform/MockGeolocationService.cpp @@ -32,12 +32,13 @@ namespace WebCore { -MockGeolocationService::MockGeolocationServiceSet MockGeolocationService::s_instances; -RefPtr<Geoposition> MockGeolocationService::s_lastPosition = 0; -RefPtr<PositionError> MockGeolocationService::s_lastError = 0; +MockGeolocationService::MockGeolocationServiceSet* MockGeolocationService::s_instances = 0; +RefPtr<Geoposition>* MockGeolocationService::s_lastPosition; +RefPtr<PositionError>* MockGeolocationService::s_lastError; GeolocationService* MockGeolocationService::create(GeolocationServiceClient* client) { + initStatics(); return new MockGeolocationService(client); } @@ -45,27 +46,30 @@ MockGeolocationService::MockGeolocationService(GeolocationServiceClient* client) : GeolocationService(client) , m_timer(this, &MockGeolocationService::timerFired) { - s_instances.add(this); + s_instances->add(this); } MockGeolocationService::~MockGeolocationService() { - MockGeolocationServiceSet::iterator iter = s_instances.find(this); - ASSERT(iter != s_instances.end()); - s_instances.remove(iter); + MockGeolocationServiceSet::iterator iter = s_instances->find(this); + ASSERT(iter != s_instances->end()); + s_instances->remove(iter); + cleanUpStatics(); } void MockGeolocationService::setPosition(PassRefPtr<Geoposition> position) { - s_lastPosition = position; - s_lastError = 0; + initStatics(); + *s_lastPosition = position; + *s_lastError = 0; makeGeolocationCallbackFromAllInstances(); } void MockGeolocationService::setError(PassRefPtr<PositionError> error) { - s_lastError = error; - s_lastPosition = 0; + initStatics(); + *s_lastError = error; + *s_lastPosition = 0; makeGeolocationCallbackFromAllInstances(); } @@ -83,8 +87,8 @@ void MockGeolocationService::timerFired(Timer<MockGeolocationService>* timer) void MockGeolocationService::makeGeolocationCallbackFromAllInstances() { - MockGeolocationServiceSet::const_iterator end = s_instances.end(); - for (MockGeolocationServiceSet::const_iterator iter = s_instances.begin(); + MockGeolocationServiceSet::const_iterator end = s_instances->end(); + for (MockGeolocationServiceSet::const_iterator iter = s_instances->begin(); iter != end; ++iter) { (*iter)->makeGeolocationCallback(); @@ -93,11 +97,30 @@ void MockGeolocationService::makeGeolocationCallbackFromAllInstances() void MockGeolocationService::makeGeolocationCallback() { - if (s_lastPosition) { + if (*s_lastPosition) { positionChanged(); - } else if (s_lastError) { + } else if (*s_lastError) { errorOccurred(); } } +void MockGeolocationService::initStatics() +{ + if (s_instances == 0) { + s_instances = new MockGeolocationServiceSet; + s_lastPosition = new RefPtr<Geoposition>; + s_lastError = new RefPtr<PositionError>; + } +} + +void MockGeolocationService::cleanUpStatics() +{ + if (s_instances->size() == 0) { + delete s_instances; + s_instances = 0; + delete s_lastPosition; + delete s_lastError; + } +} + } // namespace WebCore diff --git a/WebCore/platform/MockGeolocationService.h b/WebCore/platform/MockGeolocationService.h index ae681b1..eb92cbc 100755 --- a/WebCore/platform/MockGeolocationService.h +++ b/WebCore/platform/MockGeolocationService.h @@ -51,8 +51,8 @@ class MockGeolocationService : public GeolocationService { static void setPosition(PassRefPtr<Geoposition> position); static void setError(PassRefPtr<PositionError> position); - virtual Geoposition* lastPosition() const { return s_lastPosition.get(); } - virtual PositionError* lastError() const { return s_lastError.get(); } + virtual Geoposition* lastPosition() const { return s_lastPosition->get(); } + virtual PositionError* lastError() const { return s_lastError->get(); } private: static void makeGeolocationCallbackFromAllInstances(); @@ -60,11 +60,14 @@ class MockGeolocationService : public GeolocationService { void timerFired(Timer<MockGeolocationService>*); - static RefPtr<Geoposition> s_lastPosition; - static RefPtr<PositionError> s_lastError; + static void initStatics(); + static void cleanUpStatics(); + + static RefPtr<Geoposition>* s_lastPosition; + static RefPtr<PositionError>* s_lastError; typedef HashSet<MockGeolocationService*> MockGeolocationServiceSet; - static MockGeolocationServiceSet s_instances; + static MockGeolocationServiceSet* s_instances; Timer<MockGeolocationService> m_timer; }; |