| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 return true; | 249 return true; |
| 250 return request.options().synchronousPolicy == RequestSynchronously && resour
ce->isLoading(); | 250 return request.options().synchronousPolicy == RequestSynchronously && resour
ce->isLoading(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. | 253 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. |
| 254 // http://crbug.com/52411 | 254 // http://crbug.com/52411 |
| 255 static const int kMaxValidatedURLsSize = 10000; | 255 static const int kMaxValidatedURLsSize = 10000; |
| 256 | 256 |
| 257 void ResourceFetcher::requestLoadStarted(Resource* resource, const FetchRequest&
request, ResourceLoadStartType type, bool isStaticData) | 257 void ResourceFetcher::requestLoadStarted(Resource* resource, const FetchRequest&
request, ResourceLoadStartType type, bool isStaticData) |
| 258 { | 258 { |
| 259 if (type == ResourceLoadingFromCache) | 259 if (type == ResourceLoadingFromCache && resource->status() == Resource::Cach
ed && !m_validatedURLs.contains(resource->url())) |
| 260 notifyLoadedFromMemoryCache(resource); | 260 context().dispatchDidLoadResourceFromMemoryCache(resource); |
| 261 | 261 |
| 262 if (isStaticData) | 262 if (isStaticData) |
| 263 return; | 263 return; |
| 264 | 264 |
| 265 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { | 265 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { |
| 266 // Resources loaded from memory cache should be reported the first time
they're used. | 266 // Resources loaded from memory cache should be reported the first time
they're used. |
| 267 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime(), resource->type() == Re
source::MainResource); | 267 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime(), resource->type() == Re
source::MainResource); |
| 268 populateResourceTiming(info.get(), resource, true); | 268 populateResourceTiming(info.get(), resource, true); |
| 269 m_scheduledResourceTimingReports.append(info.release()); | 269 m_scheduledResourceTimingReports.append(info.release()); |
| 270 if (!m_resourceTimingReportTimer.isActive()) | 270 if (!m_resourceTimingReportTimer.isActive()) |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 StringVector resourcesToDelete; | 783 StringVector resourcesToDelete; |
| 784 | 784 |
| 785 for (const auto& documentResource : m_documentResources) { | 785 for (const auto& documentResource : m_documentResources) { |
| 786 if (documentResource.value->hasOneHandle()) | 786 if (documentResource.value->hasOneHandle()) |
| 787 resourcesToDelete.append(documentResource.key); | 787 resourcesToDelete.append(documentResource.key); |
| 788 } | 788 } |
| 789 | 789 |
| 790 m_documentResources.removeAll(resourcesToDelete); | 790 m_documentResources.removeAll(resourcesToDelete); |
| 791 } | 791 } |
| 792 | 792 |
| 793 void ResourceFetcher::notifyLoadedFromMemoryCache(Resource* resource) | |
| 794 { | |
| 795 if (resource->status() != Resource::Cached || m_validatedURLs.contains(resou
rce->url())) | |
| 796 return; | |
| 797 | |
| 798 ResourceRequest request(resource->url()); | |
| 799 unsigned long identifier = createUniqueIdentifier(); | |
| 800 context().dispatchDidLoadResourceFromMemoryCache(request, resource->response
()); | |
| 801 // FIXME: If willSendRequest changes the request, we don't respect it. | |
| 802 willSendRequest(identifier, request, ResourceResponse(), resource->options()
.initiatorInfo); | |
| 803 context().sendRemainingDelegateMessages(identifier, resource->response(), re
source->encodedSize()); | |
| 804 } | |
| 805 | |
| 806 int ResourceFetcher::requestCount() const | 793 int ResourceFetcher::requestCount() const |
| 807 { | 794 { |
| 808 return m_loaders ? m_loaders->size() : 0; | 795 return m_loaders ? m_loaders->size() : 0; |
| 809 } | 796 } |
| 810 | 797 |
| 811 void ResourceFetcher::preloadStarted(Resource* resource) | 798 void ResourceFetcher::preloadStarted(Resource* resource) |
| 812 { | 799 { |
| 813 if (m_preloads && m_preloads->contains(resource)) | 800 if (m_preloads && m_preloads->contains(resource)) |
| 814 return; | 801 return; |
| 815 TRACE_EVENT_ASYNC_STEP_INTO0("blink.net", "Resource", resource, "Preload"); | 802 TRACE_EVENT_ASYNC_STEP_INTO0("blink.net", "Resource", resource, "Preload"); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 visitor->trace(m_archiveResourceCollection); | 1132 visitor->trace(m_archiveResourceCollection); |
| 1146 visitor->trace(m_loaders); | 1133 visitor->trace(m_loaders); |
| 1147 visitor->trace(m_nonBlockingLoaders); | 1134 visitor->trace(m_nonBlockingLoaders); |
| 1148 #if ENABLE(OILPAN) | 1135 #if ENABLE(OILPAN) |
| 1149 visitor->trace(m_preloads); | 1136 visitor->trace(m_preloads); |
| 1150 visitor->trace(m_resourceTimingInfoMap); | 1137 visitor->trace(m_resourceTimingInfoMap); |
| 1151 #endif | 1138 #endif |
| 1152 } | 1139 } |
| 1153 | 1140 |
| 1154 } | 1141 } |
| OLD | NEW |