<http://webkit.org/b/65289> Remove GeolocationPositionCache
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jul 2011 16:57:32 +0000 (16:57 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jul 2011 16:57:32 +0000 (16:57 +0000)
Reviewed by Adam Barth.

* CMakeLists.txt: Remove references to GeolocationPositionCache.
* GNUmakefile.list.am: Ditto.
* WebCore.gypi: Ditto.
* WebCore.order: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* page/Geolocation.cpp: Switch from using m_positionCache to
m_cachedPosition.
(WebCore::Geolocation::makeCachedPositionCallbacks):
(WebCore::Geolocation::haveSuitableCachedPosition):
(WebCore::Geolocation::positionChangedInternal):
* page/Geolocation.h: Remove PositionCacheWrapper and replace
with RefPtr<Geoposition>.
* page/GeolocationPositionCache.cpp: Removed.
* page/GeolocationPositionCache.h: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91936 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.order
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/Geolocation.cpp
Source/WebCore/page/Geolocation.h
Source/WebCore/page/GeolocationPositionCache.cpp [deleted file]
Source/WebCore/page/GeolocationPositionCache.h [deleted file]

index 31a3928..8719dc3 100644 (file)
@@ -973,7 +973,6 @@ SET(WebCore_SOURCES
     page/FrameView.cpp
     page/Geolocation.cpp
     page/GeolocationController.cpp
-    page/GeolocationPositionCache.cpp
     page/GroupSettings.cpp
     page/History.cpp
     page/Location.cpp
index 6932e9b..8385892 100644 (file)
@@ -1,3 +1,27 @@
+2011-07-28  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/65289> Remove GeolocationPositionCache
+
+        Reviewed by Adam Barth.
+
+        * CMakeLists.txt: Remove references to GeolocationPositionCache.
+        * GNUmakefile.list.am: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.order: Ditto.
+        * WebCore.pro: Ditto.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+
+        * page/Geolocation.cpp: Switch from using m_positionCache to
+        m_cachedPosition.
+        (WebCore::Geolocation::makeCachedPositionCallbacks):
+        (WebCore::Geolocation::haveSuitableCachedPosition):
+        (WebCore::Geolocation::positionChangedInternal):
+        * page/Geolocation.h: Remove PositionCacheWrapper and replace
+        with RefPtr<Geoposition>.
+        * page/GeolocationPositionCache.cpp: Removed.
+        * page/GeolocationPositionCache.h: Removed.
+
 2011-07-28  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/9589433> Displaying Japanese dictionary contents in vertical orientation takes a couple of seconds
index e62d13d..30257f2 100644 (file)
@@ -2253,8 +2253,6 @@ webcore_sources += \
        Source/WebCore/page/GeolocationController.h \
        Source/WebCore/page/GeolocationError.h \
        Source/WebCore/page/GeolocationPosition.h \
-       Source/WebCore/page/GeolocationPositionCache.cpp \
-       Source/WebCore/page/GeolocationPositionCache.h \
        Source/WebCore/page/Geoposition.h \
        Source/WebCore/page/GroupSettings.cpp \
        Source/WebCore/page/GroupSettings.h \
index db0ccd6..40f7e53 100644 (file)
             'page/GeolocationController.h',
             'page/GeolocationError.h',
             'page/GeolocationPosition.h',
-            'page/GeolocationPositionCache.h',
             'page/Geoposition.h',
             'page/GroupSettings.h',
             'page/HaltablePlugin.h',
             'page/FrameView.cpp',
             'page/Geolocation.cpp',
             'page/GeolocationController.cpp',
-            'page/GeolocationPositionCache.cpp',
             'page/GroupSettings.cpp',
             'page/History.cpp',
             'page/History.h',
index 02d7bd0..8dfa4d6 100644 (file)
@@ -23624,8 +23624,6 @@ __ZN7WebCore4Node9setPrefixERKN3WTF12AtomicStringERi
 __ZN7WebCore22jsNavigatorGeolocationEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
 __ZNK7WebCore9Navigator11geolocationEv
 __ZN7WebCore11GeolocationC1EPNS_5FrameE
-__ZN7WebCore24GeolocationPositionCache8instanceEv
-__ZN7WebCore24GeolocationPositionCache7addUserEv
 __ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_11GeolocationE
 __ZN7WebCore4wrapINS_13JSGeolocationENS_11GeolocationEEEN3JSC7JSValueEPNS3_9ExecStateEPNS_17JSDOMGlobalObjectEPT0_
 __ZN7WebCore15getDOMStructureINS_13JSGeolocationEEEPN3JSC9StructureEPNS2_9ExecStateEPNS_17JSDOMGlobalObjectE
@@ -23640,7 +23638,6 @@ __ZN7WebCore14JSCallbackDataC2EPN3JSC8JSObjectEPNS_17JSDOMGlobalObjectE
 __ZN7WebCoreL21createPositionOptionsEPN3JSC9ExecStateENS0_7JSValueE
 __ZN7WebCore11Geolocation18getCurrentPositionEN3WTF10PassRefPtrINS_16PositionCallbackEEENS2_INS_21PositionErrorCallbackEEENS2_INS_15PositionOptionsEEE
 __ZN7WebCore11Geolocation12startRequestEN3WTF10PassRefPtrINS_16PositionCallbackEEENS2_INS_21PositionErrorCallbackEEENS2_INS_15PositionOptionsEEE
-__ZN7WebCore24GeolocationPositionCache14cachedPositionEv
 __ZN7WebCore21GeolocationController17requestPermissionEPNS_11GeolocationE
 __ZN7WebCore24JSCustomPositionCallbackD0Ev
 __ZN7WebCore29JSCustomPositionErrorCallbackC1EPN3JSC8JSObjectEPNS_17JSDOMGlobalObjectE
@@ -23688,7 +23685,6 @@ __ZN7WebCore15JSPositionErrorD1Ev
 __ZN7WebCore29JSCustomPositionErrorCallbackD0Ev
 __ZN7WebCore11GeolocationD1Ev
 __ZN7WebCore11GeolocationD2Ev
-__ZN7WebCore24GeolocationPositionCache10removeUserEv
 __ZN7WebCore11Geolocation8WatchersD1Ev
 __ZN7WebCore21GeolocationController15positionChangedEPNS_19GeolocationPositionE
 __ZN3WTF12copyToVectorINS_6RefPtrIN7WebCore11GeolocationEEENS_7PtrHashIS4_EENS_10HashTraitsIS4_EENS_6VectorIS4_Lm0EEEEEvRKNS_7HashSetIT_T0_T1_EERT2_
@@ -23697,7 +23693,6 @@ __ZN7WebCore11Geolocation15positionChangedEv
 __ZN7WebCore11Geolocation23positionChangedInternalEv
 __ZN7WebCore11Geolocation12lastPositionEv
 __ZN7WebCore21GeolocationController12lastPositionEv
-__ZN7WebCore24GeolocationPositionCache17setCachedPositionEPNS_11GeopositionE
 __ZN7WebCore11Geolocation21stopTimersForOneShotsEv
 __ZN7WebCore11Geolocation9stopTimerERN3WTF6VectorINS1_6RefPtrINS0_11GeoNotifierEEELm0EEE
 __ZN7WebCore11Geolocation21stopTimersForWatchersEv
index 2538b1a..b4fb08b 100644 (file)
@@ -922,7 +922,6 @@ SOURCES += \
     page/FrameView.cpp \
     page/Geolocation.cpp \
     page/GeolocationController.cpp \
-    page/GeolocationPositionCache.cpp \
     page/GroupSettings.cpp \
     page/History.cpp \
     page/Location.cpp \
@@ -1893,7 +1892,6 @@ HEADERS += \
     page/FrameTree.h \
     page/FrameView.h \
     page/Geolocation.h \
-    page/GeolocationPositionCache.h \
     page/Geoposition.h \
     page/GroupSettings.h \
     page/HaltablePlugin.h \
index 93d6580..ca594d3 100755 (executable)
                                >
                        </File>
                        <File
-                               RelativePath="..\page\GeolocationPositionCache.cpp"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\page\GeolocationPositionCache.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\page\Geoposition.h"
                                >
                        </File>
index f9fbc77..8670e5a 100644 (file)
                59309A1311F4AE6A00250603 /* DeviceOrientationClientMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */; settings = {ATTRIBUTES = (Private, ); }; };
                593D3EAF1325328C0057E7EE /* JavaMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = 593D3EAE1325328C0057E7EE /* JavaMethod.h */; };
                593D3EB1132532950057E7EE /* JavaString.h in Headers */ = {isa = PBXBuildFile; fileRef = 593D3EB0132532950057E7EE /* JavaString.h */; };
