Use modern for-loops in WebCore/Modules - 2
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jun 2015 14:36:47 +0000 (14:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jun 2015 14:36:47 +0000 (14:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145541

Patch by Hunseop Jeong <hs85.jeong@samsung.com> on 2015-06-08
Reviewed by Darin Adler.

No new tests, no behavior changes.

* Modules/mediastream/RTCConfiguration.h:
(WebCore::RTCConfiguration::iceServers):
* Modules/mediastream/RTCDTMFSender.cpp:
(WebCore::RTCDTMFSender::scheduledEventTimerFired):
* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::scheduledEventTimerFired):
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::processIceServer):
(WebCore::RTCPeerConnection::~RTCPeerConnection):
(WebCore::RTCPeerConnection::getStreamById):
(WebCore::RTCPeerConnection::hasLocalStreamWithTrackId):
(WebCore::RTCPeerConnection::stop):
(WebCore::RTCPeerConnection::scheduledEventTimerFired):
* Modules/mediastream/RTCStatsReport.cpp:
(WebCore::RTCStatsReport::names):
* Modules/navigatorcontentutils/NavigatorContentUtils.cpp:
(WebCore::initProtocolHandlerWhitelist):
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::getVoices):
* Modules/webaudio/AudioBuffer.cpp:
(WebCore::AudioBuffer::memoryCost):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::createMediaStreamSource):
(WebCore::AudioContext::derefFinishedSourceNodes):
(WebCore::AudioContext::derefUnfinishedSourceNodes):
(WebCore::AudioContext::handleDeferredFinishDerefs):
(WebCore::AudioContext::handleDirtyAudioSummingJunctions):
(WebCore::AudioContext::handleDirtyAudioNodeOutputs):
(WebCore::AudioContext::updateAutomaticPullNodes):
(WebCore::AudioContext::processAutomaticPullNodes):
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::updateChannelsForInputs):
(WebCore::AudioNode::checkNumberOfChannelsForInput):
(WebCore::AudioNode::pullInputs):
(WebCore::AudioNode::inputsAreSilent):
(WebCore::AudioNode::silenceOutputs):
(WebCore::AudioNode::unsilenceOutputs):
(WebCore::AudioNode::enableOutputsIfNecessary):
(WebCore::AudioNode::disableOutputsIfNecessary):
(WebCore::AudioNode::finishDeref):
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::numberOfChannels):
(WebCore::AudioNodeInput::sumAllConnections):
* Modules/webaudio/AudioNodeOutput.cpp:
(WebCore::AudioNodeOutput::propagateChannelCount):
(WebCore::AudioNodeOutput::disable):
(WebCore::AudioNodeOutput::enable):
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::calculateFinalValues):
* Modules/webaudio/AudioParamTimeline.cpp:
(WebCore::AudioParamTimeline::insertEvent):
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::updateRenderingState):
* Modules/webaudio/MediaStreamAudioSource.cpp:
(WebCore::MediaStreamAudioSource::setAudioFormat):
(WebCore::MediaStreamAudioSource::consumeAudio):
* Modules/webaudio/WaveShaperProcessor.cpp:
(WebCore::WaveShaperProcessor::setOversample):
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::handlePausedQueue):
(WebCore::DatabaseThread::databaseThread):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::interruptAllDatabasesForContext):
(WebCore::DatabaseTracker::databaseNamesForOrigin):
(WebCore::DatabaseTracker::getOpenDatabases):
(WebCore::DatabaseTracker::usageForOrigin):
(WebCore::DatabaseTracker::deleteAllDatabases):
(WebCore::DatabaseTracker::deleteOrigin):
(WebCore::DatabaseTracker::deleteDatabaseFile):
(WebCore::DatabaseTracker::removeDeletedOpenedDatabases):
(WebCore::DatabaseTracker::setDatabasesPaused):
* Modules/webdatabase/SQLTransactionCoordinator.cpp:
(WebCore::SQLTransactionCoordinator::shutdown):
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
* Modules/websockets/WebSocketExtensionDispatcher.cpp:
(WebCore::WebSocketExtensionDispatcher::addProcessor):
(WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension):
(WebCore::WebSocketExtensionDispatcher::processHeaderValue):
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::clientHandshakeMessage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185316 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCConfiguration.h
Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp
Source/WebCore/Modules/mediastream/RTCDataChannel.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCStatsReport.cpp
Source/WebCore/Modules/navigatorcontentutils/NavigatorContentUtils.cpp
Source/WebCore/Modules/speech/SpeechSynthesis.cpp
Source/WebCore/Modules/webaudio/AudioBuffer.cpp
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioNode.cpp
Source/WebCore/Modules/webaudio/AudioNodeInput.cpp
Source/WebCore/Modules/webaudio/AudioNodeOutput.cpp
Source/WebCore/Modules/webaudio/AudioParam.cpp
Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp
Source/WebCore/Modules/webaudio/AudioSummingJunction.cpp
Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp
Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp
Source/WebCore/Modules/webdatabase/DatabaseThread.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/SQLTransactionCoordinator.cpp
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocketExtensionDispatcher.cpp
Source/WebCore/Modules/websockets/WebSocketHandshake.cpp

