| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "public/platform/WebURLRequest.h" | 49 #include "public/platform/WebURLRequest.h" |
| 50 #include "wtf/text/CString.h" | 50 #include "wtf/text/CString.h" |
| 51 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
| 52 | 52 |
| 53 #define PRELOAD_DEBUG 0 | 53 #define PRELOAD_DEBUG 0 |
| 54 | 54 |
| 55 using blink::WebURLRequest; | 55 using blink::WebURLRequest; |
| 56 | 56 |
| 57 namespace blink { | 57 namespace blink { |
| 58 | 58 |
| 59 ResourceLoadPriority ResourceFetcher::loadPriority(Resource::Type type, const Fe
tchRequest& request) | 59 ResourceLoadPriority ResourceFetcher::loadPriority(Resource::Type type, const Fe
tchRequest& request, bool isLowPriorityIframe) |
| 60 { | 60 { |
| 61 // TODO(yoav): Change it here so that priority can be changed even after it
was resolved. | 61 // TODO(yoav): Change it here so that priority can be changed even after it
was resolved. |
| 62 if (request.priority() != ResourceLoadPriorityUnresolved) | 62 if (request.priority() != ResourceLoadPriorityUnresolved) |
| 63 return request.priority(); | 63 return request.priority(); |
| 64 | 64 |
| 65 switch (type) { | 65 switch (type) { |
| 66 case Resource::MainResource: | 66 case Resource::MainResource: |
| 67 return ResourceLoadPriorityVeryHigh; | 67 return isLowPriorityIframe ? ResourceLoadPriorityVeryLow : ResourceLoadP
riorityVeryHigh; |
| 68 case Resource::CSSStyleSheet: | 68 case Resource::CSSStyleSheet: |
| 69 return ResourceLoadPriorityHigh; | 69 return ResourceLoadPriorityHigh; |
| 70 case Resource::Raw: | 70 case Resource::Raw: |
| 71 return request.options().synchronousPolicy == RequestSynchronously ? Res
ourceLoadPriorityVeryHigh : ResourceLoadPriorityMedium; | 71 return request.options().synchronousPolicy == RequestSynchronously ? Res
ourceLoadPriorityVeryHigh : ResourceLoadPriorityMedium; |
| 72 case Resource::Script: | 72 case Resource::Script: |
| 73 // Async scripts do not block the parser so they get the lowest priority
and can be | 73 // Async scripts do not block the parser so they get the lowest priority
and can be |
| 74 // loaded in parser order with images. | 74 // loaded in parser order with images. |
| 75 if (FetchRequest::LazyLoad == request.defer()) | 75 if (FetchRequest::LazyLoad == request.defer()) |
| 76 return ResourceLoadPriorityLow; | 76 return ResourceLoadPriorityLow; |
| 77 return ResourceLoadPriorityMedium; | 77 return ResourceLoadPriorityMedium; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return nullptr; | 316 return nullptr; |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (!resource->hasClients()) | 319 if (!resource->hasClients()) |
| 320 m_deadStatsRecorder.update(policy); | 320 m_deadStatsRecorder.update(policy); |
| 321 | 321 |
| 322 if (policy != Use) | 322 if (policy != Use) |
| 323 resource->setIdentifier(createUniqueIdentifier()); | 323 resource->setIdentifier(createUniqueIdentifier()); |
| 324 | 324 |
| 325 if (!request.forPreload() || policy != Use) { | 325 if (!request.forPreload() || policy != Use) { |
| 326 ResourceLoadPriority priority = loadPriority(factory.type(), request); | 326 ResourceLoadPriority priority = loadPriority(factory.type(), request, co
ntext().isLowPriorityIframe()); |
| 327 // When issuing another request for a resource that is already in-flight
make | 327 // When issuing another request for a resource that is already in-flight
make |
| 328 // sure to not demote the priority of the in-flight request. If the new
request | 328 // sure to not demote the priority of the in-flight request. If the new
request |
| 329 // isn't at the same priority as the in-flight request, only allow promo
tions. | 329 // isn't at the same priority as the in-flight request, only allow promo
tions. |
| 330 // This can happen when a visible image's priority is increased and then
another | 330 // This can happen when a visible image's priority is increased and then
another |
| 331 // reference to the image is parsed (which would be at a lower priority)
. | 331 // reference to the image is parsed (which would be at a lower priority)
. |
| 332 if (priority > resource->resourceRequest().priority()) { | 332 if (priority > resource->resourceRequest().priority()) { |
| 333 resource->mutableResourceRequest().setPriority(priority); | 333 resource->mutableResourceRequest().setPriority(priority); |
| 334 resource->didChangePriority(priority, 0); | 334 resource->didChangePriority(priority, 0); |
| 335 } | 335 } |
| 336 } | 336 } |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 | 1052 |
| 1053 DEFINE_TRACE(ResourceFetcher) | 1053 DEFINE_TRACE(ResourceFetcher) |
| 1054 { | 1054 { |
| 1055 visitor->trace(m_context); | 1055 visitor->trace(m_context); |
| 1056 visitor->trace(m_archiveResourceCollection); | 1056 visitor->trace(m_archiveResourceCollection); |
| 1057 visitor->trace(m_loaders); | 1057 visitor->trace(m_loaders); |
| 1058 visitor->trace(m_nonBlockingLoaders); | 1058 visitor->trace(m_nonBlockingLoaders); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 } | 1061 } |
| OLD | NEW |