Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2176)

Unified Diff: Source/modules/geolocation/Geolocation.cpp

Issue 393793003: Separate GeoNotifier class from Geolocation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/geolocation/Geolocation.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/geolocation/Geolocation.cpp
diff --git a/Source/modules/geolocation/Geolocation.cpp b/Source/modules/geolocation/Geolocation.cpp
index ee8c7742abe28fb86257e94d29b6fe2cb22d90e5..a386ae6f1b0ccffb76767f09f5d44caf530c5f1d 100644
--- a/Source/modules/geolocation/Geolocation.cpp
+++ b/Source/modules/geolocation/Geolocation.cpp
@@ -79,100 +79,6 @@ static PositionError* createPositionError(GeolocationError* error)
return PositionError::create(code, error->message());
}
-Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PositionOptions* options)
- : m_geolocation(geolocation)
- , m_successCallback(successCallback)
- , m_errorCallback(errorCallback)
- , m_options(options)
- , m_timer(this, &Geolocation::GeoNotifier::timerFired)
- , m_useCachedPosition(false)
-{
- ASSERT(m_geolocation);
- ASSERT(m_successCallback);
- // If no options were supplied from JS, we should have created a default set
- // of options in JSGeolocationCustom.cpp.
- ASSERT(m_options);
-}
-
-void Geolocation::GeoNotifier::trace(Visitor* visitor)
-{
- visitor->trace(m_geolocation);
- visitor->trace(m_options);
- visitor->trace(m_fatalError);
-}
-
-void Geolocation::GeoNotifier::setFatalError(PositionError* error)
-{
- // If a fatal error has already been set, stick with it. This makes sure that
- // when permission is denied, this is the error reported, as required by the
- // spec.
- if (m_fatalError)
- return;
-
- m_fatalError = error;
- // An existing timer may not have a zero timeout.
- m_timer.stop();
- m_timer.startOneShot(0, FROM_HERE);
-}
-
-void Geolocation::GeoNotifier::setUseCachedPosition()
-{
- m_useCachedPosition = true;
- m_timer.startOneShot(0, FROM_HERE);
-}
-
-void Geolocation::GeoNotifier::runSuccessCallback(Geoposition* position)
-{
- // If we are here and the Geolocation permission is not approved, something has
- // gone horribly wrong.
- if (!m_geolocation->isAllowed())
- CRASH();
-
- m_successCallback->handleEvent(position);
-}
-
-void Geolocation::GeoNotifier::runErrorCallback(PositionError* error)
-{
- if (m_errorCallback)
- m_errorCallback->handleEvent(error);
-}
-
-void Geolocation::GeoNotifier::startTimer()
-{
- m_timer.startOneShot(m_options->timeout() / 1000.0, FROM_HERE);
-}
-
-void Geolocation::GeoNotifier::stopTimer()
-{
- m_timer.stop();
-}
-
-void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*)
-{
- m_timer.stop();
-
- // Test for fatal error first. This is required for the case where the LocalFrame is
- // disconnected and requests are cancelled.
- if (m_fatalError) {
- runErrorCallback(m_fatalError.get());
- // This will cause this notifier to be deleted.
- m_geolocation->fatalErrorOccurred(this);
- return;
- }
-
- if (m_useCachedPosition) {
- // Clear the cached position flag in case this is a watch request, which
- // will continue to run.
- m_useCachedPosition = false;
- m_geolocation->requestUsesCachedPosition(this);
- return;
- }
-
- if (m_errorCallback)
- m_errorCallback->handleEvent(PositionError::create(PositionError::TIMEOUT, "Timeout expired"));
- m_geolocation->requestTimedOut(this);
-}
-
void Geolocation::Watchers::trace(Visitor* visitor)
{
visitor->trace(m_idToNotifierMap);
@@ -188,7 +94,7 @@ bool Geolocation::Watchers::add(int id, GeoNotifier* notifier)
return true;
}
-Geolocation::GeoNotifier* Geolocation::Watchers::find(int id)
+GeoNotifier* Geolocation::Watchers::find(int id)
{
ASSERT(id > 0);
IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id);
@@ -346,7 +252,7 @@ void Geolocation::startRequest(GeoNotifier *notifier)
notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, failedToStartServiceErrorMessage));
}
-void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier)
+void Geolocation::fatalErrorOccurred(GeoNotifier* notifier)
{
// This request has failed fatally. Remove it from our lists.
m_oneShots.remove(notifier);
« no previous file with comments | « Source/modules/geolocation/Geolocation.h ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698