index b043fba..72a58d0 100644 (file)
@@ -1,3 +1,94 @@
+2015-06-08  Hunseop Jeong  <hs85.jeong@samsung.com>
+
+        Use modern for-loops in WebCore/Modules - 2
+        https://bugs.webkit.org/show_bug.cgi?id=145541
+
+        Reviewed by Darin Adler.
+
+        No new tests, no behavior changes.
+
+        * Modules/mediastream/RTCConfiguration.h:
+        (WebCore::RTCConfiguration::iceServers):
+        * Modules/mediastream/RTCDTMFSender.cpp:
+        (WebCore::RTCDTMFSender::scheduledEventTimerFired):
+        * Modules/mediastream/RTCDataChannel.cpp:
+        (WebCore::RTCDataChannel::scheduledEventTimerFired):
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::processIceServer):
+        (WebCore::RTCPeerConnection::~RTCPeerConnection):
+        (WebCore::RTCPeerConnection::getStreamById):
+        (WebCore::RTCPeerConnection::hasLocalStreamWithTrackId):
+        (WebCore::RTCPeerConnection::stop):
+        (WebCore::RTCPeerConnection::scheduledEventTimerFired):
+        * Modules/mediastream/RTCStatsReport.cpp:
+        (WebCore::RTCStatsReport::names):
+        * Modules/navigatorcontentutils/NavigatorContentUtils.cpp:
+        (WebCore::initProtocolHandlerWhitelist):
+        * Modules/speech/SpeechSynthesis.cpp:
+        (WebCore::SpeechSynthesis::getVoices):
+        * Modules/webaudio/AudioBuffer.cpp:
+        (WebCore::AudioBuffer::memoryCost):
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::createMediaStreamSource):
+        (WebCore::AudioContext::derefFinishedSourceNodes):
+        (WebCore::AudioContext::derefUnfinishedSourceNodes):
+        (WebCore::AudioContext::handleDeferredFinishDerefs):
+        (WebCore::AudioContext::handleDirtyAudioSummingJunctions):
+        (WebCore::AudioContext::handleDirtyAudioNodeOutputs):
+        (WebCore::AudioContext::updateAutomaticPullNodes):
+        (WebCore::AudioContext::processAutomaticPullNodes):
+        * Modules/webaudio/AudioNode.cpp:
+        (WebCore::AudioNode::updateChannelsForInputs):
+        (WebCore::AudioNode::checkNumberOfChannelsForInput):
+        (WebCore::AudioNode::pullInputs):
+        (WebCore::AudioNode::inputsAreSilent):
+        (WebCore::AudioNode::silenceOutputs):
+        (WebCore::AudioNode::unsilenceOutputs):
+        (WebCore::AudioNode::enableOutputsIfNecessary):
+        (WebCore::AudioNode::disableOutputsIfNecessary):
+        (WebCore::AudioNode::finishDeref):
+        * Modules/webaudio/AudioNodeInput.cpp:
+        (WebCore::AudioNodeInput::numberOfChannels):
+        (WebCore::AudioNodeInput::sumAllConnections):
+        * Modules/webaudio/AudioNodeOutput.cpp:
+        (WebCore::AudioNodeOutput::propagateChannelCount):
+        (WebCore::AudioNodeOutput::disable):
+        (WebCore::AudioNodeOutput::enable):
+        * Modules/webaudio/AudioParam.cpp:
+        (WebCore::AudioParam::calculateFinalValues):
+        * Modules/webaudio/AudioParamTimeline.cpp:
+        (WebCore::AudioParamTimeline::insertEvent):
+        * Modules/webaudio/AudioSummingJunction.cpp:
+        (WebCore::AudioSummingJunction::updateRenderingState):
+        * Modules/webaudio/MediaStreamAudioSource.cpp:
+        (WebCore::MediaStreamAudioSource::setAudioFormat):
+        (WebCore::MediaStreamAudioSource::consumeAudio):
+        * Modules/webaudio/WaveShaperProcessor.cpp:
+        (WebCore::WaveShaperProcessor::setOversample):
+        * Modules/webdatabase/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::handlePausedQueue):
+        (WebCore::DatabaseThread::databaseThread):
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::interruptAllDatabasesForContext):
+        (WebCore::DatabaseTracker::databaseNamesForOrigin):
+        (WebCore::DatabaseTracker::getOpenDatabases):
+        (WebCore::DatabaseTracker::usageForOrigin):
+        (WebCore::DatabaseTracker::deleteAllDatabases):
+        (WebCore::DatabaseTracker::deleteOrigin):
+        (WebCore::DatabaseTracker::deleteDatabaseFile):
+        (WebCore::DatabaseTracker::removeDeletedOpenedDatabases):
+        (WebCore::DatabaseTracker::setDatabasesPaused):
+        * Modules/webdatabase/SQLTransactionCoordinator.cpp:
+        (WebCore::SQLTransactionCoordinator::shutdown):
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        * Modules/websockets/WebSocketExtensionDispatcher.cpp:
+        (WebCore::WebSocketExtensionDispatcher::addProcessor):
+        (WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension):
+        (WebCore::WebSocketExtensionDispatcher::processHeaderValue):
+        * Modules/websockets/WebSocketHandshake.cpp:
+        (WebCore::WebSocketHandshake::clientHandshakeMessage):
+
 2015-06-07  Darin Adler  <darin@apple.com>
 
         REGRESSION (r181720): Unnecessary layout triggered any time animated GIF advances to a new frame
 2015-06-07  Darin Adler  <darin@apple.com>
 
         REGRESSION (r181720): Unnecessary layout triggered any time animated GIF advances to a new frame
         with callbacks is limiting a number of ways. The callback names are very ambiguous, the callbacks
         must either be on a separate object (more boilerplate), or the callback must be public for
         HysteresisActivity to call them, or friends get involved. Without the boilerplate of extra
         with callbacks is limiting a number of ways. The callback names are very ambiguous, the callbacks
         must either be on a separate object (more boilerplate), or the callback must be public for
         HysteresisActivity to call them, or friends get involved. Without the boilerplate of extra
-        delegate objects it's hard to scale use of these objects - a single object can't serve as a
+        delegate objects it's hard to scale use of these objects - a single object can't serve as a
         delegate for multiple HysteresisActivity members.
 
         Instead, make HysteresisActivity take a lambda to callback on state change. To simplify, changed
         delegate for multiple HysteresisActivity members.
 
         Instead, make HysteresisActivity take a lambda to callback on state change. To simplify, changed
index 4ffa96e..637d4d9 100644 (file)
@@ -67,10 +67,8 @@ public:
     Vector<RefPtr<RTCIceServer>> iceServers() const
     {
         Vector<RefPtr<RTCIceServer>> servers;
     Vector<RefPtr<RTCIceServer>> iceServers() const
     {
         Vector<RefPtr<RTCIceServer>> servers;
-        Vector<RefPtr<RTCIceServerPrivate>> privateServers = m_private->iceServers();
-
-        for (auto iter = privateServers.begin(); iter != privateServers.end(); ++iter)
-            servers.append(RTCIceServer::create(*iter));
+        for (auto& server : m_private->iceServers())
+            servers.append(RTCIceServer::create(server));
 
         return servers;
     }
 
         return servers;
     }
index 3cffb86..527b5d1 100644 (file)
@@ -161,9 +161,8 @@ void RTCDTMFSender::scheduledEventTimerFired()
     Vector<RefPtr<Event>> events;
     events.swap(m_scheduledEvents);
 
     Vector<RefPtr<Event>> events;
     events.swap(m_scheduledEvents);
 
-    Vector<RefPtr<Event>>::iterator it = events.begin();
-    for (; it != events.end(); ++it)
-        dispatchEvent((*it).release());
+    for (auto& event : events)
+        dispatchEvent(event.release());
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index 90d06c7..827191c 100644 (file)
@@ -320,11 +320,8 @@ void RTCDataChannel::scheduledEventTimerFired()
     Vector<RefPtr<Event>> events;
     events.swap(m_scheduledEvents);
 
     Vector<RefPtr<Event>> events;
     events.swap(m_scheduledEvents);
 
-    Vector<RefPtr<Event>>::iterator it = events.begin();
-    for (; it != events.end(); ++it)
-        dispatchEvent((*it).release());
-
-    events.clear();
+    for (auto& event : events)
+        dispatchEvent(event.release());
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index 1609816..b90404c 100644 (file)
@@ -95,8 +95,8 @@ static ExceptionCode processIceServer(const Dictionary& iceServer, RTCConfigurat
         return INVALID_ACCESS_ERR;
 
     if (urlString.find(',') != notFound && iceServer.get("urls", urlsList) && urlsList.size()) {
         return INVALID_ACCESS_ERR;
 
     if (urlString.find(',') != notFound && iceServer.get("urls", urlsList) && urlsList.size()) {
-        for (auto iter = urlsList.begin(); iter != urlsList.end(); ++iter) {
-            if (!validateIceServerURL(*iter))
+        for (auto& url : urlsList) {
+            if (!validateIceServerURL(url))
                 return INVALID_ACCESS_ERR;
         }
     } else {
                 return INVALID_ACCESS_ERR;
         }
     } else {
@@ -203,8 +203,8 @@ RTCPeerConnection::~RTCPeerConnection()
 {
     stop();
 
 {
     stop();
 
-    for (auto stream = m_localStreams.begin(), end = m_localStreams.end(); stream != end; ++stream)
-        (*stream)->removeObserver(this);
+    for (auto& localStream : m_localStreams)
+        localStream->removeObserver(this);
 }
 
 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, const Dictionary& offerOptions, ExceptionCode& ec)
 }
 
 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCPeerConnectionErrorCallback> errorCallback, const Dictionary& offerOptions, ExceptionCode& ec)
@@ -514,14 +514,14 @@ Vector<RefPtr<MediaStream>> RTCPeerConnection::getRemoteStreams() const
 
 MediaStream* RTCPeerConnection::getStreamById(const String& streamId)
 {
 
 MediaStream* RTCPeerConnection::getStreamById(const String& streamId)
 {
-    for (auto iter = m_localStreams.begin(); iter != m_localStreams.end(); ++iter) {
-        if ((*iter)->id() == streamId)
-            return iter->get();
+    for (auto& localStream : m_localStreams) {
+        if (localStream->id() == streamId)
+            return localStream.get();
     }
 
     }
 
-    for (auto iter = m_remoteStreams.begin(); iter != m_remoteStreams.end(); ++iter) {
-        if ((*iter)->id() == streamId)
-            return iter->get();
+    for (auto& remoteStream : m_remoteStreams) {
+        if (remoteStream->id() == streamId)
+            return remoteStream.get();
     }
 
     return nullptr;
     }
 
     return nullptr;
@@ -551,8 +551,8 @@ PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co
 
 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId)
 {
 
 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId)
 {
-    for (auto iter = m_localStreams.begin(); iter != m_localStreams.end(); ++iter) {
-        if ((*iter)->getTrackById(trackId))
+    for (auto& localStream : m_localStreams) {
+        if (localStream->getTrackById(trackId))
             return true;
     }
     return false;
             return true;
     }
     return false;
@@ -685,9 +685,8 @@ void RTCPeerConnection::stop()
     m_iceConnectionState = IceConnectionStateClosed;
     m_signalingState = SignalingStateClosed;
 
     m_iceConnectionState = IceConnectionStateClosed;
     m_signalingState = SignalingStateClosed;
 
-    Vector<RefPtr<RTCDataChannel>>::iterator i = m_dataChannels.begin();
-    for (; i != m_dataChannels.end(); ++i)
-        (*i)->stop();
+    for (auto& channel : m_dataChannels)
+        channel->stop();
 }
 
 const char* RTCPeerConnection::activeDOMObjectName() const
 }
 
 const char* RTCPeerConnection::activeDOMObjectName() const
@@ -743,9 +742,8 @@ void RTCPeerConnection::scheduledEventTimerFired()
     Vector<RefPtr<Event>> events;
     events.swap(m_scheduledEvents);
 
     Vector<RefPtr<Event>> events;
     events.swap(m_scheduledEvents);
 
-    Vector<RefPtr<Event>>::iterator it = events.begin();
-    for (; it != events.end(); ++it)
-        dispatchEvent((*it).release());
+    for (auto& event : events)
+        dispatchEvent(event.release());
 
     events.clear();
 }
 
     events.clear();
 }