-               596229781133EFD700DC4CBB /* GeolocationPositionCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */; };
-               5962297A1133EFE200DC4CBB /* GeolocationPositionCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 596229791133EFE200DC4CBB /* GeolocationPositionCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
                596950821321059900C3ED18 /* JobjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 596950811321059900C3ED18 /* JobjectWrapper.h */; };
                59695084132105A500C3ED18 /* JobjectWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59695083132105A500C3ED18 /* JobjectWrapper.cpp */; };
                598365DD1355F557001B185D /* JSPositionCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 598365DC1355F53C001B185D /* JSPositionCallback.h */; };
                593D3EB0132532950057E7EE /* JavaString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaString.h; sourceTree = "<group>"; };
                5958F1CB1343917C0080B31F /* XMLViewer.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = XMLViewer.css; sourceTree = "<group>"; };
                5958F1CC1343917C0080B31F /* XMLViewer.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = XMLViewer.js; sourceTree = "<group>"; };
-               596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationPositionCache.cpp; sourceTree = "<group>"; };
-               596229791133EFE200DC4CBB /* GeolocationPositionCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationPositionCache.h; sourceTree = "<group>"; };
                596950811321059900C3ED18 /* JobjectWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JobjectWrapper.h; sourceTree = "<group>"; };
                59695083132105A500C3ED18 /* JobjectWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JobjectWrapper.cpp; sourceTree = "<group>"; };
                598365DC1355F53C001B185D /* JSPositionCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPositionCallback.h; sourceTree = "<group>"; };
                                BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */,
                                BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */,
                                BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */,
