| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "platform/network/ResourceTimingInfo.h" | 45 #include "platform/network/ResourceTimingInfo.h" |
| 46 #include "platform/weborigin/KnownPorts.h" | 46 #include "platform/weborigin/KnownPorts.h" |
| 47 #include "platform/weborigin/SecurityOrigin.h" | 47 #include "platform/weborigin/SecurityOrigin.h" |
| 48 #include "platform/weborigin/SecurityPolicy.h" | 48 #include "platform/weborigin/SecurityPolicy.h" |
| 49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 50 #include "public/platform/WebCachePolicy.h" | 50 #include "public/platform/WebCachePolicy.h" |
| 51 #include "public/platform/WebURL.h" | 51 #include "public/platform/WebURL.h" |
| 52 #include "public/platform/WebURLRequest.h" | 52 #include "public/platform/WebURLRequest.h" |
| 53 #include "wtf/text/CString.h" | 53 #include "wtf/text/CString.h" |
| 54 #include "wtf/text/WTFString.h" | 54 #include "wtf/text/WTFString.h" |
| 55 #include <memory> | |
| 56 | 55 |
| 57 using blink::WebURLRequest; | 56 using blink::WebURLRequest; |
| 58 | 57 |
| 59 namespace blink { | 58 namespace blink { |
| 60 | 59 |
| 61 namespace { | 60 namespace { |
| 62 | 61 |
| 63 // Events for UMA. Do not reorder or delete. Add new events at the end, but | 62 // Events for UMA. Do not reorder or delete. Add new events at the end, but |
| 64 // before SriResourceIntegrityMismatchEventCount. | 63 // before SriResourceIntegrityMismatchEventCount. |
| 65 enum SriResourceIntegrityMismatchEvent { | 64 enum SriResourceIntegrityMismatchEvent { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void ResourceFetcher::requestLoadStarted(unsigned long identifier, Resource* res
ource, const FetchRequest& request, ResourceLoadStartType type, bool isStaticDat
a) | 285 void ResourceFetcher::requestLoadStarted(unsigned long identifier, Resource* res
ource, const FetchRequest& request, ResourceLoadStartType type, bool isStaticDat
a) |
| 287 { | 286 { |
| 288 if (type == ResourceLoadingFromCache && resource->getStatus() == Resource::C
ached && !m_validatedURLs.contains(resource->url())) | 287 if (type == ResourceLoadingFromCache && resource->getStatus() == Resource::C
ached && !m_validatedURLs.contains(resource->url())) |
| 289 context().dispatchDidLoadResourceFromMemoryCache(identifier, resource, r
equest.resourceRequest().frameType(), request.resourceRequest().requestContext()
); | 288 context().dispatchDidLoadResourceFromMemoryCache(identifier, resource, r
equest.resourceRequest().frameType(), request.resourceRequest().requestContext()
); |
| 290 | 289 |
| 291 if (isStaticData) | 290 if (isStaticData) |
| 292 return; | 291 return; |
| 293 | 292 |
| 294 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { | 293 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { |
| 295 // Resources loaded from memory cache should be reported the first time
they're used. | 294 // Resources loaded from memory cache should be reported the first time
they're used. |
| 296 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create(re
quest.options().initiatorInfo.name, monotonicallyIncreasingTime(), resource->get
Type() == Resource::MainResource); | 295 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime(), resource->getType() ==
Resource::MainResource); |
| 297 populateResourceTiming(info.get(), resource); | 296 populateResourceTiming(info.get(), resource); |
| 298 info->clearLoadTimings(); | 297 info->clearLoadTimings(); |
| 299 info->setLoadFinishTime(info->initialTime()); | 298 info->setLoadFinishTime(info->initialTime()); |
| 300 m_scheduledResourceTimingReports.append(std::move(info)); | 299 m_scheduledResourceTimingReports.append(std::move(info)); |
| 301 if (!m_resourceTimingReportTimer.isActive()) | 300 if (!m_resourceTimingReportTimer.isActive()) |
| 302 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); | 301 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 303 } | 302 } |
| 304 | 303 |
| 305 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 304 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 306 m_validatedURLs.clear(); | 305 m_validatedURLs.clear(); |
| 307 } | 306 } |
| 308 m_validatedURLs.add(request.resourceRequest().url()); | 307 m_validatedURLs.add(request.resourceRequest().url()); |
| 309 } | 308 } |
| 310 | 309 |
| 311 static std::unique_ptr<TracedValue> urlForTraceEvent(const KURL& url) | 310 static PassOwnPtr<TracedValue> urlForTraceEvent(const KURL& url) |
| 312 { | 311 { |
| 313 std::unique_ptr<TracedValue> value = TracedValue::create(); | 312 OwnPtr<TracedValue> value = TracedValue::create(); |
| 314 value->setString("url", url.getString()); | 313 value->setString("url", url.getString()); |
| 315 return value; | 314 return value; |
| 316 } | 315 } |
| 317 | 316 |
| 318 Resource* ResourceFetcher::resourceForStaticData(const FetchRequest& request, co
nst ResourceFactory& factory, const SubstituteData& substituteData) | 317 Resource* ResourceFetcher::resourceForStaticData(const FetchRequest& request, co
nst ResourceFactory& factory, const SubstituteData& substituteData) |
| 319 { | 318 { |
| 320 const KURL& url = request.resourceRequest().url(); | 319 const KURL& url = request.resourceRequest().url(); |
| 321 ASSERT(url.protocolIsData() || substituteData.isValid() || m_archive); | 320 ASSERT(url.protocolIsData() || substituteData.isValid() || m_archive); |
| 322 | 321 |
| 323 // TODO(japhet): We only send main resource data: urls through WebURLLoader
for the benefit of | 322 // TODO(japhet): We only send main resource data: urls through WebURLLoader
for the benefit of |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 517 |
| 519 if (!startLoad(resource)) | 518 if (!startLoad(resource)) |
| 520 return nullptr; | 519 return nullptr; |
| 521 ASSERT(!resource->errorOccurred() || request.options().synchronousPolicy ==
RequestSynchronously); | 520 ASSERT(!resource->errorOccurred() || request.options().synchronousPolicy ==
RequestSynchronously); |
| 522 return resource; | 521 return resource; |
| 523 } | 522 } |
| 524 | 523 |
| 525 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim
er) | 524 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim
er) |
| 526 { | 525 { |
| 527 ASSERT_UNUSED(timer, timer == &m_resourceTimingReportTimer); | 526 ASSERT_UNUSED(timer, timer == &m_resourceTimingReportTimer); |
| 528 Vector<std::unique_ptr<ResourceTimingInfo>> timingReports; | 527 Vector<OwnPtr<ResourceTimingInfo>> timingReports; |
| 529 timingReports.swap(m_scheduledResourceTimingReports); | 528 timingReports.swap(m_scheduledResourceTimingReports); |
| 530 for (const auto& timingInfo : timingReports) | 529 for (const auto& timingInfo : timingReports) |
| 531 context().addResourceTiming(*timingInfo); | 530 context().addResourceTiming(*timingInfo); |
| 532 } | 531 } |
| 533 | 532 |
| 534 void ResourceFetcher::determineRequestContext(ResourceRequest& request, Resource
::Type type, bool isMainFrame) | 533 void ResourceFetcher::determineRequestContext(ResourceRequest& request, Resource
::Type type, bool isMainFrame) |
| 535 { | 534 { |
| 536 WebURLRequest::RequestContext requestContext = requestContextFromType(isMain
Frame, type); | 535 WebURLRequest::RequestContext requestContext = requestContextFromType(isMain
Frame, type); |
| 537 request.setRequestContext(requestContext); | 536 request.setRequestContext(requestContext); |
| 538 } | 537 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 return resource; | 602 return resource; |
| 604 } | 603 } |
| 605 | 604 |
| 606 void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource
) | 605 void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource
) |
| 607 { | 606 { |
| 608 const AtomicString& fetchInitiator = resource->options().initiatorInfo.name; | 607 const AtomicString& fetchInitiator = resource->options().initiatorInfo.name; |
| 609 if (fetchInitiator == FetchInitiatorTypeNames::internal) | 608 if (fetchInitiator == FetchInitiatorTypeNames::internal) |
| 610 return; | 609 return; |
| 611 | 610 |
| 612 bool isMainResource = resource->getType() == Resource::MainResource; | 611 bool isMainResource = resource->getType() == Resource::MainResource; |
| 613 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create(fetchI
nitiator, monotonicallyIncreasingTime(), isMainResource); | 612 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(fetchInitiator,
monotonicallyIncreasingTime(), isMainResource); |
| 614 | 613 |
| 615 if (resource->isCacheValidator()) { | 614 if (resource->isCacheValidator()) { |
| 616 const AtomicString& timingAllowOrigin = resource->response().httpHeaderF
ield(HTTPNames::Timing_Allow_Origin); | 615 const AtomicString& timingAllowOrigin = resource->response().httpHeaderF
ield(HTTPNames::Timing_Allow_Origin); |
| 617 if (!timingAllowOrigin.isEmpty()) | 616 if (!timingAllowOrigin.isEmpty()) |
| 618 info->setOriginalTimingAllowOrigin(timingAllowOrigin); | 617 info->setOriginalTimingAllowOrigin(timingAllowOrigin); |
| 619 } | 618 } |
| 620 | 619 |
| 621 if (!isMainResource || context().updateTimingInfoForIFrameNavigation(info.ge
t())) | 620 if (!isMainResource || context().updateTimingInfoForIFrameNavigation(info.ge
t())) |
| 622 m_resourceTimingInfoMap.add(resource, std::move(info)); | 621 m_resourceTimingInfoMap.add(resource, std::move(info)); |
| 623 } | 622 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 | 904 |
| 906 // When loading a multipart resource, make the loader non-block when | 905 // When loading a multipart resource, make the loader non-block when |
| 907 // finishing loading the first part. | 906 // finishing loading the first part. |
| 908 if (finishReason == DidFinishFirstPartInMultipart) | 907 if (finishReason == DidFinishFirstPartInMultipart) |
| 909 moveResourceLoaderToNonBlocking(resource->loader()); | 908 moveResourceLoaderToNonBlocking(resource->loader()); |
| 910 else | 909 else |
| 911 removeResourceLoader(resource->loader()); | 910 removeResourceLoader(resource->loader()); |
| 912 DCHECK(!m_loaders.contains(resource->loader())); | 911 DCHECK(!m_loaders.contains(resource->loader())); |
| 913 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader
s.contains(resource->loader())); | 912 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader
s.contains(resource->loader())); |
| 914 | 913 |
| 915 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take(
resource)) { | 914 if (OwnPtr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take(resource)
) { |
| 916 if (resource->response().isHTTP() && resource->response().httpStatusCode
() < 400) { | 915 if (resource->response().isHTTP() && resource->response().httpStatusCode
() < 400) { |
| 917 populateResourceTiming(info.get(), resource); | 916 populateResourceTiming(info.get(), resource); |
| 918 info->setLoadFinishTime(finishTime); | 917 info->setLoadFinishTime(finishTime); |
| 919 if (resource->options().requestInitiatorContext == DocumentContext) | 918 if (resource->options().requestInitiatorContext == DocumentContext) |
| 920 context().addResourceTiming(*info); | 919 context().addResourceTiming(*info); |
| 921 resource->reportResourceTimingToClients(*info); | 920 resource->reportResourceTimingToClients(*info); |
| 922 } | 921 } |
| 923 } | 922 } |
| 924 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); | 923 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); |
| 925 if (finishReason == DidFinishLoading) | 924 if (finishReason == DidFinishLoading) |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 visitor->trace(m_context); | 1260 visitor->trace(m_context); |
| 1262 visitor->trace(m_archive); | 1261 visitor->trace(m_archive); |
| 1263 visitor->trace(m_loaders); | 1262 visitor->trace(m_loaders); |
| 1264 visitor->trace(m_nonBlockingLoaders); | 1263 visitor->trace(m_nonBlockingLoaders); |
| 1265 visitor->trace(m_documentResources); | 1264 visitor->trace(m_documentResources); |
| 1266 visitor->trace(m_preloads); | 1265 visitor->trace(m_preloads); |
| 1267 visitor->trace(m_resourceTimingInfoMap); | 1266 visitor->trace(m_resourceTimingInfoMap); |
| 1268 } | 1267 } |
| 1269 | 1268 |
| 1270 } // namespace blink | 1269 } // namespace blink |
| OLD | NEW |