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