| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void ResourceFetcher::requestLoadStarted(Resource* resource, const FetchRequest&
request, ResourceLoadStartType type) | 230 void ResourceFetcher::requestLoadStarted(Resource* resource, const FetchRequest&
request, ResourceLoadStartType type) |
| 231 { | 231 { |
| 232 if (type == ResourceLoadingFromCache) | 232 if (type == ResourceLoadingFromCache) |
| 233 notifyLoadedFromMemoryCache(resource); | 233 notifyLoadedFromMemoryCache(resource); |
| 234 | 234 |
| 235 if (request.resourceRequest().url().protocolIsData() || context().hasSubstit
uteData()) | 235 if (request.resourceRequest().url().protocolIsData() || context().hasSubstit
uteData()) |
| 236 return; | 236 return; |
| 237 | 237 |
| 238 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { | 238 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && !m_va
lidatedURLs.contains(request.resourceRequest().url())) { |
| 239 // Resources loaded from memory cache should be reported the first time
they're used. | 239 // Resources loaded from memory cache should be reported the first time
they're used. |
| 240 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime()); | 240 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(request.opt
ions().initiatorInfo.name, monotonicallyIncreasingTime(), resource->type() == Re
source::MainResource); |
| 241 populateResourceTiming(info.get(), resource, true); | 241 populateResourceTiming(info.get(), resource, true); |
| 242 m_scheduledResourceTimingReports.add(info, resource->type() == Resource:
:MainResource); | 242 m_scheduledResourceTimingReports.append(info.release()); |
| 243 if (!m_resourceTimingReportTimer.isActive()) | 243 if (!m_resourceTimingReportTimer.isActive()) |
| 244 m_resourceTimingReportTimer.startOneShot(0, FROM_HERE); | 244 m_resourceTimingReportTimer.startOneShot(0, FROM_HERE); |
| 245 } | 245 } |
| 246 | 246 |
| 247 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 247 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 248 m_validatedURLs.clear(); | 248 m_validatedURLs.clear(); |
| 249 } | 249 } |
| 250 m_validatedURLs.add(request.resourceRequest().url()); | 250 m_validatedURLs.add(request.resourceRequest().url()); |
| 251 } | 251 } |
| 252 | 252 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF
romCache : ResourceLoadingFromNetwork); | 372 requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingF
romCache : ResourceLoadingFromNetwork); |
| 373 | 373 |
| 374 ASSERT(resource->url() == url.string()); | 374 ASSERT(resource->url() == url.string()); |
| 375 m_documentResources.set(resource->url(), resource); | 375 m_documentResources.set(resource->url(), resource); |
| 376 return resource; | 376 return resource; |
| 377 } | 377 } |
| 378 | 378 |
| 379 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim
er) | 379 void ResourceFetcher::resourceTimingReportTimerFired(Timer<ResourceFetcher>* tim
er) |
| 380 { | 380 { |
| 381 ASSERT_UNUSED(timer, timer == &m_resourceTimingReportTimer); | 381 ASSERT_UNUSED(timer, timer == &m_resourceTimingReportTimer); |
| 382 HashMap<RefPtr<ResourceTimingInfo>, bool> timingReports; | 382 Vector<OwnPtr<ResourceTimingInfo>> timingReports; |
| 383 timingReports.swap(m_scheduledResourceTimingReports); | 383 timingReports.swap(m_scheduledResourceTimingReports); |
| 384 for (const auto& timingInfo : timingReports) | 384 for (const auto& timingInfo : timingReports) |
| 385 context().addResourceTiming(timingInfo.key.get(), timingInfo.value); | 385 context().addResourceTiming(*timingInfo); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void ResourceFetcher::determineRequestContext(ResourceRequest& request, Resource
::Type type) | 388 void ResourceFetcher::determineRequestContext(ResourceRequest& request, Resource
::Type type) |
| 389 { | 389 { |
| 390 WebURLRequest::RequestContext requestContext = requestContextFromType(contex
t().isMainFrame(), type); | 390 WebURLRequest::RequestContext requestContext = requestContextFromType(contex
t().isMainFrame(), type); |
| 391 request.setRequestContext(requestContext); | 391 request.setRequestContext(requestContext); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void ResourceFetcher::addAdditionalRequestHeaders(ResourceRequest& request, Reso
urce::Type type) | 394 void ResourceFetcher::addAdditionalRequestHeaders(ResourceRequest& request, Reso
urce::Type type) |
| 395 { | 395 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 return resource; | 459 return resource; |
| 460 } | 460 } |
| 461 | 461 |
| 462 void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource
) | 462 void ResourceFetcher::storeResourceTimingInitiatorInformation(Resource* resource
) |
| 463 { | 463 { |
| 464 if (resource->options().requestInitiatorContext != DocumentContext) | 464 if (resource->options().requestInitiatorContext != DocumentContext) |
| 465 return; | 465 return; |
| 466 if (resource->options().initiatorInfo.name == FetchInitiatorTypeNames::inter
nal) | 466 if (resource->options().initiatorInfo.name == FetchInitiatorTypeNames::inter
nal) |
| 467 return; | 467 return; |
| 468 | 468 |
| 469 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(resource->optio
ns().initiatorInfo.name, monotonicallyIncreasingTime()); | 469 OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(resource->optio
ns().initiatorInfo.name, monotonicallyIncreasingTime(), resource->type() == Reso
urce::MainResource); |
| 470 | 470 |
| 471 if (resource->isCacheValidator()) { | 471 if (resource->isCacheValidator()) { |
| 472 const AtomicString& timingAllowOrigin = resource->resourceToRevalidate()
->response().httpHeaderField("Timing-Allow-Origin"); | 472 const AtomicString& timingAllowOrigin = resource->resourceToRevalidate()
->response().httpHeaderField("Timing-Allow-Origin"); |
| 473 if (!timingAllowOrigin.isEmpty()) | 473 if (!timingAllowOrigin.isEmpty()) |
| 474 info->setOriginalTimingAllowOrigin(timingAllowOrigin); | 474 info->setOriginalTimingAllowOrigin(timingAllowOrigin); |
| 475 } | 475 } |
| 476 | 476 |
| 477 if (resource->type() != Resource::MainResource || context().updateTimingInfo
ForIFrameNavigation(info.get())) | 477 if (resource->type() != Resource::MainResource || context().updateTimingInfo
ForIFrameNavigation(info.get())) |
| 478 m_resourceTimingInfoMap.add(resource, info); | 478 m_resourceTimingInfoMap.add(resource, info.release()); |
| 479 } | 479 } |
| 480 | 480 |
| 481 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy
(Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour
ce) const | 481 ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy
(Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResour
ce) const |
| 482 { | 482 { |
| 483 const ResourceRequest& request = fetchRequest.resourceRequest(); | 483 const ResourceRequest& request = fetchRequest.resourceRequest(); |
| 484 | 484 |
| 485 if (!existingResource) | 485 if (!existingResource) |
| 486 return Load; | 486 return Load; |
| 487 | 487 |
| 488 // We already have a preload going for this URL. | 488 // We already have a preload going for this URL. |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 795 |
| 796 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength) | 796 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength) |
| 797 { | 797 { |
| 798 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); | 798 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource); |
| 799 RefPtrWillBeRawPtr<ResourceFetcher> protect(this); | 799 RefPtrWillBeRawPtr<ResourceFetcher> protect(this); |
| 800 willTerminateResourceLoader(resource->loader()); | 800 willTerminateResourceLoader(resource->loader()); |
| 801 | 801 |
| 802 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400) { | 802 if (resource && resource->response().isHTTP() && resource->response().httpSt
atusCode() < 400) { |
| 803 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); | 803 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resour
ce); |
| 804 if (it != m_resourceTimingInfoMap.end()) { | 804 if (it != m_resourceTimingInfoMap.end()) { |
| 805 RefPtr<ResourceTimingInfo> info = it->value; | 805 OwnPtr<ResourceTimingInfo> info = it->value.release(); |
| 806 m_resourceTimingInfoMap.remove(it); | 806 m_resourceTimingInfoMap.remove(it); |
| 807 populateResourceTiming(info.get(), resource, false); | 807 populateResourceTiming(info.get(), resource, false); |
| 808 context().addResourceTiming(info.get(), resource->type() == Resource
::MainResource); | 808 context().addResourceTiming(*info); |
| 809 } | 809 } |
| 810 } | 810 } |
| 811 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); | 811 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod
edDataLength); |
| 812 } | 812 } |
| 813 | 813 |
| 814 void ResourceFetcher::didChangeLoadingPriority(const Resource* resource, Resourc
eLoadPriority loadPriority, int intraPriorityValue) | 814 void ResourceFetcher::didChangeLoadingPriority(const Resource* resource, Resourc
eLoadPriority loadPriority, int intraPriorityValue) |
| 815 { | 815 { |
| 816 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangePrior
ity", "priority", loadPriority); | 816 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangePrior
ity", "priority", loadPriority); |
| 817 context().dispatchDidChangeResourcePriority(resource->identifier(), loadPrio
rity, intraPriorityValue); | 817 context().dispatchDidChangeResourcePriority(resource->identifier(), loadPrio
rity, intraPriorityValue); |
| 818 } | 818 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 | 1052 |
| 1053 DEFINE_TRACE(ResourceFetcher) | 1053 DEFINE_TRACE(ResourceFetcher) |
| 1054 { | 1054 { |
| 1055 visitor->trace(m_context); | 1055 visitor->trace(m_context); |
| 1056 visitor->trace(m_archiveResourceCollection); | 1056 visitor->trace(m_archiveResourceCollection); |
| 1057 visitor->trace(m_loaders); | 1057 visitor->trace(m_loaders); |
| 1058 visitor->trace(m_nonBlockingLoaders); | 1058 visitor->trace(m_nonBlockingLoaders); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 } | 1061 } |
| OLD | NEW |