-                               596229771133EFD700DC4CBB /* GeolocationPositionCache.cpp */,
-                               596229791133EFE200DC4CBB /* GeolocationPositionCache.h */,
                                FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */,
                                FE80D7BC0E9C1F25000D6F75 /* Geoposition.idl */,
                                C50B561412119D23008B46E0 /* GroupSettings.cpp */,
                                BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */,
                                BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */,
                                BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */,
-                               5962297A1133EFE200DC4CBB /* GeolocationPositionCache.h in Headers */,
                                FE80D7C90E9C1F25000D6F75 /* Geoposition.h in Headers */,
                                086BBD0F136039C2008B15D8 /* Glyph.h in Headers */,
                                B2C3DA6C0D006CD600EF6F26 /* GlyphBuffer.h in Headers */,
                                FE80D7C50E9C1F25000D6F75 /* Geolocation.cpp in Sources */,
                                052BFCE9128ABF1500FD338D /* GeolocationClientMock.cpp in Sources */,
                                BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */,
-                               596229781133EFD700DC4CBB /* GeolocationPositionCache.cpp in Sources */,
                                B2C3DA6D0D006CD600EF6F26 /* GlyphPageTreeNode.cpp in Sources */,
                                B2AFFC830D00A5C10030074D /* GlyphPageTreeNodeMac.cpp in Sources */,
                                BC53C6080DA56C570021EB5D /* Gradient.cpp in Sources */,
index cc3dfa8..2c813a5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
  * Copyright (C) 2009 Torch Mobile, Inc.
  * Copyright 2010, The Android Open Source Project
  *
