Title: [120804] trunk/Source/WebCore
Revision
120804
Author
[email protected]
Date
2012-06-19 23:03:07 -0700 (Tue, 19 Jun 2012)

Log Message

Refactoring: Geolocation::startRequest() should not create the GeoNotifiers
https://bugs.webkit.org/show_bug.cgi?id=89533

Patch by Benjamin Poulain <[email protected]> on 2012-06-19
Reviewed by David Kilzer.

It was odd to create the GeoNotifiers in Geolocation::startRequest() and having
assertions from the call site.

This patch move GeoNotifiers initialization to the exposed methods and pass them to
startRequest() as needed.
This will also help when adding support for dynamic permission reset and suspend/resume.

* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::getCurrentPosition):
(WebCore::Geolocation::watchPosition):
(WebCore::Geolocation::startRequest):
* Modules/geolocation/Geolocation.h:
(Geolocation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (120803 => 120804)


--- trunk/Source/WebCore/ChangeLog	2012-06-20 05:51:07 UTC (rev 120803)
+++ trunk/Source/WebCore/ChangeLog	2012-06-20 06:03:07 UTC (rev 120804)
@@ -1,3 +1,24 @@
+2012-06-19  Benjamin Poulain  <[email protected]>
+
+        Refactoring: Geolocation::startRequest() should not create the GeoNotifiers
+        https://bugs.webkit.org/show_bug.cgi?id=89533
+
+        Reviewed by David Kilzer.
+
+        It was odd to create the GeoNotifiers in Geolocation::startRequest() and having
+        assertions from the call site.
+
+        This patch move GeoNotifiers initialization to the exposed methods and pass them to
+        startRequest() as needed.
+        This will also help when adding support for dynamic permission reset and suspend/resume.
+
+        * Modules/geolocation/Geolocation.cpp:
+        (WebCore::Geolocation::getCurrentPosition):
+        (WebCore::Geolocation::watchPosition):
+        (WebCore::Geolocation::startRequest):
+        * Modules/geolocation/Geolocation.h:
+        (Geolocation):
+
 2012-06-19  Cris Neckar  <[email protected]>
 
         Fixes condition where inserting a CounterNode subtree which could result in incorrect placement.

Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp (120803 => 120804)


--- trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp	2012-06-20 05:51:07 UTC (rev 120803)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp	2012-06-20 06:03:07 UTC (rev 120804)
@@ -297,8 +297,8 @@
     if (!frame())
         return;
 
-    RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options);
-    ASSERT(notifier);
+    RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
+    startRequest(notifier.get());
 
     m_oneShots.add(notifier);
 }
@@ -308,8 +308,8 @@
     if (!frame())
         return 0;
 
-    RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options);
-    ASSERT(notifier);
+    RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
+    startRequest(notifier.get());
 
     static int nextAvailableWatchId = firstAvailableWatchId;
     // In case of overflow, make sure the ID remains positive, but reuse the ID values.
@@ -319,10 +319,8 @@
     return nextAvailableWatchId++;
 }
 
-PassRefPtr<Geolocation::GeoNotifier> Geolocation::startRequest(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
+void Geolocation::startRequest(GeoNotifier *notifier)
 {
-    RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
-
     // Check whether permissions have already been denied. Note that if this is the case,
     // the permission state can not change again in the lifetime of this page.
     if (isDenied())
@@ -335,12 +333,10 @@
         // if we don't yet have permission, request for permission before calling startUpdating()
         m_pendingForPermissionNotifiers.add(notifier);
         requestPermission();
-    } else if (startUpdating(notifier.get()))
+    } else if (startUpdating(notifier))
         notifier->startTimerIfNeeded();
     else
         notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage));
-
-    return notifier.release();
 }
 
 void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier)

Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.h (120803 => 120804)


--- trunk/Source/WebCore/Modules/geolocation/Geolocation.h	2012-06-20 05:51:07 UTC (rev 120803)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.h	2012-06-20 06:03:07 UTC (rev 120804)
@@ -152,7 +152,7 @@
 
     void handlePendingPermissionNotifiers();
 
-    PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
+    void startRequest(GeoNotifier*);
 
     void fatalErrorOccurred(GeoNotifier*);
     void requestTimedOut(GeoNotifier*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to