index 989a76f..a035634 100644 (file)
@@ -48,9 +48,8 @@ RTCStatsReport::RTCStatsReport(const String& id, const String& type, double time
 Vector<String> RTCStatsReport::names() const
 {
     Vector<String> result;
 Vector<String> RTCStatsReport::names() const
 {
     Vector<String> result;
-    for (HashMap<String, String>::const_iterator it = m_stats.begin(); it != m_stats.end(); ++it) {
-        result.append(it->key);
-    }
+    for (auto& stat : m_stats.keys())
+        result.append(stat);
     return result;
 }
 
     return result;
 }
 
index cca7d9e..5686715 100644 (file)
@@ -44,29 +44,8 @@ static HashSet<String>* protocolWhitelist;
 static void initProtocolHandlerWhitelist()
 {
     protocolWhitelist = new HashSet<String>;
 static void initProtocolHandlerWhitelist()
 {
     protocolWhitelist = new HashSet<String>;
-    static const char* protocols[] = {
-        "bitcoin",
-        "geo",
-        "im",
-        "irc",
-        "ircs",
-        "magnet",
-        "mailto",
-        "mms",
-        "news",
-        "nntp",
-        "sip",
-        "sms",
-        "smsto",
-        "ssh",
-        "tel",
-        "urn",
-        "webcal",
-        "wtai",
-        "xmpp",
-    };
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(protocols); ++i)
-        protocolWhitelist->add(protocols[i]);
+    for (auto* protocol : { "bitcoin", "geo", "im", "irc", "ircs", "magnet", "mailto", "mms", "news", "nntp", "sip", "sms", "smsto", "ssh", "tel", "urn", "webcal", "wtai", "xmpp" })
+        protocolWhitelist->add(protocol);
 }
 
 static bool verifyCustomHandlerURL(const URL& baseURL, const String& url, ExceptionCode& ec)
 }
 
 static bool verifyCustomHandlerURL(const URL& baseURL, const String& url, ExceptionCode& ec)
index 7850340..97149f4 100644 (file)
@@ -74,10 +74,8 @@ const Vector<RefPtr<SpeechSynthesisVoice>>& SpeechSynthesis::getVoices()
         m_platformSpeechSynthesizer = std::make_unique<PlatformSpeechSynthesizer>(this);
 
     // If the voiceList is empty, that's the cue to get the voices from the platform again.
         m_platformSpeechSynthesizer = std::make_unique<PlatformSpeechSynthesizer>(this);
 
     // If the voiceList is empty, that's the cue to get the voices from the platform again.
-    const Vector<RefPtr<PlatformSpeechSynthesisVoice>>& platformVoices = m_platformSpeechSynthesizer->voiceList();
-    size_t voiceCount = platformVoices.size();
-    for (size_t k = 0; k < voiceCount; k++)
-        m_voiceList.append(SpeechSynthesisVoice::create(platformVoices[k]));
+    for (auto& voice : m_platformSpeechSynthesizer->voiceList())
+        m_voiceList.append(SpeechSynthesisVoice::create(voice));
 
     return m_voiceList;
 }
 
     return m_voiceList;
 }
index 31da94c..8cb8a71 100644 (file)
@@ -125,8 +125,8 @@ void AudioBuffer::zero()
 size_t AudioBuffer::memoryCost() const
 {
     size_t cost = 0;
 size_t AudioBuffer::memoryCost() const
 {
     size_t cost = 0;
-    for (unsigned i = 0; i < m_channels.size() ; ++i)
-        cost += m_channels[i]->byteLength();
+    for (auto& channel : m_channels)
+        cost += channel->byteLength();
     return cost;
 }
 
     return cost;
 }
 
index a29316a..e3ec918 100644 (file)
@@ -460,12 +460,11 @@ PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med
 
     AudioSourceProvider* provider = 0;
 
 
     AudioSourceProvider* provider = 0;
 
-    Vector<RefPtr<MediaStreamTrack>> audioTracks = mediaStream->getAudioTracks();
     RefPtr<MediaStreamTrack> audioTrack;
 
     // FIXME: get a provider for non-local MediaStreams (like from a remote peer).
     RefPtr<MediaStreamTrack> audioTrack;
 
     // FIXME: get a provider for non-local MediaStreams (like from a remote peer).