@@ -372,7 +372,7 @@ void Geolocation::makeCachedPositionCallbacks()
     GeoNotifierSet::const_iterator end = m_requestsAwaitingCachedPosition.end();
     for (GeoNotifierSet::const_iterator iter = m_requestsAwaitingCachedPosition.begin(); iter != end; ++iter) {
         GeoNotifier* notifier = iter->get();
-        notifier->runSuccessCallback(m_positionCache.cachedPosition());
+        notifier->runSuccessCallback(m_cachedPosition.get());
 
         // If this is a one-shot request, stop it. Otherwise, if the watch still
         // exists, start the service to get updates.
@@ -403,14 +403,14 @@ void Geolocation::requestTimedOut(GeoNotifier* notifier)
 
 bool Geolocation::haveSuitableCachedPosition(PositionOptions* options)
 {
-    if (!m_positionCache.cachedPosition())
+    if (!m_cachedPosition)
         return false;
     if (!options->hasMaximumAge())
         return true;
     if (!options->maximumAge())
         return false;
     DOMTimeStamp currentTimeMillis = convertSecondsToDOMTimeStamp(currentTime());
-    return m_positionCache.cachedPosition()->timestamp() > currentTimeMillis - options->maximumAge();
+    return m_cachedPosition->timestamp() > currentTimeMillis - options->maximumAge();
 }
 
 void Geolocation::clearWatch(int watchId)
@@ -625,7 +625,7 @@ void Geolocation::requestPermission()
 
 void Geolocation::positionChangedInternal()
 {
-    m_positionCache.setCachedPosition(lastPosition());
+    m_cachedPosition = lastPosition();
 
     // Stop all currently running timers.
     stopTimers();
index 0bdb1a5..f96c5a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All Rights Reserved.
  * Copyright 2010, The Android Open Source Project
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 #ifndef Geolocation_h
 #define Geolocation_h
 
-#include "GeolocationPositionCache.h"
+#include "Geoposition.h"
 #include "PositionCallback.h"
 #include "PositionError.h"
 #include "PositionErrorCallback.h"
@@ -45,7 +45,6 @@ class Frame;
 class GeolocationPosition;
 class GeolocationError;
 #endif
-class Geoposition;
 class Page;
 
 class Geolocation : public RefCounted<Geolocation>
@@ -131,23 +130,6 @@ private:
         NotifierToIdMap m_notifierToIdMap;
     };
 
-    class PositionCacheWrapper {
-    public:
-        PositionCacheWrapper()
-            : m_cache(GeolocationPositionCache::instance())
-        {
-            m_cache->addUser();
-        }
-        ~PositionCacheWrapper()
-        {
-            m_cache->removeUser();
-        }
-        void setCachedPosition(Geoposition* cachedPosition) { m_cache->setCachedPosition(cachedPosition); }
-        Geoposition* cachedPosition() { return m_cache->cachedPosition(); }
-    private:
-        GeolocationPositionCache* m_cache;
-    };
-
     bool hasListeners() const { return !m_oneShots.isEmpty() || !m_watchers.isEmpty(); }
 
     void sendError(GeoNotifierVector&, PositionError*);
@@ -210,7 +192,7 @@ private:
     } m_allowGeolocation;
 
 #if ENABLE(GEOLOCATION)
-    PositionCacheWrapper m_positionCache;
+    RefPtr<Geoposition> m_cachedPosition;
 #endif
     GeoNotifierSet m_requestsAwaitingCachedPosition;
 };
