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 | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 rights reserved. | 6 rights reserved. |
| 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "core/fetch/MemoryCache.h" | 35 #include "core/fetch/MemoryCache.h" |
| 36 #include "core/fetch/ResourceLoader.h" | 36 #include "core/fetch/ResourceLoader.h" |
| 37 #include "core/fetch/ResourceLoadingLog.h" | 37 #include "core/fetch/ResourceLoadingLog.h" |
| 38 #include "core/fetch/UniqueIdentifier.h" | 38 #include "core/fetch/UniqueIdentifier.h" |
| 39 #include "platform/Histogram.h" | 39 #include "platform/Histogram.h" |
| 40 #include "platform/RuntimeEnabledFeatures.h" | 40 #include "platform/RuntimeEnabledFeatures.h" |
| 41 #include "platform/mhtml/ArchiveResource.h" | 41 #include "platform/mhtml/ArchiveResource.h" |
| 42 #include "platform/mhtml/MHTMLArchive.h" | 42 #include "platform/mhtml/MHTMLArchive.h" |
| 43 #include "platform/network/NetworkUtils.h" | 43 #include "platform/network/NetworkUtils.h" |
| 44 #include "platform/network/ResourceTimingInfo.h" | 44 #include "platform/network/ResourceTimingInfo.h" |
| 45 #include "platform/tracing/NetworkInstrumentation.h" | |
| 45 #include "platform/tracing/TraceEvent.h" | 46 #include "platform/tracing/TraceEvent.h" |
| 46 #include "platform/tracing/TracedValue.h" | 47 #include "platform/tracing/TracedValue.h" |
| 47 #include "platform/weborigin/KnownPorts.h" | 48 #include "platform/weborigin/KnownPorts.h" |
| 48 #include "platform/weborigin/SecurityOrigin.h" | 49 #include "platform/weborigin/SecurityOrigin.h" |
| 49 #include "platform/weborigin/SecurityPolicy.h" | 50 #include "platform/weborigin/SecurityPolicy.h" |
| 50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
| 51 #include "public/platform/WebCachePolicy.h" | 52 #include "public/platform/WebCachePolicy.h" |
| 52 #include "public/platform/WebURL.h" | 53 #include "public/platform/WebURL.h" |
| 53 #include "public/platform/WebURLRequest.h" | 54 #include "public/platform/WebURLRequest.h" |
| 54 #include "wtf/text/CString.h" | 55 #include "wtf/text/CString.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 factory.type() == Resource::XSLStyleSheet); | 491 factory.type() == Resource::XSLStyleSheet); |
| 491 | 492 |
| 492 context().populateRequestData(request.mutableResourceRequest()); | 493 context().populateRequestData(request.mutableResourceRequest()); |
| 493 if (request.resourceRequest().httpHeaderField("Upgrade-Insecure-Requests") != | 494 if (request.resourceRequest().httpHeaderField("Upgrade-Insecure-Requests") != |
| 494 AtomicString("1")) { | 495 AtomicString("1")) { |
| 495 context().modifyRequestForCSP(request.mutableResourceRequest()); | 496 context().modifyRequestForCSP(request.mutableResourceRequest()); |
| 496 } | 497 } |
| 497 context().addClientHintsIfNecessary(request); | 498 context().addClientHintsIfNecessary(request); |
| 498 context().addCSPHeaderIfNecessary(factory.type(), request); | 499 context().addCSPHeaderIfNecessary(factory.type(), request); |
| 499 | 500 |
| 500 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", | 501 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", |
|
chiniforooshan
2016/10/24 19:25:36
Please create a bug and add a TODO here, referenci
dproy
2016/11/03 15:13:37
Done.
| |
| 501 urlForTraceEvent(request.url())); | 502 urlForTraceEvent(request.url())); |
| 502 | 503 |
| 503 if (!request.url().isValid()) | 504 if (!request.url().isValid()) |
| 504 return nullptr; | 505 return nullptr; |
| 505 | 506 |
| 506 unsigned long identifier = createUniqueIdentifier(); | 507 unsigned long identifier = createUniqueIdentifier(); |
| 508 network_instrumentation::beginResourceLoad( | |
| 509 identifier, request.url().getString().utf8().data()); | |
|
chiniforooshan
2016/10/24 19:25:36
Do you think we can move this (and the line before
caseq
2016/10/24 22:47:46
Do we really need it in the same place? I think it
Yoav Weiss
2016/10/25 04:46:46
I think it's important to be able to instrument th
chiniforooshan
2016/10/25 18:00:40
Good point about terminating the event! Can we dea
dproy
2016/11/03 15:13:37
I added a scoped tracker. Does the overhead look r
| |
| 507 request.mutableResourceRequest().setPriority(computeLoadPriority( | 510 request.mutableResourceRequest().setPriority(computeLoadPriority( |
| 508 factory.type(), request, ResourcePriority::NotVisible)); | 511 factory.type(), request, ResourcePriority::NotVisible)); |
| 509 initializeResourceRequest(request.mutableResourceRequest(), factory.type(), | 512 initializeResourceRequest(request.mutableResourceRequest(), factory.type(), |
| 510 request.defer()); | 513 request.defer()); |
| 511 | 514 |
| 512 if (!context().canRequest( | 515 if (!context().canRequest( |
| 513 factory.type(), request.resourceRequest(), | 516 factory.type(), request.resourceRequest(), |
| 514 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), | 517 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), |
| 515 request.options(), request.forPreload(), | 518 request.options(), request.forPreload(), |
| 516 request.getOriginRestriction())) { | 519 request.getOriginRestriction())) { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1112 return nullptr; | 1115 return nullptr; |
| 1113 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); | 1116 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); |
| 1114 return m_archive ? m_archive->mainResource() : nullptr; | 1117 return m_archive ? m_archive->mainResource() : nullptr; |
| 1115 } | 1118 } |
| 1116 | 1119 |
| 1117 void ResourceFetcher::didFinishLoading(Resource* resource, | 1120 void ResourceFetcher::didFinishLoading(Resource* resource, |
| 1118 double finishTime, | 1121 double finishTime, |
| 1119 int64_t encodedDataLength, | 1122 int64_t encodedDataLength, |
| 1120 DidFinishLoadingReason finishReason) { | 1123 DidFinishLoadingReason finishReason) { |
| 1121 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); | 1124 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
| 1125 network_instrumentation::endResourceLoad(resource->identifier()); | |
| 1122 DCHECK(resource); | 1126 DCHECK(resource); |
| 1123 | 1127 |
| 1124 // When loading a multipart resource, make the loader non-block when finishing | 1128 // When loading a multipart resource, make the loader non-block when finishing |
| 1125 // loading the first part. | 1129 // loading the first part. |
| 1126 if (finishReason == DidFinishFirstPartInMultipart) | 1130 if (finishReason == DidFinishFirstPartInMultipart) |
| 1127 moveResourceLoaderToNonBlocking(resource->loader()); | 1131 moveResourceLoaderToNonBlocking(resource->loader()); |
| 1128 else | 1132 else |
| 1129 removeResourceLoader(resource->loader()); | 1133 removeResourceLoader(resource->loader()); |
| 1130 DCHECK(!m_loaders.contains(resource->loader())); | 1134 DCHECK(!m_loaders.contains(resource->loader())); |
| 1131 DCHECK(finishReason == DidFinishFirstPartInMultipart || | 1135 DCHECK(finishReason == DidFinishFirstPartInMultipart || |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1162 context().dispatchDidFinishLoading(resource->identifier(), finishTime, | 1166 context().dispatchDidFinishLoading(resource->identifier(), finishTime, |
| 1163 encodedDataLength); | 1167 encodedDataLength); |
| 1164 if (finishReason == DidFinishLoading) | 1168 if (finishReason == DidFinishLoading) |
| 1165 resource->finish(finishTime); | 1169 resource->finish(finishTime); |
| 1166 context().didLoadResource(resource); | 1170 context().didLoadResource(resource); |
| 1167 } | 1171 } |
| 1168 | 1172 |
| 1169 void ResourceFetcher::didFailLoading(Resource* resource, | 1173 void ResourceFetcher::didFailLoading(Resource* resource, |
| 1170 const ResourceError& error) { | 1174 const ResourceError& error) { |
| 1171 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); | 1175 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
| 1176 network_instrumentation::endResourceLoad(resource->identifier()); | |
|
caseq
2016/10/24 22:47:46
let's also pass success / fail flag down to the in
dproy
2016/11/03 15:13:37
Done.
| |
| 1172 removeResourceLoader(resource->loader()); | 1177 removeResourceLoader(resource->loader()); |
| 1173 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); | 1178 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); |
| 1174 bool isInternalRequest = resource->options().initiatorInfo.name == | 1179 bool isInternalRequest = resource->options().initiatorInfo.name == |
| 1175 FetchInitiatorTypeNames::internal; | 1180 FetchInitiatorTypeNames::internal; |
| 1176 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); | 1181 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); |
| 1177 resource->error(error); | 1182 resource->error(error); |
| 1178 context().didLoadResource(resource); | 1183 context().didLoadResource(resource); |
| 1179 } | 1184 } |
| 1180 | 1185 |
| 1181 void ResourceFetcher::didReceiveResponse(Resource* resource, | 1186 void ResourceFetcher::didReceiveResponse(Resource* resource, |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 visitor->trace(m_context); | 1617 visitor->trace(m_context); |
| 1613 visitor->trace(m_archive); | 1618 visitor->trace(m_archive); |
| 1614 visitor->trace(m_loaders); | 1619 visitor->trace(m_loaders); |
| 1615 visitor->trace(m_nonBlockingLoaders); | 1620 visitor->trace(m_nonBlockingLoaders); |
| 1616 visitor->trace(m_documentResources); | 1621 visitor->trace(m_documentResources); |
| 1617 visitor->trace(m_preloads); | 1622 visitor->trace(m_preloads); |
| 1618 visitor->trace(m_resourceTimingInfoMap); | 1623 visitor->trace(m_resourceTimingInfoMap); |
| 1619 } | 1624 } |
| 1620 | 1625 |
| 1621 } // namespace blink | 1626 } // namespace blink |
| OLD | NEW |