summaryrefslogtreecommitdiffstats
path: root/WebCore/page/GeolocationPositionCache.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/page/GeolocationPositionCache.h')
-rw-r--r--WebCore/page/GeolocationPositionCache.h44
1 files changed, 33 insertions, 11 deletions
diff --git a/WebCore/page/GeolocationPositionCache.h b/WebCore/page/GeolocationPositionCache.h
index dd57180..1398850 100644
--- a/WebCore/page/GeolocationPositionCache.h
+++ b/WebCore/page/GeolocationPositionCache.h
@@ -26,31 +26,53 @@
#ifndef GeolocationPositionCache_h
#define GeolocationPositionCache_h
+#include "PlatformString.h"
+#include "ScriptExecutionContext.h"
+
#include <wtf/Forward.h>
+#include <wtf/MessageQueue.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
-
namespace WebCore {
class Geoposition;
+// Maintains a cached position for Geolocation. Takes care of writing and
+// reading the position to a database on a background thread. The Geolocation
+// spec does not require a cached position to be maintained, so we take a
+// best-effort approach where we do not wait for database reads or writes.
class GeolocationPositionCache {
- public:
- GeolocationPositionCache();
- ~GeolocationPositionCache();
+public:
+ static GeolocationPositionCache* instance();
+
+ void addUser();
+ void removeUser();
+ void setDatabasePath(const String&);
void setCachedPosition(Geoposition*);
Geoposition* cachedPosition();
- static void setDatabasePath(const String&);
- private:
- static PassRefPtr<Geoposition> readFromDB();
- static void writeToDB(const Geoposition*);
+private:
+ GeolocationPositionCache();
+
+ void startBackgroundThread();
+ static void* threadEntryPoint(void* object);
+ void threadEntryPointImpl();
+
+ void triggerReadFromDatabase();
+ static void readFromDatabase(ScriptExecutionContext*, GeolocationPositionCache*);
+ void readFromDatabaseImpl();
+ void triggerWriteToDatabase();
+ static void writeToDatabase(ScriptExecutionContext*, GeolocationPositionCache*);
+ void writeToDatabaseImpl();
- static int s_instances;
- static RefPtr<Geoposition>* s_cachedPosition;
- static String* s_databaseFile;
+ RefPtr<Geoposition> m_cachedPosition;
+ Mutex m_cachedPositionMutex;
+ ThreadIdentifier m_threadId;
+ MessageQueue<ScriptExecutionContext::Task> m_queue;
+ String m_databaseFile;
+ Mutex m_databaseFileMutex;
};
} // namespace WebCore