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 403 matching lines...) Loading... |
414 | 414 |
415 if (request.forPreload()) { | 415 if (request.forPreload()) { |
416 DEFINE_RESOURCE_HISTOGRAM("Preload."); | 416 DEFINE_RESOURCE_HISTOGRAM("Preload."); |
417 } else { | 417 } else { |
418 DEFINE_RESOURCE_HISTOGRAM(""); | 418 DEFINE_RESOURCE_HISTOGRAM(""); |
419 } | 419 } |
420 // Aims to count Resource only referenced from MemoryCache (i.e. what | 420 // Aims to count Resource only referenced from MemoryCache (i.e. what |
421 // would be dead if MemoryCache holds weak references to Resource). | 421 // would be dead if MemoryCache holds weak references to Resource). |
422 // Currently we check references to Resource from ResourceClient and | 422 // Currently we check references to Resource from ResourceClient and |
423 // |m_preloads| only, because they are major sources of references. | 423 // |m_preloads| only, because they are major sources of references. |
424 if (resource && !resource->hasClients() && (!m_preloads || !m_preloads->cont
ains(resource)) && !isStaticData) { | 424 if (resource && !resource->hasClientsOrObservers() && (!m_preloads || !m_pre
loads->contains(resource)) && !isStaticData) { |
425 DEFINE_RESOURCE_HISTOGRAM("Dead."); | 425 DEFINE_RESOURCE_HISTOGRAM("Dead."); |
426 } | 426 } |
427 | 427 |
428 switch (policy) { | 428 switch (policy) { |
429 case Reload: | 429 case Reload: |
430 memoryCache()->remove(resource.get()); | 430 memoryCache()->remove(resource.get()); |
431 // Fall through | 431 // Fall through |
432 case Load: | 432 case Load: |
433 resource = createResourceForLoading(request, request.charset(), factory)
; | 433 resource = createResourceForLoading(request, request.charset(), factory)
; |
434 break; | 434 break; |
435 case Revalidate: | 435 case Revalidate: |
436 initializeRevalidation(request, resource.get()); | 436 initializeRevalidation(request, resource.get()); |
437 break; | 437 break; |
438 case Use: | 438 case Use: |
439 memoryCache()->updateForAccess(resource.get()); | 439 memoryCache()->updateForAccess(resource.get()); |
440 break; | 440 break; |
441 } | 441 } |
442 | 442 |
443 if (!resource) | 443 if (!resource) |
444 return nullptr; | 444 return nullptr; |
445 if (resource->getType() != factory.type()) { | 445 if (resource->getType() != factory.type()) { |
446 ASSERT(request.forPreload()); | 446 ASSERT(request.forPreload()); |
447 return nullptr; | 447 return nullptr; |
448 } | 448 } |
449 | 449 |
450 if (!resource->hasClients()) | 450 if (!resource->hasClientsOrObservers()) |
451 m_deadStatsRecorder.update(policy); | 451 m_deadStatsRecorder.update(policy); |
452 | 452 |
453 if (policy != Use) | 453 if (policy != Use) |
454 resource->setIdentifier(createUniqueIdentifier()); | 454 resource->setIdentifier(createUniqueIdentifier()); |
455 | 455 |
456 if (!request.forPreload() || policy != Use) { | 456 if (!request.forPreload() || policy != Use) { |
457 ResourceLoadPriority priority = loadPriority(factory.type(), request, Re
sourcePriority::NotVisible); | 457 ResourceLoadPriority priority = loadPriority(factory.type(), request, Re
sourcePriority::NotVisible); |
458 // When issuing another request for a resource that is already in-flight
make | 458 // When issuing another request for a resource that is already in-flight
make |
459 // sure to not demote the priority of the in-flight request. If the new
request | 459 // sure to not demote the priority of the in-flight request. If the new
request |
460 // isn't at the same priority as the in-flight request, only allow promo
tions. | 460 // isn't at the same priority as the in-flight request, only allow promo
tions. |
(...skipping 617 matching lines...) Loading... |
1078 return; | 1078 return; |
1079 | 1079 |
1080 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource
Priorities"); | 1080 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource
Priorities"); |
1081 for (const auto& loader : m_loaders->hashSet()) { | 1081 for (const auto& loader : m_loaders->hashSet()) { |
1082 ASSERT(loader); | 1082 ASSERT(loader); |
1083 Resource* resource = loader->cachedResource(); | 1083 Resource* resource = loader->cachedResource(); |
1084 ASSERT(resource); | 1084 ASSERT(resource); |
1085 if (!resource->isImage()) | 1085 if (!resource->isImage()) |
1086 continue; | 1086 continue; |
1087 | 1087 |
1088 ResourcePriority resourcePriority = resource->priorityFromClients(); | 1088 ResourcePriority resourcePriority = resource->priorityFromObservers(); |
1089 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image
, FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior
ity.visibility); | 1089 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image
, FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior
ity.visibility); |
1090 if (resourceLoadPriority == resource->resourceRequest().priority()) | 1090 if (resourceLoadPriority == resource->resourceRequest().priority()) |
1091 continue; | 1091 continue; |
1092 | 1092 |
1093 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra
PriorityValue); | 1093 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra
PriorityValue); |
1094 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP
riority", "priority", resourceLoadPriority); | 1094 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP
riority", "priority", resourceLoadPriority); |
1095 context().dispatchDidChangeResourcePriority(resource->identifier(), reso
urceLoadPriority, resourcePriority.intraPriorityValue); | 1095 context().dispatchDidChangeResourcePriority(resource->identifier(), reso
urceLoadPriority, resourcePriority.intraPriorityValue); |
1096 } | 1096 } |
1097 } | 1097 } |
1098 | 1098 |
(...skipping 111 matching lines...) Loading... |
1210 visitor->trace(m_loaders); | 1210 visitor->trace(m_loaders); |
1211 visitor->trace(m_nonBlockingLoaders); | 1211 visitor->trace(m_nonBlockingLoaders); |
1212 #if ENABLE(OILPAN) | 1212 #if ENABLE(OILPAN) |
1213 visitor->trace(m_documentResources); | 1213 visitor->trace(m_documentResources); |
1214 visitor->trace(m_preloads); | 1214 visitor->trace(m_preloads); |
1215 visitor->trace(m_resourceTimingInfoMap); | 1215 visitor->trace(m_resourceTimingInfoMap); |
1216 #endif | 1216 #endif |
1217 } | 1217 } |
1218 | 1218 |
1219 } // namespace blink | 1219 } // namespace blink |
OLD | NEW |