static const char failedToStartServiceErrorMessage[] = "Failed to start Geolocation service";
static const char framelessDocumentErrorMessage[] = "Geolocation cannot be used in frameless documents";
-static PassRefPtr<Geoposition> createGeoposition(GeolocationPosition* position)
+static PassRefPtrWillBeRawPtr<Geoposition> createGeoposition(GeolocationPosition* position)
{
if (!position)
return 0;
- RefPtr<Coordinates> coordinates = Coordinates::create(position->latitude(), position->longitude(), position->canProvideAltitude(), position->altitude(),
- position->accuracy(), position->canProvideAltitudeAccuracy(), position->altitudeAccuracy(),
- position->canProvideHeading(), position->heading(), position->canProvideSpeed(), position->speed());
+ RefPtrWillBeRawPtr<Coordinates> coordinates = Coordinates::create(
+ position->latitude(),
+ position->longitude(),
+ position->canProvideAltitude(),
+ position->altitude(),
+ position->accuracy(),
+ position->canProvideAltitudeAccuracy(),
+ position->altitudeAccuracy(),
+ position->canProvideHeading(),
+ position->heading(),
+ position->canProvideSpeed(),
+ position->speed());
return Geoposition::create(coordinates.release(), convertSecondsToDOMTimeStamp(position->timestamp()));
}
-static PassRefPtr<PositionError> createPositionError(GeolocationError* error)
+static PassRefPtrWillBeRawPtr<PositionError> createPositionError(GeolocationError* error)
{
PositionError::ErrorCode code = PositionError::POSITION_UNAVAILABLE;
switch (error->code()) {
return PositionError::create(code, error->message());
}
-Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
+DEFINE_GC_INFO(Geolocation::GeoNotifier);
+
+Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<PositionOptions> options)
: m_geolocation(geolocation)
, m_successCallback(successCallback)
, m_errorCallback(errorCallback)
ASSERT(m_options);
}
-void Geolocation::GeoNotifier::setFatalError(PassRefPtr<PositionError> error)
+void Geolocation::GeoNotifier::trace(Visitor* visitor)
+{
+ visitor->trace(m_geolocation);
+ visitor->trace(m_options);
+ visitor->trace(m_fatalError);
+}
+
+void Geolocation::GeoNotifier::setFatalError(PassRefPtrWillBeRawPtr<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
// Protect this GeoNotifier object, since it
// could be deleted by a call to clearWatch in a callback.
- RefPtr<GeoNotifier> protect(this);
+ RefPtrWillBeRawPtr<GeoNotifier> protect(this);
// Test for fatal error first. This is required for the case where the Frame is
// disconnected and requests are cancelled.
}
if (m_errorCallback) {
- RefPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT, "Timeout expired");
+ RefPtrWillBeRawPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT, "Timeout expired");
m_errorCallback->handleEvent(error.get());
}
m_geolocation->requestTimedOut(this);
}
-bool Geolocation::Watchers::add(int id, PassRefPtr<GeoNotifier> prpNotifier)
+void Geolocation::Watchers::trace(Visitor* visitor)
+{
+ visitor->trace(m_idToNotifierMap);
+ visitor->trace(m_notifierToIdMap);
+}
+
+bool Geolocation::Watchers::add(int id, PassRefPtrWillBeRawPtr<GeoNotifier> prpNotifier)
{
ASSERT(id > 0);
- RefPtr<GeoNotifier> notifier = prpNotifier;
+ RefPtrWillBeRawPtr<GeoNotifier> notifier = prpNotifier;
if (!m_idToNotifierMap.add(id, notifier.get()).isNewEntry)
return false;
copyValuesToVector(m_idToNotifierMap, copy);
}
-PassRefPtr<Geolocation> Geolocation::create(ExecutionContext* context)
+DEFINE_GC_INFO(Geolocation);
+
+PassRefPtrWillBeRawPtr<Geolocation> Geolocation::create(ExecutionContext* context)
{
- RefPtr<Geolocation> geolocation = adoptRef(new Geolocation(context));
+ RefPtrWillBeRawPtr<Geolocation> geolocation = adoptRefWillBeNoop(new Geolocation(context));
geolocation->suspendIfNeeded();
return geolocation.release();
}
ASSERT(m_allowGeolocation != InProgress);
}
+void Geolocation::trace(Visitor* visitor)
+{
+ visitor->trace(m_oneShots);
+ visitor->trace(m_watchers);
+ visitor->trace(m_pendingForPermissionNotifiers);
+ visitor->trace(m_lastPosition);
+ visitor->trace(m_requestsAwaitingCachedPosition);
+}
+
Document* Geolocation::document() const
{
return toDocument(executionContext());
return m_lastPosition.get();
}
-void Geolocation::getCurrentPosition(PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
+void Geolocation::getCurrentPosition(PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<PositionOptions> options)
{
if (!frame())
return;
- RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
+ RefPtrWillBeRawPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
startRequest(notifier.get());
m_oneShots.add(notifier);
}
-int Geolocation::watchPosition(PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options)
+int Geolocation::watchPosition(PassOwnPtr<PositionCallback> successCallback, PassOwnPtr<PositionErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<PositionOptions> options)
{
if (!frame())
return 0;
- RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
+ RefPtrWillBeRawPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options);
startRequest(notifier.get());
int watchID;
void Geolocation::setIsAllowed(bool allowed)
{
// Protect the Geolocation object from garbage collection during a callback.
- RefPtr<Geolocation> protect(this);
+ RefPtrWillBeRawPtr<Geolocation> protect(this);
// This may be due to either a new position from the service, or a cached
// position.
}
if (!isAllowed()) {
- RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage);
+ RefPtrWillBeRawPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage);
error->setIsFatal(true);
handleError(error.get());
m_requestsAwaitingCachedPosition.clear();
void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error)
{
- GeoNotifierVector::const_iterator end = notifiers.end();
- for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) {
- RefPtr<GeoNotifier> notifier = *it;
-
- notifier->runErrorCallback(error);
- }
+ GeoNotifierVector::const_iterator end = notifiers.end();
+ for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it)
+ (*it)->runErrorCallback(error);
}
void Geolocation::sendPosition(GeoNotifierVector& notifiers, Geoposition* position)
void Geolocation::setError(GeolocationError* error)
{
- RefPtr<PositionError> positionError = createPositionError(error);
+ RefPtrWillBeRawPtr<PositionError> positionError = createPositionError(error);
handleError(positionError.get());
}