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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 SharedBuffer* data = archiveResource->data(); | 920 SharedBuffer* data = archiveResource->data(); |
921 if (data) | 921 if (data) |
922 resource->appendData(data->data(), data->size()); | 922 resource->appendData(data->data(), data->size()); |
923 resource->finish(); | 923 resource->finish(); |
924 return true; | 924 return true; |
925 } | 925 } |
926 | 926 |
927 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength) | 927 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength) |
928 { | 928 { |
929 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); | 929 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); |
930 willTerminateResourceLoader(resource->loader()); | 930 // The ResourceLoader might be in |m_nonBlockingLoaders| for multipart respo
nses. |
| 931 ASSERT(!(m_loaders && m_loaders->contains(resource->loader()))); |
931 | 932 |
932 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400) { | 933 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400) { |
933 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); | 934 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); |
934 if (it != m_resourceTimingInfoMap.end()) { | 935 if (it != m_resourceTimingInfoMap.end()) { |
935 OwnPtr<ResourceTimingInfo> info = it->value.release(); | 936 OwnPtr<ResourceTimingInfo> info = it->value.release(); |
936 m_resourceTimingInfoMap.remove(it); | 937 m_resourceTimingInfoMap.remove(it); |
937 populateResourceTiming(info.get(), resource, false); | 938 populateResourceTiming(info.get(), resource, false); |
938 if (resource->options().requestInitiatorContext == DocumentContext) | 939 if (resource->options().requestInitiatorContext == DocumentContext) |
939 context().addResourceTiming(*info); | 940 context().addResourceTiming(*info); |
940 resource->reportResourceTimingToClients(*info); | 941 resource->reportResourceTimingToClients(*info); |
941 } | 942 } |
942 } | 943 } |
943 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); | 944 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); |
944 } | 945 } |
945 | 946 |
946 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
or& error) | 947 void ResourceFetcher::didFailLoading(const Resource* resource, const ResourceErr
or& error) |
947 { | 948 { |
948 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); | 949 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); |
949 willTerminateResourceLoader(resource->loader()); | 950 removeResourceLoader(resource->loader()); |
950 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit
iatorTypeNames::internal; | 951 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit
iatorTypeNames::internal; |
951 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); | 952 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); |
952 } | 953 } |
953 | 954 |
954 void ResourceFetcher::didReceiveResponse(const Resource* resource, const Resourc
eResponse& response) | 955 void ResourceFetcher::didReceiveResponse(const Resource* resource, const Resourc
eResponse& response) |
955 { | 956 { |
956 // If the response is fetched via ServiceWorker, the original URL of the res
ponse could be different from the URL of the request. | 957 // If the response is fetched via ServiceWorker, the original URL of the res
ponse could be different from the URL of the request. |
957 // We check the URL not to load the resources which are forbidden by the pag
e CSP. | 958 // We check the URL not to load the resources which are forbidden by the pag
e CSP. |
958 // https://w3c.github.io/webappsec-csp/#should-block-response | 959 // https://w3c.github.io/webappsec-csp/#should-block-response |
959 if (response.wasFetchedViaServiceWorker()) { | 960 if (response.wasFetchedViaServiceWorker()) { |
(...skipping 16 matching lines...) Expand all Loading... |
976 void ResourceFetcher::didDownloadData(const Resource* resource, int dataLength,
int encodedDataLength) | 977 void ResourceFetcher::didDownloadData(const Resource* resource, int dataLength,
int encodedDataLength) |
977 { | 978 { |
978 context().dispatchDidDownloadData(resource->identifier(), dataLength, encode
dDataLength); | 979 context().dispatchDidDownloadData(resource->identifier(), dataLength, encode
dDataLength); |
979 } | 980 } |
980 | 981 |
981 void ResourceFetcher::acceptDataFromThreadedReceiver(unsigned long identifier, c
onst char* data, int dataLength, int encodedDataLength) | 982 void ResourceFetcher::acceptDataFromThreadedReceiver(unsigned long identifier, c
onst char* data, int dataLength, int encodedDataLength) |
982 { | 983 { |
983 context().dispatchDidReceiveData(identifier, data, dataLength, encodedDataLe
ngth); | 984 context().dispatchDidReceiveData(identifier, data, dataLength, encodedDataLe
ngth); |
984 } | 985 } |
985 | 986 |
986 void ResourceFetcher::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* lo
ader) | 987 void ResourceFetcher::moveResourceLoaderToNonBlocking(ResourceLoader* loader) |
987 { | 988 { |
988 if (!m_nonBlockingLoaders) | 989 if (!m_nonBlockingLoaders) |
989 m_nonBlockingLoaders = ResourceLoaderSet::create(); | 990 m_nonBlockingLoaders = ResourceLoaderSet::create(); |
990 m_nonBlockingLoaders->add(loader); | 991 m_nonBlockingLoaders->add(loader); |
991 m_loaders->remove(loader); | 992 m_loaders->remove(loader); |
992 didLoadResource(loader->cachedResource()); | |
993 } | 993 } |
994 | 994 |
995 void ResourceFetcher::willStartLoadingResource(Resource* resource, ResourceLoade
r* loader, ResourceRequest& request) | 995 void ResourceFetcher::willStartLoadingResource(Resource* resource, ResourceLoade
r* loader, ResourceRequest& request) |
996 { | 996 { |
997 if (loader->cachedResource()->shouldBlockLoadEvent()) { | 997 if (loader->cachedResource()->shouldBlockLoadEvent()) { |
998 if (!m_loaders) | 998 if (!m_loaders) |
999 m_loaders = ResourceLoaderSet::create(); | 999 m_loaders = ResourceLoaderSet::create(); |
1000 m_loaders->add(loader); | 1000 m_loaders->add(loader); |
1001 } else { | 1001 } else { |
1002 if (!m_nonBlockingLoaders) | 1002 if (!m_nonBlockingLoaders) |
1003 m_nonBlockingLoaders = ResourceLoaderSet::create(); | 1003 m_nonBlockingLoaders = ResourceLoaderSet::create(); |
1004 m_nonBlockingLoaders->add(loader); | 1004 m_nonBlockingLoaders->add(loader); |
1005 } | 1005 } |
1006 | 1006 |
1007 context().willStartLoadingResource(request); | 1007 context().willStartLoadingResource(request); |
1008 storeResourceTimingInitiatorInformation(resource); | 1008 storeResourceTimingInitiatorInformation(resource); |
1009 TRACE_EVENT_ASYNC_BEGIN2("blink.net", "Resource", resource, "url", resource-
>url().getString().ascii(), "priority", resource->resourceRequest().priority()); | 1009 TRACE_EVENT_ASYNC_BEGIN2("blink.net", "Resource", resource, "url", resource-
>url().getString().ascii(), "priority", resource->resourceRequest().priority()); |
1010 | 1010 |
1011 context().dispatchWillSendRequest(resource->identifier(), request, ResourceR
esponse(), resource->options().initiatorInfo); | 1011 context().dispatchWillSendRequest(resource->identifier(), request, ResourceR
esponse(), resource->options().initiatorInfo); |
1012 } | 1012 } |
1013 | 1013 |
1014 void ResourceFetcher::willTerminateResourceLoader(ResourceLoader* loader) | 1014 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) |
1015 { | 1015 { |
1016 if (m_loaders && m_loaders->contains(loader)) | 1016 if (m_loaders && m_loaders->contains(loader)) |
1017 m_loaders->remove(loader); | 1017 m_loaders->remove(loader); |
1018 else if (m_nonBlockingLoaders && m_nonBlockingLoaders->contains(loader)) | 1018 else if (m_nonBlockingLoaders && m_nonBlockingLoaders->contains(loader)) |
1019 m_nonBlockingLoaders->remove(loader); | 1019 m_nonBlockingLoaders->remove(loader); |
1020 else | 1020 else |
1021 ASSERT_NOT_REACHED(); | 1021 ASSERT_NOT_REACHED(); |
1022 } | 1022 } |
1023 | 1023 |
1024 void ResourceFetcher::stopFetching() | 1024 void ResourceFetcher::stopFetching() |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 visitor->trace(m_loaders); | 1219 visitor->trace(m_loaders); |
1220 visitor->trace(m_nonBlockingLoaders); | 1220 visitor->trace(m_nonBlockingLoaders); |
1221 #if ENABLE(OILPAN) | 1221 #if ENABLE(OILPAN) |
1222 visitor->trace(m_documentResources); | 1222 visitor->trace(m_documentResources); |
1223 visitor->trace(m_preloads); | 1223 visitor->trace(m_preloads); |
1224 visitor->trace(m_resourceTimingInfoMap); | 1224 visitor->trace(m_resourceTimingInfoMap); |
1225 #endif | 1225 #endif |
1226 } | 1226 } |
1227 | 1227 |
1228 } // namespace blink | 1228 } // namespace blink |
OLD | NEW |