Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2647643004: Report nav timing 2 instance as soon as it's requested. (Closed)
Patch Set: got rid of test cases that don't apply anymore Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 if (request.requestContext() == WebURLRequest::RequestContextUnspecified) 646 if (request.requestContext() == WebURLRequest::RequestContextUnspecified)
647 determineRequestContext(request, type); 647 determineRequestContext(request, type);
648 if (type == Resource::LinkPrefetch) 648 if (type == Resource::LinkPrefetch)
649 request.setHTTPHeaderField(HTTPNames::Purpose, "prefetch"); 649 request.setHTTPHeaderField(HTTPNames::Purpose, "prefetch");
650 650
651 context().addAdditionalRequestHeaders( 651 context().addAdditionalRequestHeaders(
652 request, 652 request,
653 (type == Resource::MainResource) ? FetchMainResource : FetchSubresource); 653 (type == Resource::MainResource) ? FetchMainResource : FetchSubresource);
654 } 654 }
655 655
656 std::unique_ptr<ResourceTimingInfo> ResourceFetcher::getNavigationTimingInfo() {
657 return std::move(m_navigationTimingInfo);
Kunihiko Sakamoto 2017/02/03 01:28:07 Scripts can be executed from partially loaded main
sunjian 2017/02/03 20:15:21 Added an extra field which is raw pointer of m_nav
panicker 2017/02/03 23:27:43 This is strange. I think your intention is shared_
sunjian 2017/02/04 00:08:36 A shared smart pointer probably makes things easie
panicker 2017/02/07 00:45:05 I think shared_ptr is the right thing here. We wan
658 }
659
656 void ResourceFetcher::initializeRevalidation( 660 void ResourceFetcher::initializeRevalidation(
657 ResourceRequest& revalidatingRequest, 661 ResourceRequest& revalidatingRequest,
658 Resource* resource) { 662 Resource* resource) {
659 DCHECK(resource); 663 DCHECK(resource);
660 DCHECK(memoryCache()->contains(resource)); 664 DCHECK(memoryCache()->contains(resource));
661 DCHECK(resource->isLoaded()); 665 DCHECK(resource->isLoaded());
662 DCHECK(resource->canUseCacheValidator()); 666 DCHECK(resource->canUseCacheValidator());
663 DCHECK(!resource->isCacheValidator()); 667 DCHECK(!resource->isCacheValidator());
664 DCHECK(!context().isControlledByServiceWorker()); 668 DCHECK(!context().isControlledByServiceWorker());
665 669
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 } 1111 }
1108 1112
1109 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) { 1113 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) {
1110 // Only the top-frame can load MHTML. 1114 // Only the top-frame can load MHTML.
1111 if (!context().isMainFrame()) 1115 if (!context().isMainFrame())
1112 return nullptr; 1116 return nullptr;
1113 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); 1117 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer());
1114 return m_archive ? m_archive->mainResource() : nullptr; 1118 return m_archive ? m_archive->mainResource() : nullptr;
1115 } 1119 }
1116 1120
1117 ResourceTimingInfo* ResourceFetcher::getNavigationTimingInfo() {
1118 return m_navigationTimingInfo.get();
1119 }
1120
1121 void ResourceFetcher::handleLoadCompletion(Resource* resource) { 1121 void ResourceFetcher::handleLoadCompletion(Resource* resource) {
1122 context().didLoadResource(resource); 1122 context().didLoadResource(resource);
1123 1123
1124 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadIfNeeded); 1124 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadIfNeeded);
1125 } 1125 }
1126 1126
1127 void ResourceFetcher::handleLoaderFinish(Resource* resource, 1127 void ResourceFetcher::handleLoaderFinish(Resource* resource,
1128 double finishTime, 1128 double finishTime,
1129 LoaderFinishType type) { 1129 LoaderFinishType type) {
1130 DCHECK(resource); 1130 DCHECK(resource);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 visitor->trace(m_context); 1525 visitor->trace(m_context);
1526 visitor->trace(m_archive); 1526 visitor->trace(m_archive);
1527 visitor->trace(m_loaders); 1527 visitor->trace(m_loaders);
1528 visitor->trace(m_nonBlockingLoaders); 1528 visitor->trace(m_nonBlockingLoaders);
1529 visitor->trace(m_documentResources); 1529 visitor->trace(m_documentResources);
1530 visitor->trace(m_preloads); 1530 visitor->trace(m_preloads);
1531 visitor->trace(m_resourceTimingInfoMap); 1531 visitor->trace(m_resourceTimingInfoMap);
1532 } 1532 }
1533 1533
1534 } // namespace blink 1534 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698