Changeset 190338 in webkit
- Timestamp:
- Sep 29, 2015 10:53:51 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r190337 r190338 1 2015-09-29 Hunseop Jeong <hs85.jeong@samsung.com> 2 3 Use modern for-loops in WebCore/loader. 4 https://bugs.webkit.org/show_bug.cgi?id=149397 5 6 Reviewed by Darin Adler. 7 8 No new tests because there is no behavior change. 9 10 * loader/CrossOriginAccessControl.cpp: 11 (WebCore::parseAccessControlExposeHeadersAllowList): 12 * loader/DocumentLoader.cpp: 13 (WebCore::DocumentLoader::substituteResourceDeliveryTimerFired): 14 * loader/FormSubmission.cpp: 15 (WebCore::FormSubmission::create): 16 * loader/FrameLoader.cpp: 17 (WebCore::FrameLoader::~FrameLoader): 18 (WebCore::FrameLoader::commitProvisionalLoad): 19 (WebCore::FrameLoader::detachChildren): 20 (WebCore::FrameLoader::shouldClose): 21 (WebCore::FrameLoader::tellClientAboutPastMemoryCacheLoads): 22 * loader/HistoryController.cpp: 23 (WebCore::HistoryController::currentFramesMatchItem): 24 * loader/SubframeLoader.cpp: 25 (WebCore::findPluginMIMETypeFromURL): 26 (WebCore::SubframeLoader::createJavaAppletWidget): 27 * loader/appcache/ApplicationCache.cpp: 28 (WebCore::ApplicationCache::isURLInOnlineWhitelist): 29 (WebCore::ApplicationCache::urlMatchesFallbackNamespace): 30 * loader/appcache/ApplicationCacheGroup.cpp: 31 (WebCore::ApplicationCacheGroup::didFinishLoadingManifest): 32 (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete): 33 (WebCore::ApplicationCacheGroup::postListenerTask): 34 * loader/appcache/ApplicationCacheHost.cpp: 35 (WebCore::ApplicationCacheHost::stopDeferringEvents): 36 * loader/appcache/ApplicationCacheStorage.cpp: 37 (WebCore::StorageIDJournal::~StorageIDJournal): 38 (WebCore::ApplicationCacheStorage::store): 39 (WebCore::ApplicationCacheStorage::getOriginsWithCache): 40 * loader/archive/Archive.cpp: 41 (WebCore::Archive::clearAllSubframeArchivesImpl): 42 * loader/archive/ArchiveResourceCollection.cpp: 43 (WebCore::ArchiveResourceCollection::addAllResources): 44 * loader/archive/cf/LegacyWebArchive.cpp: 45 (WebCore::LegacyWebArchive::createPropertyListRepresentation): 46 (WebCore::LegacyWebArchive::create): 47 * loader/archive/mhtml/MHTMLArchive.cpp: 48 (WebCore::MHTMLArchive::generateMHTMLData): 49 * loader/cache/CachedImage.cpp: 50 (WebCore::CachedImage::switchClientsToRevalidatedResource): 51 (WebCore::CachedImage::createImage): 52 * loader/cache/CachedResource.cpp: 53 (WebCore::CachedResource::switchClientsToRevalidatedResource): 54 * loader/cache/CachedResourceLoader.cpp: 55 (WebCore::CachedResourceLoader::~CachedResourceLoader): 56 (WebCore::CachedResourceLoader::reloadImagesIfNotDeferred): 57 (WebCore::CachedResourceLoader::garbageCollectDocumentResources): 58 (WebCore::CachedResourceLoader::isPreloaded): 59 (WebCore::CachedResourceLoader::printPreloadStats): 60 * loader/icon/IconDatabase.cpp: 61 (WebCore::IconDatabase::removeAllIcons): 62 (WebCore::IconDatabase::setIconDataForIconURL): 63 (WebCore::IconDatabase::iconRecordCountWithData): 64 (WebCore::IconDatabase::notifyPendingLoadDecisions): 65 (WebCore::IconDatabase::performURLImport): 66 (WebCore::IconDatabase::performPendingRetainAndReleaseOperations): 67 (WebCore::IconDatabase::readFromDatabase): 68 (WebCore::IconDatabase::writeToDatabase): 69 1 70 2015-09-29 Chris Dumez <cdumez@apple.com> 2 71 -
trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp
r175231 r190338 171 171 Vector<String> headers; 172 172 headerValue.split(',', false, headers); 173 for ( unsigned headerCount = 0; headerCount < headers.size(); headerCount++) {174 String strippedHeader = header s[headerCount].stripWhiteSpace();173 for (auto& header : headers) { 174 String strippedHeader = header.stripWhiteSpace(); 175 175 if (!strippedHeader.isEmpty()) 176 176 headerSet.add(strippedHeader); -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r190169 r190338 1149 1149 copy.swap(m_pendingSubstituteResources); 1150 1150 1151 SubstituteResourceMap::const_iterator end = copy.end(); 1152 for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++it) { 1153 RefPtr<ResourceLoader> loader = it->key; 1154 SubstituteResource* resource = it->value.get(); 1155 1151 for (auto& entry : copy) { 1152 auto& loader = entry.key; 1153 SubstituteResource* resource = entry.value.get(); 1154 1156 1155 if (resource) 1157 1156 resource->deliver(*loader); -
trunk/Source/WebCore/loader/FormSubmission.cpp
r189771 r190338 202 202 203 203 bool containsPasswordData = false; 204 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { 205 FormAssociatedElement& control = *form->associatedElements()[i]; 206 HTMLElement& element = control.asHTMLElement(); 204 for (auto& control : form->associatedElements()) { 205 HTMLElement& element = control->asHTMLElement(); 207 206 if (!element.isDisabledFormControl()) 208 control .appendFormData(*domFormData, isMultiPartForm);207 control->appendFormData(*domFormData, isMultiPartForm); 209 208 if (is<HTMLInputElement>(element)) { 210 209 HTMLInputElement& input = downcast<HTMLInputElement>(element); -
trunk/Source/WebCore/loader/FrameLoader.cpp
r189834 r190338 245 245 setOpener(nullptr); 246 246 247 HashSet<Frame*>::iterator end = m_openedFrames.end(); 248 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it) 249 (*it)->loader().m_opener = 0; 247 for (auto& frame : m_openedFrames) 248 frame->loader().m_opener = nullptr; 250 249 251 250 m_client.frameLoaderDestroyed(); … … 1859 1858 #endif 1860 1859 1861 const ResponseVector& responses = m_documentLoader->responses(); 1862 size_t count = responses.size(); 1863 for (size_t i = 0; i < count; i++) { 1864 const ResourceResponse& response = responses[i]; 1860 for (auto& response : m_documentLoader->responses()) { 1865 1861 // FIXME: If the WebKit client changes or cancels the request, this is not respected. 1866 1862 ResourceError error; … … 2429 2425 for (Frame* child = m_frame.tree().lastChild(); child; child = child->tree().previousSibling()) 2430 2426 childrenToDetach.uncheckedAppend(*child); 2431 for ( unsigned i = 0; i < childrenToDetach.size(); ++i)2432 child renToDetach[i]->loader().detachFromParent();2427 for (auto& child : childrenToDetach) 2428 child->loader().detachFromParent(); 2433 2429 } 2434 2430 … … 3433 3429 m_documentLoader->takeMemoryCacheLoadsForClientNotification(pastLoads); 3434 3430 3435 size_t size = pastLoads.size(); 3436 for (size_t i = 0; i < size; ++i) { 3437 CachedResource* resource = MemoryCache::singleton().resourceForRequest(pastLoads[i], m_frame.page()->sessionID()); 3431 for (auto& pastLoad : pastLoads) { 3432 CachedResource* resource = MemoryCache::singleton().resourceForRequest(pastLoad, m_frame.page()->sessionID()); 3438 3433 3439 3434 // FIXME: These loads, loaded from cache, but now gone from the cache by the time -
trunk/Source/WebCore/loader/HistoryController.cpp
r187962 r190338 780 780 return false; 781 781 782 unsigned size = childItems.size(); 783 for (unsigned i = 0; i < size; ++i) { 784 if (!m_frame.tree().child(childItems[i]->target())) 782 for (auto& item : childItems) { 783 if (!m_frame.tree().child(item->target())) 785 784 return false; 786 785 } -
trunk/Source/WebCore/loader/SubframeLoader.cpp
r189164 r190338 172 172 Vector<size_t> mimePluginIndices; 173 173 pluginData.getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices); 174 for (size_t i = 0; i < mimes.size(); ++i) { 175 const MimeClassInfo& mimeClassInfo = mimes[i]; 176 for (size_t j = 0; j < mimeClassInfo.extensions.size(); ++j) { 177 if (equalIgnoringCase(extension, mimeClassInfo.extensions[j])) 178 return mimeClassInfo.type; 174 for (auto& mime : mimes) { 175 for (auto& mimeExtension : mime.extensions) { 176 if (equalIgnoringCase(extension, mimeExtension)) 177 return mime.type; 179 178 } 180 179 } -
trunk/Source/WebCore/loader/appcache/ApplicationCache.cpp
r182570 r190338 154 154 bool ApplicationCache::isURLInOnlineWhitelist(const URL& url) 155 155 { 156 size_t whitelistSize = m_onlineWhitelist.size(); 157 for (size_t i = 0; i < whitelistSize; ++i) { 158 if (protocolHostAndPortAreEqual(url, m_onlineWhitelist[i]) && url.string().startsWith(m_onlineWhitelist[i].string())) 156 for (auto& whitelistURL : m_onlineWhitelist) { 157 if (protocolHostAndPortAreEqual(url, whitelistURL) && url.string().startsWith(whitelistURL.string())) 159 158 return true; 160 159 } … … 172 171 bool ApplicationCache::urlMatchesFallbackNamespace(const URL& url, URL* fallbackURL) 173 172 { 174 size_t fallbackCount = m_fallbackURLs.size(); 175 for (size_t i = 0; i < fallbackCount; ++i) { 176 if (protocolHostAndPortAreEqual(url, m_fallbackURLs[i].first) && url.string().startsWith(m_fallbackURLs[i].first.string())) { 173 for (auto& fallback : m_fallbackURLs) { 174 if (protocolHostAndPortAreEqual(url, fallback.first) && url.string().startsWith(fallback.first.string())) { 177 175 if (fallbackURL) 178 *fallbackURL = m_fallbackURLs[i].second;176 *fallbackURL = fallback.second; 179 177 return true; 180 178 } -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
r187533 r190338 730 730 m_cacheBeingUpdated->setGroup(this); 731 731 732 HashSet<DocumentLoader*>::const_iterator masterEnd = m_pendingMasterResourceLoaders.end(); 733 for (HashSet<DocumentLoader*>::const_iterator iter = m_pendingMasterResourceLoaders.begin(); iter != masterEnd; ++iter) 734 associateDocumentLoaderWithCache(*iter, m_cacheBeingUpdated.get()); 732 for (auto& loader : m_pendingMasterResourceLoaders) 733 associateDocumentLoaderWithCache(loader, m_cacheBeingUpdated.get()); 735 734 736 735 // We have the manifest, now download the resources. … … 752 751 addEntry(explicitURL, ApplicationCacheResource::Explicit); 753 752 754 size_t fallbackCount = manifest.fallbackURLs.size(); 755 for (size_t i = 0; i < fallbackCount; ++i) 756 addEntry(manifest.fallbackURLs[i].second, ApplicationCacheResource::Fallback); 753 for (auto& fallbackURL : manifest.fallbackURLs) 754 addEntry(fallbackURL.second, ApplicationCacheResource::Fallback); 757 755 758 756 m_cacheBeingUpdated->setOnlineWhitelist(manifest.onlineWhitelistedURLs); … … 942 940 Vector<DocumentLoader*> loaders; 943 941 copyToVector(m_pendingMasterResourceLoaders, loaders); 944 size_t count = loaders.size(); 945 for (size_t i = 0; i != count; ++i) 946 disassociateDocumentLoader(loaders[i]); // This can delete this group. 942 for (auto& loader : loaders) 943 disassociateDocumentLoader(loader); // This can delete this group. 947 944 948 945 // Reinstate the oldNewestCache, if there was one. … … 1080 1077 void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID eventID, int progressTotal, int progressDone, const HashSet<DocumentLoader*>& loaderSet) 1081 1078 { 1082 HashSet<DocumentLoader*>::const_iterator loaderSetEnd = loaderSet.end(); 1083 for (HashSet<DocumentLoader*>::const_iterator iter = loaderSet.begin(); iter != loaderSetEnd; ++iter) 1084 postListenerTask(eventID, progressTotal, progressDone, *iter); 1079 for (auto& loader : loaderSet) 1080 postListenerTask(eventID, progressTotal, progressDone, loader); 1085 1081 } 1086 1082 -
trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
r188486 r190338 306 306 { 307 307 Ref<DocumentLoader> protect(m_documentLoader); 308 for (unsigned i = 0; i < m_deferredEvents.size(); ++i) { 309 const DeferredEvent& deferred = m_deferredEvents[i]; 310 dispatchDOMEvent(deferred.eventID, deferred.progressTotal, deferred.progressDone); 311 } 308 for (auto& event : m_deferredEvents) 309 dispatchDOMEvent(event.eventID, event.progressTotal, event.progressDone); 312 310 m_deferredEvents.clear(); 313 311 m_defersEvents = false; -
trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
r182612 r190338 51 51 ~StorageIDJournal() 52 52 { 53 size_t size = m_records.size(); 54 for (size_t i = 0; i < size; ++i) 55 m_records[i].restore(); 53 for (auto& record : m_records) 54 record.restore(); 56 55 } 57 56 … … 752 751 const Vector<URL>& onlineWhitelist = cache->onlineWhitelist(); 753 752 { 754 size_t whitelistSize = onlineWhitelist.size(); 755 for (size_t i = 0; i < whitelistSize; ++i) { 753 for (auto& whitelistURL : onlineWhitelist) { 756 754 SQLiteStatement statement(m_database, "INSERT INTO CacheWhitelistURLs (url, cache) VALUES (?, ?)"); 757 755 statement.prepare(); 758 756 759 statement.bindText(1, onlineWhitelist[i]);757 statement.bindText(1, whitelistURL); 760 758 statement.bindInt64(2, cacheStorageID); 761 759 … … 780 778 const FallbackURLVector& fallbackURLs = cache->fallbackURLs(); 781 779 { 782 size_t fallbackCount = fallbackURLs.size(); 783 for (size_t i = 0; i < fallbackCount; ++i) { 780 for (auto& fallbackURL : fallbackURLs) { 784 781 SQLiteStatement statement(m_database, "INSERT INTO FallbackURLs (namespace, fallbackURL, cache) VALUES (?, ?, ?)"); 785 782 statement.prepare(); 786 783 787 statement.bindText(1, fallbackURL s[i].first);788 statement.bindText(2, fallbackURL s[i].second);784 statement.bindText(1, fallbackURL.first); 785 statement.bindText(2, fallbackURL.second); 789 786 statement.bindInt64(3, cacheStorageID); 790 787 … … 1530 1527 // Multiple manifest URLs might share the same SecurityOrigin, so we might be creating extra, wasted origins here. 1531 1528 // The current schema doesn't allow for a more efficient way of building this list. 1532 size_t count = urls.size(); 1533 for (size_t i = 0; i < count; ++i) 1534 origins.add(SecurityOrigin::create(urls[i])); 1529 for (auto& url : urls) 1530 origins.add(SecurityOrigin::create(url)); 1535 1531 } 1536 1532 -
trunk/Source/WebCore/loader/archive/Archive.cpp
r165676 r190338 44 44 void Archive::clearAllSubframeArchivesImpl(Vector<RefPtr<Archive>>* clearedArchives) 45 45 { 46 for ( Vector<RefPtr<Archive>>::iterator it = m_subframeArchives.begin(); it != m_subframeArchives.end(); ++it) {47 if (!clearedArchives->contains( *it)) {48 clearedArchives->append( *it);49 (*it)->clearAllSubframeArchivesImpl(clearedArchives);46 for (auto& archive : m_subframeArchives) { 47 if (!clearedArchives->contains(archive)) { 48 clearedArchives->append(archive); 49 archive->clearAllSubframeArchivesImpl(clearedArchives); 50 50 } 51 51 } -
trunk/Source/WebCore/loader/archive/ArchiveResourceCollection.cpp
r165676 r190338 42 42 return; 43 43 44 const Vector<RefPtr<ArchiveResource>>& subresources = archive->subresources(); 45 for (Vector<RefPtr<ArchiveResource>>::const_iterator iterator = subresources.begin(); iterator != subresources.end(); ++iterator) 46 m_subresources.set((*iterator)->url(), iterator->get()); 44 for (auto& subresource : archive->subresources()) 45 m_subresources.set(subresource->url(), subresource.get()); 47 46 48 const Vector<RefPtr<Archive>>& subframes = archive->subframeArchives(); 49 for (Vector<RefPtr<Archive>>::const_iterator iterator = subframes.begin(); iterator != subframes.end(); ++iterator) { 50 RefPtr<Archive> archive = *iterator; 51 ASSERT(archive->mainResource()); 47 for (auto& subframeArchive : archive->subframeArchives()) { 48 ASSERT(subframeArchive->mainResource()); 52 49 53 const String& frameName = archive->mainResource()->frameName();50 const String& frameName = subframeArchive->mainResource()->frameName(); 54 51 if (!frameName.isNull()) 55 m_subframes.set(frameName, archive.get());52 m_subframes.set(frameName, subframeArchive.get()); 56 53 else { 57 54 // In the MHTML case, frames don't have a name so we use the URL instead. 58 m_subframes.set( archive->mainResource()->url().string(), archive.get());55 m_subframes.set(subframeArchive->mainResource()->url().string(), subframeArchive.get()); 59 56 } 60 57 } -
trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
r189182 r190338 134 134 135 135 RetainPtr<CFMutableArrayRef> subresourcesArray = adoptCF(CFArrayCreateMutable(0, archive->subresources().size(), &kCFTypeArrayCallBacks)); 136 const Vector<RefPtr<ArchiveResource>>& subresources(archive->subresources()); 137 for (unsigned i = 0; i < subresources.size(); ++i) { 138 RetainPtr<CFDictionaryRef> subresource = createPropertyListRepresentation(subresources[i].get(), Subresource); 139 if (subresource) 136 for (auto& resource : archive->subresources()) { 137 if (RetainPtr<CFDictionaryRef> subresource = createPropertyListRepresentation(resource.get(), Subresource)) 140 138 CFArrayAppendValue(subresourcesArray.get(), subresource.get()); 141 139 else … … 146 144 147 145 RetainPtr<CFMutableArrayRef> subframesArray = adoptCF(CFArrayCreateMutable(0, archive->subframeArchives().size(), &kCFTypeArrayCallBacks)); 148 const Vector<RefPtr<Archive>>& subframeArchives(archive->subframeArchives()); 149 for (unsigned i = 0; i < subframeArchives.size(); ++i) { 150 RetainPtr<CFDictionaryRef> subframeArchive = createPropertyListRepresentation(subframeArchives[i].get()); 151 if (subframeArchive) 146 for (auto& subframe : archive->subframeArchives()) { 147 if (RetainPtr<CFDictionaryRef> subframeArchive = createPropertyListRepresentation(subframe.get())) 152 148 CFArrayAppendValue(subframesArray.get(), subframeArchive.get()); 153 149 else … … 247 243 archive->setMainResource(mainResource); 248 244 249 for ( unsigned i = 0; i < subresources.size(); ++i)250 archive->addSubresource(WTF::move(subresource s[i]));251 252 for ( unsigned i = 0; i < subframeArchives.size(); ++i)253 archive->addSubframeArchive(WTF::move(subframeArchive s[i]));254 245 for (auto& subresource : subresources) 246 archive->addSubresource(WTF::move(subresource)); 247 248 for (auto& subframeArchive : subframeArchives) 249 archive->addSubframeArchive(WTF::move(subframeArchive)); 250 255 251 return archive.release(); 256 252 } -
trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp
r156550 r190338 177 177 mhtmlData->append(asciiString.data(), asciiString.length()); 178 178 179 for (size_t i = 0; i < resources.size(); ++i) { 180 const PageSerializer::Resource& resource = resources[i]; 181 179 for (auto& resource : resources) { 182 180 stringBuilder.clear(); 183 181 stringBuilder.append(endOfResourceBoundary); -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r188839 r190338 150 150 // A copy of pending size requests is needed as they are deleted during CachedResource::switchClientsToRevalidateResouce(). 151 151 ContainerSizeRequests switchContainerSizeRequests; 152 for ( ContainerSizeRequests::iterator it = m_pendingContainerSizeRequests.begin(); it != m_pendingContainerSizeRequests.end(); ++it)153 switchContainerSizeRequests.set( it->key, it->value);152 for (auto& request : m_pendingContainerSizeRequests) 153 switchContainerSizeRequests.set(request.key, request.value); 154 154 CachedResource::switchClientsToRevalidatedResource(); 155 155 CachedImage& revalidatedCachedImage = downcast<CachedImage>(*resourceToRevalidate()); 156 for ( ContainerSizeRequests::iterator it = switchContainerSizeRequests.begin(); it != switchContainerSizeRequests.end(); ++it)157 revalidatedCachedImage.setContainerSizeForRenderer( it->key, it->value.first, it->value.second);156 for (auto& request : switchContainerSizeRequests) 157 revalidatedCachedImage.setContainerSizeForRenderer(request.key, request.value.first, request.value.second); 158 158 return; 159 159 } … … 354 354 // Send queued container size requests. 355 355 if (m_image->usesContainerSize()) { 356 for ( ContainerSizeRequests::iterator it = m_pendingContainerSizeRequests.begin(); it != m_pendingContainerSizeRequests.end(); ++it)357 setContainerSizeForRenderer( it->key, it->value.first, it->value.second);356 for (auto& request : m_pendingContainerSizeRequests) 357 setContainerSizeForRenderer(request.key, request.value.first, request.value.second); 358 358 } 359 359 m_pendingContainerSizeRequests.clear(); -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r188358 r190338 626 626 627 627 m_switchingClientsToRevalidatedResource = true; 628 HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end(); 629 for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) { 630 CachedResourceHandleBase* handle = *it; 628 for (auto& handle : m_handlesToRevalidate) { 631 629 handle->m_resource = m_resourceToRevalidate; 632 630 m_resourceToRevalidate->registerHandle(handle); … … 637 635 638 636 Vector<CachedResourceClient*> clientsToMove; 639 HashCountedSet<CachedResourceClient*>::iterator end2 = m_clients.end(); 640 for (HashCountedSet<CachedResourceClient*>::iterator it = m_clients.begin(); it != end2; ++it) { 641 CachedResourceClient* client = it->key; 642 unsigned count = it->value; 637 for (auto& entry : m_clients) { 638 CachedResourceClient* client = entry.key; 639 unsigned count = entry.value; 643 640 while (count) { 644 641 clientsToMove.append(client); … … 647 644 } 648 645 649 unsigned moveCount = clientsToMove.size(); 650 for (unsigned n = 0; n < moveCount; ++n) 651 removeClient(clientsToMove[n]); 646 for (auto& client : clientsToMove) 647 removeClient(client); 652 648 ASSERT(m_clients.isEmpty()); 653 649 654 for ( unsigned n = 0; n < moveCount; ++n)655 m_resourceToRevalidate->addClientToSet(client sToMove[n]);656 for ( unsigned n = 0; n < moveCount; ++n) {650 for (auto& client : clientsToMove) 651 m_resourceToRevalidate->addClientToSet(client); 652 for (auto& client : clientsToMove) { 657 653 // Calling didAddClient may do anything, including trying to cancel revalidation. 658 654 // Assert that it didn't succeed. 659 655 ASSERT(m_resourceToRevalidate); 660 656 // Calling didAddClient for a client may end up removing another client. In that case it won't be in the set anymore. 661 if (m_resourceToRevalidate->m_clients.contains(client sToMove[n]))662 m_resourceToRevalidate->didAddClient(client sToMove[n]);657 if (m_resourceToRevalidate->m_clients.contains(client)) 658 m_resourceToRevalidate->didAddClient(client); 663 659 } 664 660 m_switchingClientsToRevalidatedResource = false; -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r189432 r190338 139 139 140 140 clearPreloads(); 141 DocumentResourceMap::iterator end = m_documentResources.end(); 142 for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) 143 it->value->setOwningCachedResourceLoader(0); 141 for (auto& resource : m_documentResources.values()) 142 resource->setOwningCachedResourceLoader(nullptr); 144 143 145 144 // Make sure no requests still point to this CachedResourceLoader … … 862 861 void CachedResourceLoader::reloadImagesIfNotDeferred() 863 862 { 864 DocumentResourceMap::iterator end = m_documentResources.end(); 865 for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it) { 866 CachedResource* resource = it->value.get(); 863 for (auto& resource : m_documentResources.values()) { 867 864 if (is<CachedImage>(*resource) && resource->stillNeedsLoad() && !clientDefersImage(resource->url())) 868 865 downcast<CachedImage>(*resource).load(*this, defaultCachedResourceOptions()); … … 946 943 StringVector resourcesToDelete; 947 944 948 for ( DocumentResourceMap::iterator it = m_documentResources.begin(); it != m_documentResources.end(); ++it) {949 if ( it->value->hasOneHandle()) {950 resourcesToDelete.append( it->key);951 it->value->setOwningCachedResourceLoader(0);945 for (auto& resource : m_documentResources) { 946 if (resource.value->hasOneHandle()) { 947 resourcesToDelete.append(resource.key); 948 resource.value->setOwningCachedResourceLoader(nullptr); 952 949 } 953 950 } 954 951 955 for ( StringVector::const_iterator it = resourcesToDelete.begin(); it != resourcesToDelete.end(); ++it)956 m_documentResources.remove( *it);952 for (auto& resource : resourcesToDelete) 953 m_documentResources.remove(resource); 957 954 } 958 955 … … 1050 1047 1051 1048 if (m_preloads) { 1052 ListHashSet<CachedResource*>::iterator end = m_preloads->end(); 1053 for (ListHashSet<CachedResource*>::iterator it = m_preloads->begin(); it != end; ++it) { 1054 CachedResource* resource = *it; 1049 for (auto& resource : *m_preloads) { 1055 1050 if (resource->url() == url) 1056 1051 return true; … … 1058 1053 } 1059 1054 1060 Deque<PendingPreload>::const_iterator dequeEnd = m_pendingPreloads.end(); 1061 for (Deque<PendingPreload>::const_iterator it = m_pendingPreloads.begin(); it != dequeEnd; ++it) { 1062 PendingPreload pendingPreload = *it; 1055 for (auto& pendingPreload : m_pendingPreloads) { 1063 1056 if (pendingPreload.m_request.resourceRequest().url() == url) 1064 1057 return true; … … 1098 1091 unsigned images = 0; 1099 1092 unsigned imageMisses = 0; 1100 ListHashSet<CachedResource*>::iterator end = m_preloads.end(); 1101 for (ListHashSet<CachedResource*>::iterator it = m_preloads.begin(); it != end; ++it) { 1102 CachedResource* res = *it; 1103 if (res->preloadResult() == CachedResource::PreloadNotReferenced) 1104 printf("!! UNREFERENCED PRELOAD %s\n", res->url().latin1().data()); 1105 else if (res->preloadResult() == CachedResource::PreloadReferencedWhileComplete) 1106 printf("HIT COMPLETE PRELOAD %s\n", res->url().latin1().data()); 1107 else if (res->preloadResult() == CachedResource::PreloadReferencedWhileLoading) 1108 printf("HIT LOADING PRELOAD %s\n", res->url().latin1().data()); 1093 for (auto& resource : m_preloads) { 1094 if (resource->preloadResult() == CachedResource::PreloadNotReferenced) 1095 printf("!! UNREFERENCED PRELOAD %s\n", resource->url().latin1().data()); 1096 else if (resource->preloadResult() == CachedResource::PreloadReferencedWhileComplete) 1097 printf("HIT COMPLETE PRELOAD %s\n", resource->url().latin1().data()); 1098 else if (resource->preloadResult() == CachedResource::PreloadReferencedWhileLoading) 1099 printf("HIT LOADING PRELOAD %s\n", resource->url().latin1().data()); 1109 1100 1110 if (res ->type() == CachedResource::Script) {1101 if (resource->type() == CachedResource::Script) { 1111 1102 scripts++; 1112 if (res ->preloadResult() < CachedResource::PreloadReferencedWhileLoading)1103 if (resource->preloadResult() < CachedResource::PreloadReferencedWhileLoading) 1113 1104 scriptMisses++; 1114 } else if (res ->type() == CachedResource::CSSStyleSheet) {1105 } else if (resource->type() == CachedResource::CSSStyleSheet) { 1115 1106 stylesheets++; 1116 if (res ->preloadResult() < CachedResource::PreloadReferencedWhileLoading)1107 if (resource->preloadResult() < CachedResource::PreloadReferencedWhileLoading) 1117 1108 stylesheetMisses++; 1118 1109 } else { 1119 1110 images++; 1120 if (res ->preloadResult() < CachedResource::PreloadReferencedWhileLoading)1111 if (resource->preloadResult() < CachedResource::PreloadReferencedWhileLoading) 1121 1112 imageMisses++; 1122 1113 } 1123 1114 1124 if (res ->errorOccurred())1125 MemoryCache::singleton().remove(res );1115 if (resource->errorOccurred()) 1116 MemoryCache::singleton().remove(resource); 1126 1117 1127 res ->decreasePreloadCount();1118 resource->decreasePreloadCount(); 1128 1119 } 1129 1120 m_preloads = nullptr; -
trunk/Source/WebCore/loader/icon/IconDatabase.cpp
r188931 r190338 191 191 // Clear the IconRecords for every page URL - RefCounting will cause the IconRecords themselves to be deleted 192 192 // We don't delete the actual PageRecords because we have the "retain icon for url" count to keep track of 193 HashMap<String, PageURLRecord*>::iterator iter = m_pageURLToRecordMap.begin(); 194 HashMap<String, PageURLRecord*>::iterator end = m_pageURLToRecordMap.end(); 195 for (; iter != end; ++iter) 196 (*iter).value->setIconRecord(0); 197 193 for (auto& pageURL : m_pageURLToRecordMap.values()) 194 pageURL->setIconRecord(nullptr); 195 198 196 // Clear the iconURL -> IconRecord map 199 197 m_iconURLToRecordMap.clear(); … … 586 584 scheduleOrDeferSyncTimer(); 587 585 588 for ( unsigned i = 0; i < pageURLs.size(); ++i) {586 for (auto& pageURL : pageURLs) { 589 587 AutodrainedPool pool; 590 588 591 LOG(IconDatabase, "Dispatching notification that retaining pageURL %s has a new icon", urlForLogging(pageURL s[i]).ascii().data());592 m_client->didChangeIconForPageURL(pageURL s[i]);589 LOG(IconDatabase, "Dispatching notification that retaining pageURL %s has a new icon", urlForLogging(pageURL).ascii().data()); 590 m_client->didChangeIconForPageURL(pageURL); 593 591 } 594 592 } … … 776 774 LockHolder locker(m_urlAndIconLock); 777 775 size_t result = 0; 778 779 HashMap<String, IconRecord*>::iterator i = m_iconURLToRecordMap.begin(); 780 HashMap<String, IconRecord*>::iterator end = m_iconURLToRecordMap.end(); 781 782 for (; i != end; ++i) 783 result += ((*i).value->imageDataStatus() == ImageDataStatusPresent); 784 776 777 for (auto& iconRecord : m_iconURLToRecordMap.values()) 778 result += (iconRecord->imageDataStatus() == ImageDataStatusPresent); 779 785 780 return result; 786 781 } … … 817 812 ASSERT(m_iconURLImportComplete); 818 813 LOG(IconDatabase, "Notifying all DocumentLoaders that were waiting on a load decision for their icons"); 819 820 HashSet<RefPtr<DocumentLoader>>::iterator i = m_loadersPendingDecision.begin(); 821 HashSet<RefPtr<DocumentLoader>>::iterator end = m_loadersPendingDecision.end(); 822 823 for (; i != end; ++i) 824 if ((*i)->refCount() > 1) 825 (*i)->iconLoadDecisionAvailable(); 826 814 815 for (auto& loader : m_loadersPendingDecision) { 816 if (loader->refCount() > 1) 817 loader->iconLoadDecisionAvailable(); 818 } 819 827 820 m_loadersPendingDecision.clear(); 828 821 } … … 1289 1282 performPendingRetainAndReleaseOperations(); 1290 1283 1291 for ( unsigned i = 0; i < urls.size(); ++i) {1292 if (!m_retainedPageURLs.contains(url s[i])) {1293 PageURLRecord* record = m_pageURLToRecordMap.get(url s[i]);1284 for (auto& url : urls) { 1285 if (!m_retainedPageURLs.contains(url)) { 1286 PageURLRecord* record = m_pageURLToRecordMap.get(url); 1294 1287 if (record && !databaseCleanupCounter) { 1295 m_pageURLToRecordMap.remove(url s[i]);1288 m_pageURLToRecordMap.remove(url); 1296 1289 IconRecord* iconRecord = record->iconRecord(); 1297 1290 … … 1303 1296 { 1304 1297 LockHolder locker(m_pendingReadingLock); 1305 m_pageURLsInterestedInIcons.remove(url s[i]);1298 m_pageURLsInterestedInIcons.remove(url); 1306 1299 m_iconsPendingReading.remove(iconRecord); 1307 1300 } … … 1315 1308 } 1316 1309 } else { 1317 urlsToNotify.append(url s[i]);1310 urlsToNotify.append(url); 1318 1311 } 1319 1312 } … … 1322 1315 LOG(IconDatabase, "Notifying %lu interested page URLs that their icon URL is known due to the import", static_cast<unsigned long>(urlsToNotify.size())); 1323 1316 // Now that we don't hold any locks, perform the actual notifications 1324 for ( unsigned i = 0; i < urlsToNotify.size(); ++i) {1317 for (auto& url : urlsToNotify) { 1325 1318 AutodrainedPool pool; 1326 1319 1327 LOG(IconDatabase, "Notifying icon info known for pageURL %s", url sToNotify[i].ascii().data());1328 dispatchDidImportIconURLForPageURLOnMainThread(url sToNotify[i]);1320 LOG(IconDatabase, "Notifying icon info known for pageURL %s", url.ascii().data()); 1321 dispatchDidImportIconURLForPageURLOnMainThread(url); 1329 1322 if (shouldStopThreadActivity()) 1330 1323 return; … … 1466 1459 } 1467 1460 1468 for ( HashCountedSet<String>::const_iterator it = toRetain.begin(), end = toRetain.end(); it != end; ++it) {1469 ASSERT(! it->key.impl() || it->key.impl()->hasOneRef());1470 performRetainIconForPageURL( it->key, it->value);1471 } 1472 1473 for ( HashCountedSet<String>::const_iterator it = toRelease.begin(), end = toRelease.end(); it != end; ++it) {1474 ASSERT(! it->key.impl() || it->key.impl()->hasOneRef());1475 performReleaseIconForPageURL( it->key, it->value);1461 for (auto& entry : toRetain) { 1462 ASSERT(!entry.key.impl() || entry.key.impl()->hasOneRef()); 1463 performRetainIconForPageURL(entry.key, entry.value); 1464 } 1465 1466 for (auto& entry : toRelease) { 1467 ASSERT(!entry.key.impl() || entry.key.impl()->hasOneRef()); 1468 performReleaseIconForPageURL(entry.key, entry.value); 1476 1469 } 1477 1470 } … … 1529 1522 } 1530 1523 1531 HashSet<String>::const_iterator iter = outerHash->begin(); 1532 HashSet<String>::const_iterator end = outerHash->end(); 1533 for (; iter != end; ++iter) { 1534 if (innerHash->contains(*iter)) { 1535 LOG(IconDatabase, "%s is interested in the icon we just read. Adding it to the notification list and removing it from the interested set", urlForLogging(*iter).ascii().data()); 1536 urlsToNotify.add(*iter); 1524 for (auto& outer : *outerHash) { 1525 if (innerHash->contains(outer)) { 1526 LOG(IconDatabase, "%s is interested in the icon we just read. Adding it to the notification list and removing it from the interested set", urlForLogging(outer).ascii().data()); 1527 urlsToNotify.add(outer); 1537 1528 } 1538 1529 … … 1546 1537 m_pageURLsInterestedInIcons.clear(); 1547 1538 else { 1548 iter = urlsToNotify.begin(); 1549 end = urlsToNotify.end(); 1550 for (; iter != end; ++iter) 1551 m_pageURLsInterestedInIcons.remove(*iter); 1539 for (auto& url : urlsToNotify) 1540 m_pageURLsInterestedInIcons.remove(url); 1552 1541 } 1553 1542 } … … 1613 1602 syncTransaction.begin(); 1614 1603 1615 for ( unsigned i = 0; i < iconSnapshots.size(); ++i) {1616 writeIconSnapshotToSQLDatabase( iconSnapshots[i]);1617 LOG(IconDatabase, "Wrote IconRecord for IconURL %s with timeStamp of %i to the DB", urlForLogging( iconSnapshots[i].iconURL()).ascii().data(), iconSnapshots[i].timestamp());1618 } 1619 1620 for ( unsigned i = 0; i < pageSnapshots.size(); ++i) {1604 for (auto& snapshot : iconSnapshots) { 1605 writeIconSnapshotToSQLDatabase(snapshot); 1606 LOG(IconDatabase, "Wrote IconRecord for IconURL %s with timeStamp of %i to the DB", urlForLogging(snapshot.iconURL()).ascii().data(), snapshot.timestamp()); 1607 } 1608 1609 for (auto& snapshot : pageSnapshots) { 1621 1610 // If the icon URL is empty, this page is meant to be deleted 1622 1611 // ASSERTs are sanity checks to make sure the mappings exist if they should and don't if they shouldn't 1623 if ( pageSnapshots[i].iconURL().isEmpty())1624 removePageURLFromSQLDatabase( pageSnapshots[i].pageURL());1612 if (snapshot.iconURL().isEmpty()) 1613 removePageURLFromSQLDatabase(snapshot.pageURL()); 1625 1614 else 1626 setIconURLForPageURLInSQLDatabase( pageSnapshots[i].iconURL(), pageSnapshots[i].pageURL());1627 LOG(IconDatabase, "Committed IconURL for PageURL %s to database", urlForLogging( pageSnapshots[i].pageURL()).ascii().data());1615 setIconURLForPageURLInSQLDatabase(snapshot.iconURL(), snapshot.pageURL()); 1616 LOG(IconDatabase, "Committed IconURL for PageURL %s to database", urlForLogging(snapshot.pageURL()).ascii().data()); 1628 1617 } 1629 1618
Note: See TracChangeset
for help on using the changeset viewer.