2009-11-05 Steve Block <steveblock@google.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Nov 2009 02:46:05 +0000 (02:46 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Nov 2009 02:46:05 +0000 (02:46 +0000)
        Reviewed by Eric Seidel.

        If the Geolocation service fails to start, invoke the error callback asynchronously.
        https://bugs.webkit.org/show_bug.cgi?id=28276

        All Geolocation callbacks must be invoked asynchronously.
        See http://www.w3.org/TR/geolocation-API/#geolocation_interface

        No new tests possible with current LayoutTestController.

        * page/Geolocation.cpp:
        (WebCore::Geolocation::getCurrentPosition): Modified. Asserts that startRequest returned a notifier.
        (WebCore::Geolocation::watchPosition): Modified. Asserts that startRequest returned a notifier.
        (WebCore::Geolocation::startRequest): Modified. If the Geolocation service fails to start, set a fatal error on the notifier.

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

WebCore/ChangeLog
WebCore/page/Geolocation.cpp

index 5fcc5c0fa6743f5aad835af38232837dc10f4c84..d411a239651450d8a5e2ab5bd040eb728e0cdf85 100644 (file)
@@ -1,3 +1,20 @@
+2009-11-05  Steve Block  <steveblock@google.com>
+
+        Reviewed by Eric Seidel.
+
+        If the Geolocation service fails to start, invoke the error callback asynchronously.
+        https://bugs.webkit.org/show_bug.cgi?id=28276
+
+        All Geolocation callbacks must be invoked asynchronously.
+        See http://www.w3.org/TR/geolocation-API/#geolocation_interface
+
+        No new tests possible with current LayoutTestController.
+
+        * page/Geolocation.cpp:
+        (WebCore::Geolocation::getCurrentPosition): Modified. Asserts that startRequest returned a notifier.
+        (WebCore::Geolocation::watchPosition): Modified. Asserts that startRequest returned a notifier.
+        (WebCore::Geolocation::startRequest): Modified. If the Geolocation service fails to start, set a fatal error on the notifier.
+
 2009-11-05  Chris Jerdonek  <chris.jerdonek@gmail.com>
 
         Reviewed by Eric Seidel.
index de4a9a1ec3b78c6b55f2fd88fc1913327f1aff1a..9a8a59c942f53f2def8e0fb160d80ade5f7ae755 100644 (file)
@@ -151,8 +151,7 @@ void Geolocation::disconnectFrame()
 void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
 {
     RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options);
-    if (!notifier)
-        return;
+    ASSERT(notifier);
 
     m_oneShots.add(notifier);
 }
@@ -160,8 +159,7 @@ void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallbac
 int Geolocation::watchPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
 {
     RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options);
-    if (!notifier)
-        return 0;
+    ASSERT(notifier);
 
     static int nextAvailableWatchId = 1;
     // In case of overflow, make sure the ID remains positive, but reuse the ID values.
@@ -182,13 +180,8 @@ PassRefPtr<Geolocation::GeoNotifier> Geolocation::startRequest(PassRefPtr<Positi
     else {
         if (notifier->hasZeroTimeout() || m_service->startUpdating(notifier->m_options.get()))
             notifier->startTimerIfNeeded();
-        else {
-            if (notifier->m_errorCallback) {
-                RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, "Unable to Start");
-                notifier->m_errorCallback->handleEvent(error.get());
-            }
-            return 0;
-        }
+        else
+            notifier->setFatalError(PositionError::create(PositionError::UNKNOWN_ERROR, "Failed to start Geolocation service"));
     }
 
     return notifier.release();