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

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

Issue 641963003: Make the geolocation code use C++11 for-ranges (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | 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 6423370b9a03ef2161253e78ec273444f9bbce08..2cb8a1bd0e5e4f4ffeb6abf25fb133386b6f0b06 100644
--- a/Source/modules/geolocation/Geolocation.cpp
+++ b/Source/modules/geolocation/Geolocation.cpp
@@ -241,9 +241,7 @@ void Geolocation::makeCachedPositionCallbacks()
// All modifications to m_requestsAwaitingCachedPosition are done
// asynchronously, so we don't need to worry about it being modified from
// the callbacks.
- GeoNotifierSet::const_iterator end = m_requestsAwaitingCachedPosition.end();
- for (GeoNotifierSet::const_iterator iter = m_requestsAwaitingCachedPosition.begin(); iter != end; ++iter) {
- GeoNotifier* notifier = iter->get();
+ for (GeoNotifier* notifier : m_requestsAwaitingCachedPosition) {
Mike West 2014/10/16 19:38:15 As you're replacing a const_iteratore, please s/Ge
kenneth.christiansen 2014/10/16 22:33:05 That would be a bigger change :-) I am fine to do
notifier->runSuccessCallback(lastPosition());
// If this is a one-shot request, stop it. Otherwise, if the watch still
@@ -328,23 +326,20 @@ void Geolocation::setIsAllowed(bool allowed)
void Geolocation::sendError(GeoNotifierVector& notifiers, PositionError* error)
{
- GeoNotifierVector::const_iterator end = notifiers.end();
- for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it)
- (*it)->runErrorCallback(error);
+ for (GeoNotifier* notifier : notifiers)
+ notifier->runErrorCallback(error);
}
void Geolocation::sendPosition(GeoNotifierVector& notifiers, Geoposition* position)
{
- GeoNotifierVector::const_iterator end = notifiers.end();
- for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it)
- (*it)->runSuccessCallback(position);
+ for (GeoNotifier* notifier : notifiers)
+ notifier->runSuccessCallback(position);
}
void Geolocation::stopTimer(GeoNotifierVector& notifiers)
{
- GeoNotifierVector::const_iterator end = notifiers.end();
- for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it)
- (*it)->stopTimer();
+ for (GeoNotifier* notifier : notifiers)
+ notifier->stopTimer();
}
void Geolocation::stopTimersForOneShots()
@@ -371,9 +366,8 @@ void Geolocation::stopTimers()
void Geolocation::cancelRequests(GeoNotifierVector& notifiers)
{
- GeoNotifierVector::const_iterator end = notifiers.end();
- for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it)
- (*it)->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, framelessDocumentErrorMessage));
+ for (GeoNotifier* notifier : notifiers)
+ notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, framelessDocumentErrorMessage));
}
void Geolocation::cancelAllRequests()
@@ -388,9 +382,7 @@ void Geolocation::cancelAllRequests()
void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifiers, GeoNotifierVector* cached)
{
GeoNotifierVector nonCached;
- GeoNotifierVector::iterator end = notifiers.end();
- for (GeoNotifierVector::const_iterator it = notifiers.begin(); it != end; ++it) {
- GeoNotifier* notifier = it->get();
+ for (GeoNotifier* notifier : notifiers) {
if (notifier->useCachedPosition()) {
if (cached)
cached->append(notifier);
@@ -402,11 +394,8 @@ void Geolocation::extractNotifiersWithCachedPosition(GeoNotifierVector& notifier
void Geolocation::copyToSet(const GeoNotifierVector& src, GeoNotifierSet& dest)
{
- GeoNotifierVector::const_iterator end = src.end();
- for (GeoNotifierVector::const_iterator it = src.begin(); it != end; ++it) {
- GeoNotifier* notifier = it->get();
+ for (GeoNotifier* notifier : src)
dest.add(notifier);
- }
}
void Geolocation::handleError(PositionError* error)
@@ -525,11 +514,8 @@ void Geolocation::stopUpdating()
void Geolocation::handlePendingPermissionNotifiers()
{
// 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
- GeoNotifierSet::const_iterator end = m_pendingForPermissionNotifiers.end();
- for (GeoNotifierSet::const_iterator iter = m_pendingForPermissionNotifiers.begin(); iter != end; ++iter) {
- GeoNotifier* notifier = iter->get();
-
+ // is already set to Yes/No and no new listeners will be added to the pending list.
+ for (GeoNotifier* notifier : m_pendingForPermissionNotifiers) {
if (isAllowed()) {
// start all pending notification requests as permission granted.
// The notifier is always ref'ed by m_oneShots or m_watchers.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698