-    for (size_t i = 0; i < audioTracks.size(); ++i) {
-        audioTrack = audioTracks[i];
+    for (auto& track : mediaStream->getAudioTracks()) {
+        audioTrack = track;
         if (audioTrack->source()->isAudioStreamSource()) {
             auto source = static_cast<MediaStreamAudioSource*>(audioTrack->source());
             ASSERT(!source->deviceId().isEmpty());
         if (audioTrack->source()->isAudioStreamSource()) {
             auto source = static_cast<MediaStreamAudioSource*>(audioTrack->source());
             ASSERT(!source->deviceId().isEmpty());
@@ -664,8 +663,8 @@ void AudioContext::derefFinishedSourceNodes()
 {
     ASSERT(isGraphOwner());
     ASSERT(isAudioThread() || isAudioThreadFinished());
 {
     ASSERT(isGraphOwner());
     ASSERT(isAudioThread() || isAudioThreadFinished());
-    for (unsigned i = 0; i < m_finishedNodes.size(); i++)
-        derefNode(m_finishedNodes[i]);
+    for (auto& node : m_finishedNodes)
+        derefNode(node);
 
     m_finishedNodes.clear();
 }
 
     m_finishedNodes.clear();
 }
@@ -692,8 +691,8 @@ void AudioContext::derefNode(AudioNode* node)
 void AudioContext::derefUnfinishedSourceNodes()
 {
     ASSERT(isMainThread() && isAudioThreadFinished());
 void AudioContext::derefUnfinishedSourceNodes()
 {
     ASSERT(isMainThread() && isAudioThreadFinished());
-    for (unsigned i = 0; i < m_referencedNodes.size(); ++i)
-        m_referencedNodes[i]->deref(AudioNode::RefTypeConnection);
+    for (auto& node : m_referencedNodes)
+        node->deref(AudioNode::RefTypeConnection);
 
     m_referencedNodes.clear();
 }
 
     m_referencedNodes.clear();
 }
@@ -825,10 +824,8 @@ void AudioContext::handlePostRenderTasks()
 void AudioContext::handleDeferredFinishDerefs()
 {
     ASSERT(isAudioThread() && isGraphOwner());
 void AudioContext::handleDeferredFinishDerefs()
 {
     ASSERT(isAudioThread() && isGraphOwner());
-    for (unsigned i = 0; i < m_deferredFinishDerefList.size(); ++i) {
-        AudioNode* node = m_deferredFinishDerefList[i];
+    for (auto& node : m_deferredFinishDerefList)
         node->finishDeref(AudioNode::RefTypeConnection);
         node->finishDeref(AudioNode::RefTypeConnection);
-    }
     
     m_deferredFinishDerefList.clear();
 }
     
     m_deferredFinishDerefList.clear();
 }
@@ -922,8 +919,8 @@ void AudioContext::handleDirtyAudioSummingJunctions()
 {
     ASSERT(isGraphOwner());    
 
 {
     ASSERT(isGraphOwner());    
 
-    for (HashSet<AudioSummingJunction*>::iterator i = m_dirtySummingJunctions.begin(); i != m_dirtySummingJunctions.end(); ++i)
-        (*i)->updateRenderingState();
+    for (auto& junction : m_dirtySummingJunctions)
+        junction->updateRenderingState();
 
     m_dirtySummingJunctions.clear();
 }
 
     m_dirtySummingJunctions.clear();
 }
@@ -932,8 +929,8 @@ void AudioContext::handleDirtyAudioNodeOutputs()
 {
     ASSERT(isGraphOwner());    
 
 {
     ASSERT(isGraphOwner());    
 
-    for (HashSet<AudioNodeOutput*>::iterator i = m_dirtyAudioNodeOutputs.begin(); i != m_dirtyAudioNodeOutputs.end(); ++i)
-        (*i)->updateRenderingState();
+    for (auto& output : m_dirtyAudioNodeOutputs)
+        output->updateRenderingState();
 
     m_dirtyAudioNodeOutputs.clear();
 }
 
     m_dirtyAudioNodeOutputs.clear();
 }
@@ -962,11 +959,9 @@ void AudioContext::updateAutomaticPullNodes()
         // Copy from m_automaticPullNodes to m_renderingAutomaticPullNodes.
         m_renderingAutomaticPullNodes.resize(m_automaticPullNodes.size());
 
         // Copy from m_automaticPullNodes to m_renderingAutomaticPullNodes.
         m_renderingAutomaticPullNodes.resize(m_automaticPullNodes.size());
 
-        unsigned j = 0;
-        for (HashSet<AudioNode*>::iterator i = m_automaticPullNodes.begin(); i != m_automaticPullNodes.end(); ++i, ++j) {
-            AudioNode* output = *i;
-            m_renderingAutomaticPullNodes[j] = output;
-        }
+        unsigned i = 0;
+        for (auto& output : m_automaticPullNodes)
+            m_renderingAutomaticPullNodes[i++] = output;
 
         m_automaticPullNodesNeedUpdating = false;
     }
 
         m_automaticPullNodesNeedUpdating = false;
     }
@@ -976,8 +971,8 @@ void AudioContext::processAutomaticPullNodes(size_t framesToProcess)
 {
     ASSERT(isAudioThread());
 
 {
     ASSERT(isAudioThread());
 
-    for (unsigned i = 0; i < m_renderingAutomaticPullNodes.size(); ++i)
-        m_renderingAutomaticPullNodes[i]->processIfNecessary(framesToProcess);
+    for (auto& node : m_renderingAutomaticPullNodes)
+        node->processIfNecessary(framesToProcess);
 }
 
 ScriptExecutionContext* AudioContext::scriptExecutionContext() const
 }
 
 ScriptExecutionContext* AudioContext::scriptExecutionContext() const
index 3264b5b..f46b4be 100644 (file)
@@ -277,8 +277,8 @@ void AudioNode::setChannelInterpretation(const String& interpretation, Exception
 
 void AudioNode::updateChannelsForInputs()
 {
 
 void AudioNode::updateChannelsForInputs()
 {
-    for (unsigned i = 0; i < m_inputs.size(); ++i)
-        input(i)->changedOutputs();
+    for (auto& input : m_inputs)
+        input->changedOutputs();
 }
 
 EventTargetInterface AudioNode::eventTargetInterface() const
 }
 
 EventTargetInterface AudioNode::eventTargetInterface() const
@@ -325,7 +325,7 @@ void AudioNode::checkNumberOfChannelsForInput(AudioNodeInput* input)
 {
     ASSERT(context()->isAudioThread() && context()->isGraphOwner());
 
 {
     ASSERT(context()->isAudioThread() && context()->isGraphOwner());
 
-    for (const std::unique_ptr<AudioNodeInput>& savedInput : m_inputs) {
+    for (auto& savedInput : m_inputs) {
         if (input == savedInput.get()) {
             input->updateInternalBus();
             return;
         if (input == savedInput.get()) {
             input->updateInternalBus();
             return;
@@ -345,14 +345,14 @@ void AudioNode::pullInputs(size_t framesToProcess)
     ASSERT(context()->isAudioThread());
     
     // Process all of the AudioNodes connected to our inputs.
     ASSERT(context()->isAudioThread());
     
     // Process all of the AudioNodes connected to our inputs.
-    for (unsigned i = 0; i < m_inputs.size(); ++i)
-        input(i)->pull(0, framesToProcess);
+    for (auto& input : m_inputs)
+        input->pull(0, framesToProcess);
 }
 
 bool AudioNode::inputsAreSilent()
 {
 }
 
 bool AudioNode::inputsAreSilent()
 {
-    for (unsigned i = 0; i < m_inputs.size(); ++i) {
-        if (!input(i)->bus()->isSilent())
+    for (auto& input : m_inputs) {
+        if (!input->bus()->isSilent())
             return false;
     }
     return true;
             return false;
     }
     return true;
@@ -360,14 +360,14 @@ bool AudioNode::inputsAreSilent()
 
 void AudioNode::silenceOutputs()
 {
 
 void AudioNode::silenceOutputs()
 {
-    for (unsigned i = 0; i < m_outputs.size(); ++i)
-        output(i)->bus()->zero();
+    for (auto& output : m_outputs)
+        output->bus()->zero();
 }
 
 void AudioNode::unsilenceOutputs()
 {
 }
 
 void AudioNode::unsilenceOutputs()
 {
-    for (unsigned i = 0; i < m_outputs.size(); ++i)
-        output(i)->bus()->clearSilentFlag();
+    for (auto& output : m_outputs)
+        output->bus()->clearSilentFlag();
 }
 
 void AudioNode::enableOutputsIfNecessary()
 }
 
 void AudioNode::enableOutputsIfNecessary()
@@ -377,8 +377,8 @@ void AudioNode::enableOutputsIfNecessary()
         AudioContext::AutoLocker locker(*context());
 
         m_isDisabled = false;
         AudioContext::AutoLocker locker(*context());
 
         m_isDisabled = false;
-        for (unsigned i = 0; i < m_outputs.size(); ++i)
-            output(i)->enable();
+        for (auto& output : m_outputs)
+            output->enable();
     }
 }
 
     }
 }
 
@@ -402,8 +402,8 @@ void AudioNode::disableOutputsIfNecessary()
         // longer any active connections.
         if (nodeType() != NodeTypeConvolver && nodeType() != NodeTypeDelay) {
             m_isDisabled = true;
         // longer any active connections.
         if (nodeType() != NodeTypeConvolver && nodeType() != NodeTypeDelay) {
             m_isDisabled = true;
-            for (unsigned i = 0; i < m_outputs.size(); ++i)
-                output(i)->disable();
+            for (auto& output : m_outputs)
+                output->disable();
         }
     }
 }
         }
     }
 }
@@ -492,8 +492,8 @@ void AudioNode::finishDeref(RefType refType)
         if (!m_normalRefCount) {
             if (!m_isMarkedForDeletion) {
                 // All references are gone - we need to go away.
         if (!m_normalRefCount) {
             if (!m_isMarkedForDeletion) {
                 // All references are gone - we need to go away.
-                for (unsigned i = 0; i < m_outputs.size(); ++i)
-                    output(i)->disconnectAll(); // This will deref() nodes we're connected to.
+                for (auto& output : m_outputs)
+                    output->disconnectAll(); // This will deref() nodes we're connected to.
 
                 // Mark for deletion at end of each render quantum or when context shuts down.
                 context()->markForDeletion(this);
 
                 // Mark for deletion at end of each render quantum or when context shuts down.
                 context()->markForDeletion(this);
index c62333d..a605e33 100644 (file)
@@ -151,8 +151,7 @@ unsigned AudioNodeInput::numberOfChannels() const
     // Find the number of channels of the connection with the largest number of channels.
     unsigned maxChannels = 1; // one channel is the minimum allowed
 
     // Find the number of channels of the connection with the largest number of channels.
     unsigned maxChannels = 1; // one channel is the minimum allowed
 
-    for (HashSet<AudioNodeOutput*>::iterator i = m_outputs.begin(); i != m_outputs.end(); ++i) {
-        AudioNodeOutput* output = *i;
+    for (auto& output : m_outputs) {
         // Use output()->numberOfChannels() instead of output->bus()->numberOfChannels(),
         // because the calling of AudioNodeOutput::bus() is not safe here.
         maxChannels = std::max(maxChannels, output->numberOfChannels());
         // Use output()->numberOfChannels() instead of output->bus()->numberOfChannels(),
         // because the calling of AudioNodeOutput::bus() is not safe here.
         maxChannels = std::max(maxChannels, output->numberOfChannels());
@@ -198,8 +197,7 @@ void AudioNodeInput::sumAllConnections(AudioBus* summingBus, size_t framesToProc
 
     AudioBus::ChannelInterpretation interpretation = node()->internalChannelInterpretation();
 
 
     AudioBus::ChannelInterpretation interpretation = node()->internalChannelInterpretation();
 
-    for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) {
-        AudioNodeOutput* output = renderingOutput(i);
+    for (auto& output : m_renderingOutputs) {
         ASSERT(output);
 
         // Render audio from this output.
         ASSERT(output);
 
         // Render audio from this output.
index f9a4516..468d8d5 100644 (file)
@@ -98,8 +98,7 @@ void AudioNodeOutput::propagateChannelCount()
     
     if (isChannelCountKnown()) {
         // Announce to any nodes we're connected to that we changed our channel count for its input.
     
     if (isChannelCountKnown()) {
         // Announce to any nodes we're connected to that we changed our channel count for its input.
-        for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) {
-            AudioNodeInput* input = *i;
+        for (auto& input : m_inputs) {
             AudioNode* connectionNode = input->node();
             connectionNode->checkNumberOfChannelsForInput(input);
         }
             AudioNode* connectionNode = input->node();
             connectionNode->checkNumberOfChannelsForInput(input);
         }
@@ -230,10 +229,8 @@ void AudioNodeOutput::disable()
     ASSERT(context()->isGraphOwner());
 
     if (m_isEnabled) {
     ASSERT(context()->isGraphOwner());
 
     if (m_isEnabled) {
-        for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) {
-            AudioNodeInput* input = *i;
+        for (auto& input : m_inputs)
             input->disable(this);
             input->disable(this);
-        }
         m_isEnabled = false;
     }
 }
         m_isEnabled = false;
     }
 }
@@ -243,10 +240,8 @@ void AudioNodeOutput::enable()
     ASSERT(context()->isGraphOwner());
 
     if (!m_isEnabled) {
     ASSERT(context()->isGraphOwner());
 
     if (!m_isEnabled) {
-        for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) {
-            AudioNodeInput* input = *i;
+        for (auto& input : m_inputs)
             input->enable(this);
             input->enable(this);
-        }
         m_isEnabled = true;
     }
 }
         m_isEnabled = true;
     }
 }
index 3e4899f..b73e916 100644 (file)
@@ -139,8 +139,7 @@ void AudioParam::calculateFinalValues(float* values, unsigned numberOfValues, bo
     RefPtr<AudioBus> summingBus = AudioBus::create(1, numberOfValues, false);
     summingBus->setChannelMemory(0, values, numberOfValues);
 
     RefPtr<AudioBus> summingBus = AudioBus::create(1, numberOfValues, false);
     summingBus->setChannelMemory(0, values, numberOfValues);
 
-    for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) {
-        AudioNodeOutput* output = renderingOutput(i);
+    for (auto& output : m_renderingOutputs) {
         ASSERT(output);
 
         // Render audio from this output.
         ASSERT(output);
 
         // Render audio from this output.
index 1c7e4e5..e87be62 100644 (file)
@@ -84,15 +84,17 @@ void AudioParamTimeline::insertEvent(const ParamEvent& event)
     
     unsigned i = 0;
     float insertTime = event.time();
     
     unsigned i = 0;
     float insertTime = event.time();
-    for (i = 0; i < m_events.size(); ++i) {
+    for (auto& paramEvent : m_events) {
         // Overwrite same event type and time.
         // Overwrite same event type and time.
-        if (m_events[i].time() == insertTime && m_events[i].type() == event.type()) {
-            m_events[i] = event;
+        if (paramEvent.time() == insertTime && paramEvent.type() == event.type()) {
+            paramEvent = event;
             return;
         }
 
             return;
         }
 
-        if (m_events[i].time() > insertTime)
+        if (paramEvent.time() > insertTime)
             break;
             break;
+
+        ++i;
     }
 
     m_events.insert(i, event);
     }
 
     m_events.insert(i, event);
index ed417fa..c228eec 100644 (file)
@@ -62,10 +62,9 @@ void AudioSummingJunction::updateRenderingState()
     if (m_renderingStateNeedUpdating && canUpdateState()) {
         // Copy from m_outputs to m_renderingOutputs.
         m_renderingOutputs.resize(m_outputs.size());
     if (m_renderingStateNeedUpdating && canUpdateState()) {
         // Copy from m_outputs to m_renderingOutputs.
         m_renderingOutputs.resize(m_outputs.size());
-        unsigned j = 0;
-        for (HashSet<AudioNodeOutput*>::iterator i = m_outputs.begin(); i != m_outputs.end(); ++i, ++j) {
-            AudioNodeOutput* output = *i;
-            m_renderingOutputs[j] = output;
+        unsigned i = 0;
+        for (auto& output : m_outputs) {
+            m_renderingOutputs[i++] = output;
             output->updateRenderingState();
         }
 
             output->updateRenderingState();
         }
 
index ed78a7c..b6e26e7 100644 (file)
@@ -81,15 +81,15 @@ bool MediaStreamAudioSource::removeAudioConsumer(AudioDestinationConsumer* consu
 void MediaStreamAudioSource::setAudioFormat(size_t numberOfChannels, float sampleRate)
 {
     MutexLocker locker(m_audioConsumersLock);
 void MediaStreamAudioSource::setAudioFormat(size_t numberOfChannels, float sampleRate)
 {
     MutexLocker locker(m_audioConsumersLock);
-    for (Vector<RefPtr<AudioDestinationConsumer>>::iterator it = m_audioConsumers.begin(); it != m_audioConsumers.end(); ++it)
-        (*it)->setFormat(numberOfChannels, sampleRate);
+    for (auto& consumer : m_audioConsumers)
+        consumer->setFormat(numberOfChannels, sampleRate);
 }
 
 void MediaStreamAudioSource::consumeAudio(AudioBus* bus, size_t numberOfFrames)
 {
     MutexLocker locker(m_audioConsumersLock);
 }
 
 void MediaStreamAudioSource::consumeAudio(AudioBus* bus, size_t numberOfFrames)
 {
     MutexLocker locker(m_audioConsumersLock);
-    for (Vector<RefPtr<AudioDestinationConsumer>>::iterator it = m_audioConsumers.begin(); it != m_audioConsumers.end(); ++it)
-        (*it)->consumeAudio(bus, numberOfFrames);
+    for (auto& consumer : m_audioConsumers)
+        consumer->consumeAudio(bus, numberOfFrames);
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index c2d6de0..6ce5586 100644 (file)
@@ -65,9 +65,9 @@ void WaveShaperProcessor::setOversample(OverSampleType oversample)
     m_oversample = oversample;
 
     if (oversample != OverSampleNone) {
     m_oversample = oversample;
 
     if (oversample != OverSampleNone) {
-        for (unsigned i = 0; i < m_kernels.size(); ++i) {
-            WaveShaperDSPKernel* kernel = static_cast<WaveShaperDSPKernel*>(m_kernels[i].get());
-            kernel->lazyInitializeOversampling();
+        for (auto& audioDSPKernel : m_kernels) {
+            WaveShaperDSPKernel& kernel = static_cast<WaveShaperDSPKernel&>(*audioDSPKernel);
+            kernel.lazyInitializeOversampling();
         }
     }
 }
         }
     }
 }
index 296adfd..a4413c2 100644 (file)
@@ -150,10 +150,10 @@ void DatabaseThread::handlePausedQueue()
     while (auto task = m_pausedQueue.tryGetMessage())
         pausedTasks.append(WTF::move(task));
 
     while (auto task = m_pausedQueue.tryGetMessage())
         pausedTasks.append(WTF::move(task));
 
-    for (unsigned i = 0; i < pausedTasks.size(); ++i) {
+    for (auto& pausedTask : pausedTasks) {
         AutodrainedPool pool;
 
         AutodrainedPool pool;
 
-        std::unique_ptr<DatabaseTask> task(pausedTasks[i].release());
+        std::unique_ptr<DatabaseTask> task(pausedTask.release());
         {
             MutexLocker pausedLocker(m_pausedMutex);
             if (m_paused) {
         {
             MutexLocker pausedLocker(m_pausedMutex);
             if (m_paused) {
@@ -203,9 +203,8 @@ void DatabaseThread::databaseThread()
         // As the call to close will modify the original set, we must take a copy to iterate over.
         DatabaseSet openSetCopy;
         openSetCopy.swap(m_openDatabaseSet);
         // As the call to close will modify the original set, we must take a copy to iterate over.
         DatabaseSet openSetCopy;
         openSetCopy.swap(m_openDatabaseSet);
-        DatabaseSet::iterator end = openSetCopy.end();
-        for (DatabaseSet::iterator it = openSetCopy.begin(); it != end; ++it)
-            (*it).get()->close();
+        for (auto& openDatabase : openSetCopy)
+            openDatabase->close();
     }
 
     // Detach the thread so its resources are no longer of any concern to anyone else
     }
 
     // Detach the thread so its resources are no longer of any concern to anyone else
index 7bcdbf0..a710dc2 100644 (file)
@@ -338,20 +338,16 @@ void DatabaseTracker::interruptAllDatabasesForContext(const DatabaseContext* con
         if (!nameMap)
             return;
 
         if (!nameMap)
             return;
 
-        DatabaseNameMap::const_iterator dbNameMapEndIt = nameMap->end();
-        for (DatabaseNameMap::const_iterator dbNameMapIt = nameMap->begin(); dbNameMapIt != dbNameMapEndIt; ++dbNameMapIt) {
-            DatabaseSet* databaseSet = dbNameMapIt->value;
-            DatabaseSet::const_iterator dbSetEndIt = databaseSet->end();
-            for (DatabaseSet::const_iterator dbSetIt = databaseSet->begin(); dbSetIt != dbSetEndIt; ++dbSetIt) {
-                if ((*dbSetIt)->databaseContext() == context)
-                    openDatabases.append(*dbSetIt);
+        for (auto& databaseSet : nameMap->values()) {
+            for (auto& database : *databaseSet) {
+                if (database->databaseContext() == context)
+                    openDatabases.append(database);
             }
         }
     }
 
             }
         }
     }
 
-    Vector<RefPtr<DatabaseBackendBase>>::const_iterator openDatabasesEndIt = openDatabases.end();
-    for (Vector<RefPtr<DatabaseBackendBase>>::const_iterator openDatabasesIt = openDatabases.begin(); openDatabasesIt != openDatabasesEndIt; ++openDatabasesIt)
-        (*openDatabasesIt)->interrupt();
+    for (auto& openDatabase : openDatabases)
+        openDatabase->interrupt();
 }
 
 String DatabaseTracker::originPath(SecurityOrigin* origin) const
 }
 
 String DatabaseTracker::originPath(SecurityOrigin* origin) const
@@ -482,8 +478,8 @@ bool DatabaseTracker::databaseNamesForOrigin(SecurityOrigin* origin, Vector<Stri
           return false;
     }
 
           return false;
     }
 
-    for (Vector<String>::iterator iter = temp.begin(); iter != temp.end(); ++iter)
-        resultVector.append(iter->isolatedCopy());
+    for (auto& databaseName : temp)
+        resultVector.append(databaseName.isolatedCopy());
     return true;
 }
 
     return true;
 }
 
@@ -670,8 +666,8 @@ void DatabaseTracker::getOpenDatabases(SecurityOrigin* origin, const String& nam
     if (!databaseSet)
         return;
 
     if (!databaseSet)
         return;
 
-    for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end(); ++it)
-        databases->add(*it);
+    for (auto& database : *databaseSet)
+        databases->add(database);
 }
 
 RefPtr<OriginLock> DatabaseTracker::originLockFor(SecurityOrigin* origin)
 }
 
 RefPtr<OriginLock> DatabaseTracker::originLockFor(SecurityOrigin* origin)
@@ -724,12 +720,9 @@ unsigned long long DatabaseTracker::usageForOrigin(SecurityOrigin* origin)
 {
     String originPath = this->originPath(origin);
     unsigned long long diskUsage = 0;
 {
     String originPath = this->originPath(origin);
     unsigned long long diskUsage = 0;
-    Vector<String> fileNames = listDirectory(originPath, String("*.db"));
-    Vector<String>::iterator fileName = fileNames.begin();
-    Vector<String>::iterator lastFileName = fileNames.end();
-    for (; fileName != lastFileName; ++fileName) {
+    for (auto& fileName : listDirectory(originPath, ASCIILiteral("*.db"))) {
         long long size;
         long long size;
-        getFileSize(*fileName, size);
+        getFileSize(fileName, size);
         diskUsage += size;
     }
     return diskUsage;
         diskUsage += size;
     }
     return diskUsage;
@@ -855,8 +848,8 @@ void DatabaseTracker::deleteAllDatabases()
     Vector<RefPtr<SecurityOrigin>> originsCopy;
     origins(originsCopy);
 
     Vector<RefPtr<SecurityOrigin>> originsCopy;
     origins(originsCopy);
 
-    for (unsigned i = 0; i < originsCopy.size(); ++i)
-        deleteOrigin(originsCopy[i].get());
+    for (auto& origin : originsCopy)
+        deleteOrigin(origin.get());
 }
 
 void DatabaseTracker::deleteDatabasesModifiedSince(std::chrono::system_clock::time_point time)
 }
 
 void DatabaseTracker::deleteDatabasesModifiedSince(std::chrono::system_clock::time_point time)
@@ -908,10 +901,10 @@ bool DatabaseTracker::deleteOrigin(SecurityOrigin* origin)
     }
 
     // We drop the lock here because holding locks during a call to deleteDatabaseFile will deadlock.
     }
 
     // We drop the lock here because holding locks during a call to deleteDatabaseFile will deadlock.
-    for (unsigned i = 0; i < databaseNames.size(); ++i) {
-        if (!deleteDatabaseFile(origin, databaseNames[i])) {
+    for (auto& name : databaseNames) {
+        if (!deleteDatabaseFile(origin, name)) {
             // Even if the file can't be deleted, we want to try and delete the rest, don't return early here.
             // Even if the file can't be deleted, we want to try and delete the rest, don't return early here.
-            LOG_ERROR("Unable to delete file for database %s in origin %s", databaseNames[i].ascii().data(), origin->databaseIdentifier().ascii().data());
+            LOG_ERROR("Unable to delete file for database %s in origin %s", name.ascii().data(), origin->databaseIdentifier().ascii().data());
         }
     }
 
         }
     }
 
@@ -973,8 +966,8 @@ bool DatabaseTracker::deleteOrigin(SecurityOrigin* origin)
 #if PLATFORM(IOS)
             m_client->dispatchDidDeleteDatabaseOrigin();
 #endif
 #if PLATFORM(IOS)
             m_client->dispatchDidDeleteDatabaseOrigin();
 #endif
-            for (unsigned i = 0; i < databaseNames.size(); ++i)
-                m_client->dispatchDidModifyDatabase(origin, databaseNames[i]);
+            for (auto& name : databaseNames)
+                m_client->dispatchDidModifyDatabase(origin, name);
         }
     }
     return true;
         }
     }
     return true;
