Make the geolocation code use C++11 for-ranges

Review URL: https://codereview.chromium.org/641963003

git-svn-id: svn://svn.chromium.org/blink/trunk@183865 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fe2f1c6f
...@@ -241,9 +241,7 @@ void Geolocation::makeCachedPositionCallbacks() ...@@ -241,9 +241,7 @@ void Geolocation::makeCachedPositionCallbacks()
// All modifications to m_requestsAwaitingCachedPosition are done // All modifications to m_requestsAwaitingCachedPosition are done
// asynchronously, so we don't need to worry about it being modified from // asynchronously, so we don't need to worry about it being modified from
// the callbacks. // the callbacks.
GeoNotifierSet::const_iterator end = m_requestsAwaitingCachedPosition.end(); for (GeoNotifier* notifier : m_requestsAwaitingCachedPosition) {
for (GeoNotifierSet::const_iterator iter = m_requestsAwaitingCachedPosition.begin(); iter != end; ++iter) {
GeoNotifier* notifier = iter->get();
notifier->runSuccessCallback(lastPosition()); notifier->runSuccessCallback(lastPosition());
// If this is a one-shot request, stop it. Otherwise, if the watch still // If this is a one-shot request, stop it. Otherwise, if the watch still
...@@ -328,23 +326,20 @@ void Geolocation::setIsAllowed(bool allowed) ...@@ -328,23 +326,20 @@ void Geolocation::setIsAllowed(bool allowed)
void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error) void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error)
{ {
GeoNotifierVector::const_iterator end = notifiers.end(); for (GeoNotifier* notifier : notifiers)
for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) notifier->runErrorCallback(error);
(*it)->runErrorCallback(error);
} }
void Geolocation::sendPosition(GeoNotifierVector& notifiers, Geoposition* position) void Geolocation::sendPosition(GeoNotifierVector& notifiers, Geoposition* position)
{ {
GeoNotifierVector::const_iterator end = notifiers.end(); for (GeoNotifier* notifier : notifiers)
for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) notifier->runSuccessCallback(position);
(*it)->runSuccessCallback(position);
} }
void Geolocation::stopTimer(GeoNotifierVector& notifiers) void Geolocation::stopTimer(GeoNotifierVector& notifiers)
{ {
GeoNotifierVector::const_iterator end = notifiers.end(); for (GeoNotifier* notifier : notifiers)
for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) notifier->stopTimer();
(*it)->stopTimer();
} }
void Geolocation::stopTimersForOneShots() void Geolocation::stopTimersForOneShots()
...@@ -371,9 +366,8 @@ void Geolocation::stopTimers() ...@@ -371,9 +366,8 @@ void Geolocation::stopTimers()
void Geolocation::cancelRequests(GeoNotifierVector& notifiers) void Geolocation::cancelRequests(GeoNotifierVector& notifiers)
{ {
GeoNotifierVector::const_iterator end = notifiers.end(); for (GeoNotifier* notifier : notifiers)
for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, framelessDocumentErrorMessage));
(*it)->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, framelessDocumentErrorMessage));
} }
void Geolocation::cancelAllRequests() void Geolocation::cancelAllRequests()
...@@ -388,9 +382,7 @@ void Geolocation::cancelAllRequests() ...@@ -388,9 +382,7 @@ void Geolocation::cancelAllRequests()
void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, GeoNotifierVector* cached) void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, GeoNotifierVector* cached)
{ {
GeoNotifierVector nonCached; GeoNotifierVector nonCached;
GeoNotifierVector::iterator end = notifiers.end(); for (GeoNotifier* notifier : notifiers) {
for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) {
GeoNotifier* notifier = it->get();
if (notifier->useCachedPosition()) { if (notifier->useCachedPosition()) {
if (cached) if (cached)
cached->append(notifier); cached->append(notifier);
...@@ -402,11 +394,8 @@ void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifier ...@@ -402,11 +394,8 @@ void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifier
void Geolocation::copyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest) void Geolocation::copyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest)
{ {
GeoNotifierVector::const_iterator end = src.end(); for (GeoNotifier* notifier : src)
for (GeoNotifierVector::const_iterator it = src.begin(); it != end; ++it) {
GeoNotifier* notifier = it->get();
dest.add(notifier); dest.add(notifier);
}
} }
void Geolocation::handleError(PositionError* error) void Geolocation::handleError(PositionError* error)
...@@ -525,11 +514,8 @@ void Geolocation::stopUpdating() ...@@ -525,11 +514,8 @@ void Geolocation::stopUpdating()
void Geolocation::handlePendingPermissionNotifiers() void Geolocation::handlePendingPermissionNotifiers()
{ {
// While we iterate through the list, we need not worry about list being modified as the permission // While we iterate through the list, we need not worry about list being modified as the permission
// is already set to Yes/No and no new listeners will be added to the pending list // is already set to Yes/No and no new listeners will be added to the pending list.
GeoNotifierSet::const_iterator end = m_pendingForPermissionNotifiers.end(); for (GeoNotifier* notifier : m_pendingForPermissionNotifiers) {
for (GeoNotifierSet::const_iterator iter = m_pendingForPermissionNotifiers.begin(); iter != end; ++iter) {
GeoNotifier* notifier = iter->get();
if (isAllowed()) { if (isAllowed()) {
// start all pending notification requests as permission granted. // start all pending notification requests as permission granted.
// The notifier is always ref'ed by m_oneShots or m_watchers. // The notifier is always ref'ed by m_oneShots or m_watchers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment