Chromium Code Reviews| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 ASSERT_NOT_REACHED(); | 218 ASSERT_NOT_REACHED(); |
| 219 return ResourceRequest::TargetIsSubresource; | 219 return ResourceRequest::TargetIsSubresource; |
| 220 } | 220 } |
| 221 | 221 |
| 222 ResourceFetcher::ResourceFetcher(DocumentLoader* documentLoader) | 222 ResourceFetcher::ResourceFetcher(DocumentLoader* documentLoader) |
| 223 : m_document(0) | 223 : m_document(0) |
| 224 , m_documentLoader(documentLoader) | 224 , m_documentLoader(documentLoader) |
| 225 , m_requestCount(0) | 225 , m_requestCount(0) |
| 226 , m_garbageCollectDocumentResourcesTimer(this, &ResourceFetcher::garbageColl ectDocumentResourcesTimerFired) | 226 , m_garbageCollectDocumentResourcesTimer(this, &ResourceFetcher::garbageColl ectDocumentResourcesTimerFired) |
| 227 , m_resourceTimingReportTimer(this, &ResourceFetcher::resourceTimingReportTi merFired) | 227 , m_resourceTimingReportTimer(this, &ResourceFetcher::resourceTimingReportTi merFired) |
| 228 , m_useCount(0) | |
| 229 , m_revalidateCount(0) | |
| 230 , m_loadCount(0) | |
| 228 , m_autoLoadImages(true) | 231 , m_autoLoadImages(true) |
| 229 , m_imagesEnabled(true) | 232 , m_imagesEnabled(true) |
| 230 , m_allowStaleResources(false) | 233 , m_allowStaleResources(false) |
| 231 { | 234 { |
| 232 } | 235 } |
| 233 | 236 |
| 234 ResourceFetcher::~ResourceFetcher() | 237 ResourceFetcher::~ResourceFetcher() |
| 235 { | 238 { |
| 236 m_documentLoader = 0; | 239 m_documentLoader = 0; |
| 237 m_document = 0; | 240 m_document = 0; |
| 238 | 241 |
| 239 clearPreloads(); | 242 clearPreloads(); |
| 240 | 243 |
| 244 blink::Platform::current()->histogramCustomCounts( | |
| 245 "WebCore.ResourceFetcher.HitCount", m_useCount, 0, 1000, 50); | |
| 246 blink::Platform::current()->histogramCustomCounts( | |
| 247 "WebCore.ResourceFetcher.RevalidateCount", m_revalidateCount, 0, 1000, 5 0); | |
| 248 blink::Platform::current()->histogramCustomCounts( | |
| 249 "WebCore.ResourceFetcher.LoadCount", m_loadCount, 0, 1000, 50); | |
| 250 | |
| 241 // Make sure no requests still point to this ResourceFetcher | 251 // Make sure no requests still point to this ResourceFetcher |
| 242 ASSERT(!m_requestCount); | 252 ASSERT(!m_requestCount); |
| 243 } | 253 } |
| 244 | 254 |
| 245 Resource* ResourceFetcher::cachedResource(const KURL& resourceURL) const | 255 Resource* ResourceFetcher::cachedResource(const KURL& resourceURL) const |
| 246 { | 256 { |
| 247 KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL); | 257 KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL); |
| 248 return m_documentResources.get(url).get(); | 258 return m_documentResources.get(url).get(); |
| 249 } | 259 } |
| 250 | 260 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 // See if we can use an existing resource from the cache. | 632 // See if we can use an existing resource from the cache. |
| 623 ResourcePtr<Resource> resource = memoryCache()->resourceForURL(url); | 633 ResourcePtr<Resource> resource = memoryCache()->resourceForURL(url); |
| 624 | 634 |
| 625 const RevalidationPolicy policy = determineRevalidationPolicy(type, request. mutableResourceRequest(), request.forPreload(), resource.get(), request.defer()) ; | 635 const RevalidationPolicy policy = determineRevalidationPolicy(type, request. mutableResourceRequest(), request.forPreload(), resource.get(), request.defer()) ; |
| 626 switch (policy) { | 636 switch (policy) { |
| 627 case Reload: | 637 case Reload: |
| 628 memoryCache()->remove(resource.get()); | 638 memoryCache()->remove(resource.get()); |
| 629 // Fall through | 639 // Fall through |
| 630 case Load: | 640 case Load: |
| 631 resource = loadResource(type, request, request.charset()); | 641 resource = loadResource(type, request, request.charset()); |
| 642 ++m_loadCount; | |
|
Nate Chapin
2014/01/28 20:22:54
Would it be cleaner to wrap these variables up int
clamy
2014/01/29 12:19:21
Done.
| |
| 632 break; | 643 break; |
| 633 case Revalidate: | 644 case Revalidate: |
| 634 resource = revalidateResource(request, resource.get()); | 645 resource = revalidateResource(request, resource.get()); |
| 646 if (!resource->hasClients()) | |
| 647 ++m_revalidateCount; | |
| 635 break; | 648 break; |
| 636 case Use: | 649 case Use: |
| 637 resource->updateForAccess(); | 650 resource->updateForAccess(); |
| 638 notifyLoadedFromMemoryCache(resource.get()); | 651 notifyLoadedFromMemoryCache(resource.get()); |
| 652 if (!resource->hasClients()) | |
| 653 ++m_useCount; | |
| 639 break; | 654 break; |
| 640 } | 655 } |
| 641 | 656 |
| 642 if (!resource) | 657 if (!resource) |
| 643 return 0; | 658 return 0; |
| 644 | 659 |
| 645 if (policy != Use) | 660 if (policy != Use) |
| 646 resource->setIdentifier(createUniqueIdentifier()); | 661 resource->setIdentifier(createUniqueIdentifier()); |
| 647 | 662 |
| 648 if (!request.forPreload() || policy != Use) { | 663 if (!request.forPreload() || policy != Use) { |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1370 } | 1385 } |
| 1371 #endif | 1386 #endif |
| 1372 | 1387 |
| 1373 const ResourceLoaderOptions& ResourceFetcher::defaultResourceOptions() | 1388 const ResourceLoaderOptions& ResourceFetcher::defaultResourceOptions() |
| 1374 { | 1389 { |
| 1375 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SniffContent, BufferDat a, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCr edentials, DoSecurityCheck, CheckContentSecurityPolicy, DocumentContext)); | 1390 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SniffContent, BufferDat a, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCr edentials, DoSecurityCheck, CheckContentSecurityPolicy, DocumentContext)); |
| 1376 return options; | 1391 return options; |
| 1377 } | 1392 } |
| 1378 | 1393 |
| 1379 } | 1394 } |
| OLD | NEW |