@@ -1178,16 +1171,15 @@ bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& n
                 DatabaseSet* databaseSet = nameMap->get(name);
                 if (databaseSet && databaseSet->size()) {
                     // We have some database open with this name. Mark them as deleted.
                 DatabaseSet* databaseSet = nameMap->get(name);
                 if (databaseSet && databaseSet->size()) {
                     // We have some database open with this name. Mark them as deleted.
-                    DatabaseSet::const_iterator end = databaseSet->end();
-                    for (DatabaseSet::const_iterator it = databaseSet->begin(); it != end; ++it)
-                        deletedDatabases.append(*it);
+                    for (auto& database : *databaseSet)
+                        deletedDatabases.append(database);
                 }
             }
         }
     }
 
                 }
             }
         }
     }
 
-    for (unsigned i = 0; i < deletedDatabases.size(); ++i)
-        deletedDatabases[i]->markAsDeletedAndClose();
+    for (auto& database : deletedDatabases)
+        database->markAsDeletedAndClose();
 
 #if !PLATFORM(IOS)
     return SQLiteFileSystem::deleteDatabaseFile(fullPath);
 
 #if !PLATFORM(IOS)
     return SQLiteFileSystem::deleteDatabaseFile(fullPath);
@@ -1230,17 +1222,15 @@ void DatabaseTracker::removeDeletedOpenedDatabases()
     {
         MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
         if (m_openDatabaseMap) {
     {
         MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
         if (m_openDatabaseMap) {
-            DatabaseOriginMap::const_iterator originMapEnd = m_openDatabaseMap->end();
-            for (DatabaseOriginMap::const_iterator originMapIt = m_openDatabaseMap->begin(); originMapIt != originMapEnd; ++originMapIt) {
-                RefPtr<SecurityOrigin> origin = originMapIt->key;
-                DatabaseNameMap* databaseNameMap = originMapIt->value;
+            for (auto& openDatabase : *m_openDatabaseMap) {
+                auto& origin = openDatabase.key;
+                DatabaseNameMap* databaseNameMap = openDatabase.value;
                 Vector<String> deletedDatabaseNamesForThisOrigin;
 
                 // Loop through all opened databases in this origin.  Get the current database file path of each database and see if
                 // it still matches the path stored in the opened database object.
                 Vector<String> deletedDatabaseNamesForThisOrigin;
 
                 // Loop through all opened databases in this origin.  Get the current database file path of each database and see if
                 // it still matches the path stored in the opened database object.
-                DatabaseNameMap::const_iterator dbNameMapEnd = databaseNameMap->end();
-                for (DatabaseNameMap::const_iterator dbNameMapIt = databaseNameMap->begin(); dbNameMapIt != dbNameMapEnd; ++dbNameMapIt) {
-                    String databaseName = dbNameMapIt->key;
+                for (auto& databases : *databaseNameMap) {
+                    String databaseName = databases.key;
                     String databaseFileName;
                     SQLiteStatement statement(m_database, "SELECT path FROM Databases WHERE origin=? AND name=?;");
                     if (statement.prepare() == SQLITE_OK) {
                     String databaseFileName;
                     SQLiteStatement statement(m_database, "SELECT path FROM Databases WHERE origin=? AND name=?;");
                     if (statement.prepare() == SQLITE_OK) {
@@ -1252,11 +1242,7 @@ void DatabaseTracker::removeDeletedOpenedDatabases()
                     }
                     
                     bool foundDeletedDatabase = false;
                     }
                     
                     bool foundDeletedDatabase = false;
-                    DatabaseSet* databaseSet = dbNameMapIt->value;
-                    DatabaseSet::const_iterator dbEnd = databaseSet->end();
-                    for (DatabaseSet::const_iterator dbIt = databaseSet->begin(); dbIt != dbEnd; ++dbIt) {
-                        Database* db = static_cast<Database*>(*dbIt);
-                        
+                    for (auto& db : *databases.value) {
                         // We are done if this database has already been marked as deleted.
                         if (db->deleted())
                             continue;
                         // We are done if this database has already been marked as deleted.
                         if (db->deleted())
                             continue;
@@ -1279,19 +1265,18 @@ void DatabaseTracker::removeDeletedOpenedDatabases()
         }
     }
     
         }
     }
     
-    for (unsigned i = 0; i < deletedDatabases.size(); ++i)
-        deletedDatabases[i]->markAsDeletedAndClose();
-    
-    DeletedDatabaseMap::const_iterator end = deletedDatabaseMap.end();
-    for (DeletedDatabaseMap::const_iterator it = deletedDatabaseMap.begin(); it != end; ++it) {
-        SecurityOrigin* origin = it->key.get();
+    for (auto& deletedDatabase : deletedDatabases)
+        deletedDatabase->markAsDeletedAndClose();
+
+    for (auto& deletedDatabase : deletedDatabaseMap) {
+        SecurityOrigin* origin = deletedDatabase.key.get();
         if (m_client)
             m_client->dispatchDidModifyOrigin(origin);
         
         if (m_client)
             m_client->dispatchDidModifyOrigin(origin);
         
-        const Vector<String>& databaseNames = it->value;
-        for (unsigned i = 0; i < databaseNames.size(); ++i) {
+        const Vector<String>& databaseNames = deletedDatabase.value;
+        for (auto& databaseName : databaseNames) {
             if (m_client)
             if (m_client)
-                m_client->dispatchDidModifyDatabase(origin, databaseNames[i]);
+                m_client->dispatchDidModifyDatabase(origin, databaseName);
         }        
     }
 }
         }        
     }
 }
@@ -1365,21 +1350,10 @@ void DatabaseTracker::setDatabasesPaused(bool paused)
 
     // This walking is - sadly - the only reliable way to get at each open database thread.
     // This will be cleaner once <rdar://problem/5680441> or some other DB thread consolidation takes place.
 
     // This walking is - sadly - the only reliable way to get at each open database thread.
     // This will be cleaner once <rdar://problem/5680441> or some other DB thread consolidation takes place.
-    DatabaseOriginMap::iterator i = m_openDatabaseMap.get()->begin();
-    DatabaseOriginMap::iterator end = m_openDatabaseMap.get()->end();
-    
-    for (; i != end; ++i) {
-        DatabaseNameMap* databaseNameMap = i->value;
-        DatabaseNameMap::iterator j = databaseNameMap->begin();
-        DatabaseNameMap::iterator dbNameMapEnd = databaseNameMap->end();
-        for (; j != dbNameMapEnd; ++j) {
-            DatabaseSet* databaseSet = j->value;
-            DatabaseSet::iterator k = databaseSet->begin();
-            DatabaseSet::iterator dbSetEnd = databaseSet->end();
-            for (; k != dbSetEnd; ++k) {
-                DatabaseContext* context = (*k)->databaseContext();
-                context->setPaused(paused);
-            }
+    for (auto& databaseNameMap : m_openDatabaseMap->values()) {
+        for (auto& databaseSet : databaseNameMap->values()) {
+            for (auto& database : *databaseSet)
+                database->databaseContext()->setPaused(paused);
         }
     }
 }
         }
     }
 }
index 9f62234..89a62ab 100644 (file)
@@ -119,21 +119,14 @@ void SQLTransactionCoordinator::shutdown()
     m_isShuttingDown = true;
 
     // Notify all transactions in progress that the database thread is shutting down
     m_isShuttingDown = true;
 
     // Notify all transactions in progress that the database thread is shutting down
-    for (CoordinationInfoMap::iterator coordinationInfoIterator = m_coordinationInfoMap.begin();
-         coordinationInfoIterator != m_coordinationInfoMap.end(); ++coordinationInfoIterator) {
-        CoordinationInfo& info = coordinationInfoIterator->value;
-
+    for (auto& info : m_coordinationInfoMap.values()) {
         // Clean up transactions that have reached "lockAcquired":
         // Transaction phase 4 cleanup. See comment on "What happens if a
         // transaction is interrupted?" at the top of SQLTransactionBackend.cpp.
         if (info.activeWriteTransaction)
             info.activeWriteTransaction->notifyDatabaseThreadIsShuttingDown();
         // Clean up transactions that have reached "lockAcquired":
         // Transaction phase 4 cleanup. See comment on "What happens if a
         // transaction is interrupted?" at the top of SQLTransactionBackend.cpp.
         if (info.activeWriteTransaction)
             info.activeWriteTransaction->notifyDatabaseThreadIsShuttingDown();
-        for (HashSet<RefPtr<SQLTransactionBackend>>::iterator activeReadTransactionsIterator =
-                     info.activeReadTransactions.begin();
-             activeReadTransactionsIterator != info.activeReadTransactions.end();
-             ++activeReadTransactionsIterator) {
-            (*activeReadTransactionsIterator)->notifyDatabaseThreadIsShuttingDown();
-        }
+        for (auto& transaction : info.activeReadTransactions)
+            transaction->notifyDatabaseThreadIsShuttingDown();
 
         // Clean up transactions that have NOT reached "lockAcquired":
         // Transaction phase 3 cleanup. See comment on "What happens if a
 
         // Clean up transactions that have NOT reached "lockAcquired":
         // Transaction phase 3 cleanup. See comment on "What happens if a
index e359b3b..0315fbe 100644 (file)
@@ -260,18 +260,18 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
     //
     // Here, we throw SYNTAX_ERR if the given protocols do not meet the latter criteria. This behavior does not
     // comply with WebSocket API specification, but it seems to be the only reasonable way to handle this conflict.
     //
     // Here, we throw SYNTAX_ERR if the given protocols do not meet the latter criteria. This behavior does not
     // comply with WebSocket API specification, but it seems to be the only reasonable way to handle this conflict.
-    for (size_t i = 0; i < protocols.size(); ++i) {
-        if (!isValidProtocolString(protocols[i])) {
-            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "Wrong protocol for WebSocket '" + encodeProtocolString(protocols[i]) + "'");
+    for (auto& protocol : protocols) {
+        if (!isValidProtocolString(protocol)) {
+            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "Wrong protocol for WebSocket '" + encodeProtocolString(protocol) + "'");
             m_state = CLOSED;
             ec = SYNTAX_ERR;
             return;
         }
     }
     HashSet<String> visited;
             m_state = CLOSED;
             ec = SYNTAX_ERR;
             return;
         }
     }
     HashSet<String> visited;
-    for (size_t i = 0; i < protocols.size(); ++i) {
-        if (!visited.add(protocols[i]).isNewEntry) {
-            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "WebSocket protocols contain duplicates: '" + encodeProtocolString(protocols[i]) + "'");
+    for (auto& protocol : protocols) {
+        if (!visited.add(protocol).isNewEntry) {
+            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "WebSocket protocols contain duplicates: '" + encodeProtocolString(protocol) + "'");
             m_state = CLOSED;
             ec = SYNTAX_ERR;
             return;
             m_state = CLOSED;
             ec = SYNTAX_ERR;
             return;
index 19e25a1..09d99e9 100644 (file)
@@ -50,8 +50,8 @@ void WebSocketExtensionDispatcher::reset()
 
 void WebSocketExtensionDispatcher::addProcessor(std::unique_ptr<WebSocketExtensionProcessor> processor)
 {
 
 void WebSocketExtensionDispatcher::addProcessor(std::unique_ptr<WebSocketExtensionProcessor> processor)
 {
-    for (size_t i = 0; i < m_processors.size(); ++i) {
-        if (m_processors[i]->extensionToken() == processor->extensionToken())
+    for (auto& extensionProcessor : m_processors) {
+        if (extensionProcessor->extensionToken() == processor->extensionToken())
             return;
     }
     ASSERT(processor->handshakeString().length());
             return;
     }
     ASSERT(processor->handshakeString().length());
@@ -81,12 +81,12 @@ void WebSocketExtensionDispatcher::appendAcceptedExtension(const String& extensi
         m_acceptedExtensionsBuilder.appendLiteral(", ");
     m_acceptedExtensionsBuilder.append(extensionToken);
     // FIXME: Should use ListHashSet to keep the order of the parameters.
         m_acceptedExtensionsBuilder.appendLiteral(", ");
     m_acceptedExtensionsBuilder.append(extensionToken);
     // FIXME: Should use ListHashSet to keep the order of the parameters.
-    for (HashMap<String, String>::const_iterator iterator = extensionParameters.begin(); iterator != extensionParameters.end(); ++iterator) {
+    for (auto& parameter : extensionParameters) {
         m_acceptedExtensionsBuilder.appendLiteral("; ");
         m_acceptedExtensionsBuilder.appendLiteral("; ");
-        m_acceptedExtensionsBuilder.append(iterator->key);
-        if (!iterator->value.isNull()) {
+        m_acceptedExtensionsBuilder.append(parameter.key);
+        if (!parameter.value.isNull()) {
             m_acceptedExtensionsBuilder.append('=');
             m_acceptedExtensionsBuilder.append('=');
-            m_acceptedExtensionsBuilder.append(iterator->value);
+            m_acceptedExtensionsBuilder.append(parameter.value);
         }
     }
 }
         }
     }
 }
@@ -118,9 +118,8 @@ bool WebSocketExtensionDispatcher::processHeaderValue(const String& headerValue)
             return false;
         }
 
             return false;
         }
 
-        size_t index;
-        for (index = 0; index < m_processors.size(); ++index) {
-            WebSocketExtensionProcessor* processor = m_processors[index].get();
+        size_t index = 0;
+        for (auto& processor : m_processors) {
             if (extensionToken == processor->extensionToken()) {
                 if (processor->processResponse(extensionParameters)) {
                     appendAcceptedExtension(extensionToken, extensionParameters);
             if (extensionToken == processor->extensionToken()) {
                 if (processor->processResponse(extensionParameters)) {
                     appendAcceptedExtension(extensionToken, extensionParameters);
@@ -129,6 +128,7 @@ bool WebSocketExtensionDispatcher::processHeaderValue(const String& headerValue)
                 fail(processor->failureReason());
                 return false;
             }
                 fail(processor->failureReason());
                 return false;
             }
+            ++index;
         }
         // There is no extension which can process the response.
         if (index == m_processors.size()) {
         }
         // There is no extension which can process the response.
         if (index == m_processors.size()) {
index 322aa40..551ddf2 100644 (file)
@@ -224,8 +224,8 @@ CString WebSocketHandshake::clientHandshakeMessage() const
     // order is not meaningful.  Thus, it's ok to send the order we constructed
     // the fields.
 
     // order is not meaningful.  Thus, it's ok to send the order we constructed
     // the fields.
 
-    for (size_t i = 0; i < fields.size(); i++) {
-        builder.append(fields[i]);
+    for (auto& field : fields) {
+        builder.append(field);
         builder.appendLiteral("\r\n");
     }
 
         builder.appendLiteral("\r\n");
     }