GeolocationManager.h [plain text]
#ifndef GeolocationManager_h
#define GeolocationManager_h
#include "GeolocationService.h"
#include "Geoposition.h"
#include "PositionError.h"
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
#ifdef __OBJC__
@class GeolocationCoreLocationDelegate;
#else
class GeolocationCoreLocationDelegate;
#endif
namespace WebCore {
class GeolocationServiceCoreLocation;
class GeolocationLink;
class GeolocationManager : public Noncopyable {
public:
static GeolocationManager& shared();
PassRefPtr<GeolocationLink> linkService(GeolocationServiceCoreLocation*, PositionOptions*);
void suspend();
void resume();
private:
GeolocationManager() : m_locationDelegate(0), m_linkedServices(), m_suspended(false), m_lastPosition(0), m_lastError(0) { }
void updatePositionOptions();
RetainPtr<GeolocationCoreLocationDelegate> m_locationDelegate;
HashSet<GeolocationLink*> m_linkedServices;
bool m_suspended;
RefPtr<Geoposition> m_lastPosition;
RefPtr<PositionError> m_lastError;
friend class GeolocationLink;
public:
void positionChanged(PassRefPtr<Geoposition>);
void errorOccurred(PassRefPtr<PositionError>);
};
class GeolocationLink : public RefCounted<GeolocationLink> {
public:
void suspend();
void resume();
virtual ~GeolocationLink();
private:
GeolocationLink(GeolocationServiceCoreLocation* service,
GeolocationManager* manager,
bool highAccuracy)
: m_service(service), m_geolocationManager(manager), m_suspended(false), m_wantsHighAccuracy(highAccuracy) { }
GeolocationServiceCoreLocation* m_service;
GeolocationManager* m_geolocationManager;
RefPtr<Geoposition> m_positionWaitingForResume;
RefPtr<PositionError> m_errorWaitingForResume;
bool m_suspended;
bool m_wantsHighAccuracy;
friend class GeolocationManager;
};
}
#endif // GeolocationManager_h