| 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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 847 |
| 848 int ResourceFetcher::requestCount() const | 848 int ResourceFetcher::requestCount() const |
| 849 { | 849 { |
| 850 return m_loaders.size(); | 850 return m_loaders.size(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void ResourceFetcher::preloadStarted(Resource* resource) | 853 void ResourceFetcher::preloadStarted(Resource* resource) |
| 854 { | 854 { |
| 855 if (m_preloads && m_preloads->contains(resource)) | 855 if (m_preloads && m_preloads->contains(resource)) |
| 856 return; | 856 return; |
| 857 TRACE_EVENT_ASYNC_STEP_INTO0("blink.net", "Resource", resource, "Preload"); | 857 TRACE_EVENT_ASYNC_STEP_INTO0("blink.net", "Resource", resource->identifier()
, "Preload"); |
| 858 resource->increasePreloadCount(); | 858 resource->increasePreloadCount(); |
| 859 | 859 |
| 860 if (!m_preloads) | 860 if (!m_preloads) |
| 861 m_preloads = new HeapListHashSet<Member<Resource>>; | 861 m_preloads = new HeapListHashSet<Member<Resource>>; |
| 862 m_preloads->add(resource); | 862 m_preloads->add(resource); |
| 863 } | 863 } |
| 864 | 864 |
| 865 bool ResourceFetcher::isPreloaded(const KURL& url) const | 865 bool ResourceFetcher::isPreloaded(const KURL& url) const |
| 866 { | 866 { |
| 867 if (m_preloads) { | 867 if (m_preloads) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 893 { | 893 { |
| 894 // Only the top-frame can load MHTML. | 894 // Only the top-frame can load MHTML. |
| 895 if (!context().isMainFrame()) | 895 if (!context().isMainFrame()) |
| 896 return nullptr; | 896 return nullptr; |
| 897 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()
); | 897 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()
); |
| 898 return m_archive ? m_archive->mainResource() : nullptr; | 898 return m_archive ? m_archive->mainResource() : nullptr; |
| 899 } | 899 } |
| 900 | 900 |
| 901 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength, DidFinishLoadingReason finishReason) | 901 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength, DidFinishLoadingReason finishReason) |
| 902 { | 902 { |
| 903 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); | 903 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
| 904 DCHECK(resource); | 904 DCHECK(resource); |
| 905 | 905 |
| 906 // When loading a multipart resource, make the loader non-block when | 906 // When loading a multipart resource, make the loader non-block when |
| 907 // finishing loading the first part. | 907 // finishing loading the first part. |
| 908 if (finishReason == DidFinishFirstPartInMultipart) | 908 if (finishReason == DidFinishFirstPartInMultipart) |
| 909 moveResourceLoaderToNonBlocking(resource->loader()); | 909 moveResourceLoaderToNonBlocking(resource->loader()); |
| 910 else | 910 else |
| 911 removeResourceLoader(resource->loader()); | 911 removeResourceLoader(resource->loader()); |
| 912 DCHECK(!m_loaders.contains(resource->loader())); | 912 DCHECK(!m_loaders.contains(resource->loader())); |
| 913 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader
s.contains(resource->loader())); | 913 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader
s.contains(resource->loader())); |
| 914 | 914 |
| 915 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take(
resource)) { | 915 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take(
resource)) { |
| 916 if (resource->response().isHTTP() && resource->response().httpStatusCode
() < 400) { | 916 if (resource->response().isHTTP() && resource->response().httpStatusCode
() < 400) { |
| 917 populateResourceTiming(info.get(), resource); | 917 populateResourceTiming(info.get(), resource); |
| 918 info->setLoadFinishTime(finishTime); | 918 info->setLoadFinishTime(finishTime); |
| 919 if (resource->options().requestInitiatorContext == DocumentContext) | 919 if (resource->options().requestInitiatorContext == DocumentContext) |
| 920 context().addResourceTiming(*info); | 920 context().addResourceTiming(*info); |
| 921 resource->reportResourceTimingToClients(*info); | 921 resource->reportResourceTimingToClients(*info); |
| 922 } | 922 } |
| 923 } | 923 } |
| 924 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); | 924 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); |
| 925 if (finishReason == DidFinishLoading) | 925 if (finishReason == DidFinishLoading) |
| 926 resource->finish(finishTime); | 926 resource->finish(finishTime); |
| 927 context().didLoadResource(resource); | 927 context().didLoadResource(resource); |
| 928 } | 928 } |
| 929 | 929 |
| 930 void ResourceFetcher::didFailLoading(Resource* resource, const ResourceError& er
ror) | 930 void ResourceFetcher::didFailLoading(Resource* resource, const ResourceError& er
ror) |
| 931 { | 931 { |
| 932 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); | 932 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
| 933 removeResourceLoader(resource->loader()); | 933 removeResourceLoader(resource->loader()); |
| 934 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); | 934 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); |
| 935 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit
iatorTypeNames::internal; | 935 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit
iatorTypeNames::internal; |
| 936 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); | 936 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); |
| 937 resource->error(error); | 937 resource->error(error); |
| 938 context().didLoadResource(resource); | 938 context().didLoadResource(resource); |
| 939 } | 939 } |
| 940 | 940 |
| 941 void ResourceFetcher::didReceiveResponse(Resource* resource, const ResourceRespo
nse& response) | 941 void ResourceFetcher::didReceiveResponse(Resource* resource, const ResourceRespo
nse& response) |
| 942 { | 942 { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 Resource* resource = documentResource.value.get(); | 1075 Resource* resource = documentResource.value.get(); |
| 1076 if (!resource || !resource->isImage() || !resource->isLoading()) | 1076 if (!resource || !resource->isImage() || !resource->isLoading()) |
| 1077 continue; | 1077 continue; |
| 1078 | 1078 |
| 1079 ResourcePriority resourcePriority = resource->priorityFromObservers(); | 1079 ResourcePriority resourcePriority = resource->priorityFromObservers(); |
| 1080 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image
, FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior
ity.visibility); | 1080 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image
, FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior
ity.visibility); |
| 1081 if (resourceLoadPriority == resource->resourceRequest().priority()) | 1081 if (resourceLoadPriority == resource->resourceRequest().priority()) |
| 1082 continue; | 1082 continue; |
| 1083 | 1083 |
| 1084 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra
PriorityValue); | 1084 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra
PriorityValue); |
| 1085 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP
riority", "priority", resourceLoadPriority); | 1085 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource->identifi
er(), "ChangePriority", "priority", resourceLoadPriority); |
| 1086 context().dispatchDidChangeResourcePriority(resource->identifier(), reso
urceLoadPriority, resourcePriority.intraPriorityValue); | 1086 context().dispatchDidChangeResourcePriority(resource->identifier(), reso
urceLoadPriority, resourcePriority.intraPriorityValue); |
| 1087 } | 1087 } |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 void ResourceFetcher::reloadLoFiImages() | 1090 void ResourceFetcher::reloadLoFiImages() |
| 1091 { | 1091 { |
| 1092 for (const auto& documentResource : m_documentResources) { | 1092 for (const auto& documentResource : m_documentResources) { |
| 1093 Resource* resource = documentResource.value.get(); | 1093 Resource* resource = documentResource.value.get(); |
| 1094 if (resource && resource->isImage()) { | 1094 if (resource && resource->isImage()) { |
| 1095 ImageResource* imageResource = toImageResource(resource); | 1095 ImageResource* imageResource = toImageResource(resource); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 visitor->trace(m_context); | 1261 visitor->trace(m_context); |
| 1262 visitor->trace(m_archive); | 1262 visitor->trace(m_archive); |
| 1263 visitor->trace(m_loaders); | 1263 visitor->trace(m_loaders); |
| 1264 visitor->trace(m_nonBlockingLoaders); | 1264 visitor->trace(m_nonBlockingLoaders); |
| 1265 visitor->trace(m_documentResources); | 1265 visitor->trace(m_documentResources); |
| 1266 visitor->trace(m_preloads); | 1266 visitor->trace(m_preloads); |
| 1267 visitor->trace(m_resourceTimingInfoMap); | 1267 visitor->trace(m_resourceTimingInfoMap); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 } // namespace blink | 1270 } // namespace blink |
| OLD | NEW |