diff --git a/Source/WebCore/page/GeolocationPositionCache.cpp b/Source/WebCore/page/GeolocationPositionCache.cpp
deleted file mode 100644 (file)
index a42f2ec..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GeolocationPositionCache.h"
-
-#if ENABLE(GEOLOCATION)
-
-#include "CrossThreadTask.h"
-#include "Geoposition.h"
-#include "SQLValue.h"
-#include "SQLiteDatabase.h"
-#include "SQLiteFileSystem.h"
-#include "SQLiteStatement.h"
-#include "SQLiteTransaction.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Threading.h>
-
-using namespace WTF;
-
-namespace WebCore {
-
-static int numUsers = 0;
-
-GeolocationPositionCache* GeolocationPositionCache::instance()
-{
-    DEFINE_STATIC_LOCAL(GeolocationPositionCache*, instance, (0));
-    if (!instance)
-        instance = new GeolocationPositionCache();
-    return instance;
-}
-
-GeolocationPositionCache::GeolocationPositionCache()
-    : m_threadId(0)
-{
-}
-
-void GeolocationPositionCache::addUser()
-{
-    ASSERT(numUsers >= 0);
-    MutexLocker databaseLock(m_databaseFileMutex);
-    if (!numUsers && !m_threadId && !m_databaseFile.isNull()) {
-        startBackgroundThread();
-        MutexLocker lock(m_cachedPositionMutex);
-        if (!m_cachedPosition)
-            triggerReadFromDatabase();
-    }
-    ++numUsers;
-}
-
-void GeolocationPositionCache::removeUser()
-{
-    MutexLocker lock(m_cachedPositionMutex);
-    --numUsers;
-    ASSERT(numUsers >= 0);
-    if (!numUsers && m_cachedPosition && m_threadId)
-        triggerWriteToDatabase();
-}
-
-void GeolocationPositionCache::setDatabasePath(const String& path)
-{
-    static const char* databaseName = "CachedGeoposition.db";
-    String newFile = SQLiteFileSystem::appendDatabaseFileNameToPath(path, databaseName);
-    MutexLocker lock(m_databaseFileMutex);
-    if (m_databaseFile != newFile) {
-        m_databaseFile = newFile;
-        if (numUsers && !m_threadId) {
-            startBackgroundThread();
-            if (!m_cachedPosition)
-                triggerReadFromDatabase();
-        }
-    }
-}
-
-void GeolocationPositionCache::setCachedPosition(Geoposition* cachedPosition)
-{
-    MutexLocker lock(m_cachedPositionMutex);
-    m_cachedPosition = cachedPosition;
-}
-
-Geoposition* GeolocationPositionCache::cachedPosition()
-{
-    MutexLocker lock(m_cachedPositionMutex);
-    return m_cachedPosition.get();
-}
-
-void GeolocationPositionCache::startBackgroundThread()
-{
-    // FIXME: Consider sharing this thread with other background tasks.
-    m_threadId = createThread(threadEntryPoint, this, "WebCore: Geolocation cache");
-}
-
-void* GeolocationPositionCache::threadEntryPoint(void* object)
-{
-    static_cast<GeolocationPositionCache*>(object)->threadEntryPointImpl();
-    return 0;
-}
-
-void GeolocationPositionCache::threadEntryPointImpl()
-{
-    while (OwnPtr<ScriptExecutionContext::Task> task = m_queue.waitForMessage()) {
-        // We don't need a ScriptExecutionContext in the callback, so pass 0 here.
-        task->performTask(0);
-    }
-}
-
-void GeolocationPositionCache::triggerReadFromDatabase()
-{
-    m_queue.append(createCallbackTask(&GeolocationPositionCache::readFromDatabase, AllowCrossThreadAccess(this)));
-}
-
-void GeolocationPositionCache::readFromDatabase(ScriptExecutionContext*, GeolocationPositionCache* cache)
-{
-    cache->readFromDatabaseImpl();
-}
-
-void GeolocationPositionCache::readFromDatabaseImpl()
-{
-    SQLiteDatabase database;
-    {
-        MutexLocker lock(m_databaseFileMutex);
-        if (!database.open(m_databaseFile))
-            return;
-    }
-
-    // Create the table here, such that even if we've just created the
-    // DB, the commands below should succeed.
-    if (!database.executeCommand("CREATE TABLE IF NOT EXISTS CachedPosition ("
-            "latitude REAL NOT NULL, "
-            "longitude REAL NOT NULL, "
-            "altitude REAL, "
-            "accuracy REAL NOT NULL, "
-            "altitudeAccuracy REAL, "
-            "heading REAL, "
-            "speed REAL, "
-            "timestamp INTEGER NOT NULL)"))
-        return;
-
-    SQLiteStatement statement(database, "SELECT * FROM CachedPosition");
-    if (statement.prepare() != SQLResultOk)
-        return;
-
-    if (statement.step() != SQLResultRow)
-        return;
-
-    bool providesAltitude = statement.getColumnValue(2).type() != SQLValue::NullValue;
-    bool providesAltitudeAccuracy = statement.getColumnValue(4).type() != SQLValue::NullValue;
-    bool providesHeading = statement.getColumnValue(5).type() != SQLValue::NullValue;
-    bool providesSpeed = statement.getColumnValue(6).type() != SQLValue::NullValue;
-    RefPtr<Coordinates> coordinates = Coordinates::create(statement.getColumnDouble(0), // latitude
-                                                          statement.getColumnDouble(1), // longitude
-                                                          providesAltitude, statement.getColumnDouble(2), // altitude
-                                                          statement.getColumnDouble(3), // accuracy
-                                                          providesAltitudeAccuracy, statement.getColumnDouble(4), // altitudeAccuracy
-                                                          providesHeading, statement.getColumnDouble(5), // heading
-                                                          providesSpeed, statement.getColumnDouble(6)); // speed
-    DOMTimeStamp timestamp = statement.getColumnInt64(7); // timestamp
-
-    // A position may have been set since we called triggerReadFromDatabase().
-    MutexLocker lock(m_cachedPositionMutex);
-    if (m_cachedPosition)
-        return;
-    m_cachedPosition = Geoposition::create(coordinates.release(), timestamp);
-}
-
-void GeolocationPositionCache::triggerWriteToDatabase()
-{
-    m_queue.append(createCallbackTask(writeToDatabase, AllowCrossThreadAccess(this)));
-}
-
-void GeolocationPositionCache::writeToDatabase(ScriptExecutionContext*, GeolocationPositionCache* cache)
-{
-    cache->writeToDatabaseImpl();
-}
-
-void GeolocationPositionCache::writeToDatabaseImpl()
-{
-    SQLiteDatabase database;
-    {
-        MutexLocker lock(m_databaseFileMutex);
-        if (!database.open(m_databaseFile))
-            return;
-    }
-
-    RefPtr<Geoposition> cachedPosition;
-    {
-        MutexLocker lock(m_cachedPositionMutex);
-        if (m_cachedPosition)
-            cachedPosition = m_cachedPosition->threadSafeCopy();
-    }
-
-    SQLiteTransaction transaction(database);
-
-    if (!database.executeCommand("DELETE FROM CachedPosition"))
-        return;
-
-    SQLiteStatement statement(database, "INSERT INTO CachedPosition ("
-        "latitude, "
-        "longitude, "
-        "altitude, "
-        "accuracy, "
-        "altitudeAccuracy, "
-        "heading, "
-        "speed, "
-        "timestamp) "
-        "VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
-    if (statement.prepare() != SQLResultOk)
-        return;
-
-    statement.bindDouble(1, cachedPosition->coords()->latitude());
-    statement.bindDouble(2, cachedPosition->coords()->longitude());
-    if (cachedPosition->coords()->canProvideAltitude())
-        statement.bindDouble(3, cachedPosition->coords()->altitude());
-    else
-        statement.bindNull(3);
-    statement.bindDouble(4, cachedPosition->coords()->accuracy());
-    if (cachedPosition->coords()->canProvideAltitudeAccuracy())
-        statement.bindDouble(5, cachedPosition->coords()->altitudeAccuracy());
-    else
-        statement.bindNull(5);
-    if (cachedPosition->coords()->canProvideHeading())
-        statement.bindDouble(6, cachedPosition->coords()->heading());
-    else
-        statement.bindNull(6);
-    if (cachedPosition->coords()->canProvideSpeed())
-        statement.bindDouble(7, cachedPosition->coords()->speed());
-    else
-        statement.bindNull(7);
-    statement.bindInt64(8, cachedPosition->timestamp());
-
-    if (!statement.executeCommand())
-        return;
-
-    transaction.commit();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GEOLOCATION)
diff --git a/Source/WebCore/page/GeolocationPositionCache.h b/Source/WebCore/page/GeolocationPositionCache.h
deleted file mode 100644 (file)
index 5903ae4..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GeolocationPositionCache_h
-#define GeolocationPositionCache_h
-
-#include "Geoposition.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 {
-
-// 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:
-    static GeolocationPositionCache* instance();
-
-    void addUser();
-    void removeUser();
-
-    void setDatabasePath(const String&);
-    void setCachedPosition(Geoposition*);
-    Geoposition* cachedPosition();
-
-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();
-
-    RefPtr<Geoposition> m_cachedPosition;
-    Mutex m_cachedPositionMutex;
-    ThreadIdentifier m_threadId;
-    MessageQueue<ScriptExecutionContext::Task> m_queue;
-    String m_databaseFile;
-    Mutex m_databaseFileMutex;
-};
-
-} // namespace WebCore
-
-#endif // GeolocationPositionCache_h