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

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

Issue 2105713002: Render process changes for ResourceTiming sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_browser_process
Patch Set: Fixes from ksakamoto review Created 4 years, 5 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 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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 moveResourceLoaderToNonBlocking(resource->loader()); 909 moveResourceLoaderToNonBlocking(resource->loader());
910 else 910 else
911 removeResourceLoader(resource->loader()); 911 removeResourceLoader(resource->loader());
912 DCHECK(!m_loaders.contains(resource->loader())); 912 DCHECK(!m_loaders.contains(resource->loader()));
913 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader s.contains(resource->loader())); 913 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader s.contains(resource->loader()));
914 914
915 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take( resource)) { 915 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take( resource)) {
916 if (resource->response().isHTTP() && resource->response().httpStatusCode () < 400) { 916 if (resource->response().isHTTP() && resource->response().httpStatusCode () < 400) {
917 populateResourceTiming(info.get(), resource); 917 populateResourceTiming(info.get(), resource);
918 info->setLoadFinishTime(finishTime); 918 info->setLoadFinishTime(finishTime);
919 // encodedDataLength == -1 means "not available".
920 // FIXME: Find cases where it is not available but the
921 // PerformanceResourceTiming spec requires it to be available and
922 // fix them.
923 info->addFinalTransferSize(encodedDataLength == -1 ? 0 : encodedData Length);
919 if (resource->options().requestInitiatorContext == DocumentContext) 924 if (resource->options().requestInitiatorContext == DocumentContext)
920 context().addResourceTiming(*info); 925 context().addResourceTiming(*info);
921 resource->reportResourceTimingToClients(*info); 926 resource->reportResourceTimingToClients(*info);
922 } 927 }
923 } 928 }
924 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod edDataLength); 929 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod edDataLength);
925 if (finishReason == DidFinishLoading) 930 if (finishReason == DidFinishLoading)
926 resource->finish(finishTime); 931 resource->finish(finishTime);
927 context().didLoadResource(resource); 932 context().didLoadResource(resource);
928 } 933 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 bool ResourceFetcher::defersLoading() const 1031 bool ResourceFetcher::defersLoading() const
1027 { 1032 {
1028 return context().defersLoading(); 1033 return context().defersLoading();
1029 } 1034 }
1030 1035
1031 static bool isManualRedirectFetchRequest(const ResourceRequest& request) 1036 static bool isManualRedirectFetchRequest(const ResourceRequest& request)
1032 { 1037 {
1033 return request.fetchRedirectMode() == WebURLRequest::FetchRedirectModeManual && request.requestContext() == WebURLRequest::RequestContextFetch; 1038 return request.fetchRedirectMode() == WebURLRequest::FetchRedirectModeManual && request.requestContext() == WebURLRequest::RequestContextFetch;
1034 } 1039 }
1035 1040
1036 bool ResourceFetcher::willFollowRedirect(Resource* resource, ResourceRequest& ne wRequest, const ResourceResponse& redirectResponse) 1041 bool ResourceFetcher::willFollowRedirect(Resource* resource, ResourceRequest& ne wRequest, const ResourceResponse& redirectResponse, int64_t encodedDataLength)
1037 { 1042 {
1038 if (!isManualRedirectFetchRequest(resource->resourceRequest())) { 1043 if (!isManualRedirectFetchRequest(resource->resourceRequest())) {
1039 if (!context().canRequest(resource->getType(), newRequest, newRequest.ur l(), resource->options(), resource->isUnusedPreload(), FetchRequest::UseDefaultO riginRestrictionForType)) 1044 if (!context().canRequest(resource->getType(), newRequest, newRequest.ur l(), resource->options(), resource->isUnusedPreload(), FetchRequest::UseDefaultO riginRestrictionForType))
1040 return false; 1045 return false;
1041 if (resource->options().corsEnabled == IsCORSEnabled) { 1046 if (resource->options().corsEnabled == IsCORSEnabled) {
1042 SecurityOrigin* sourceOrigin = resource->options().securityOrigin.ge t(); 1047 SecurityOrigin* sourceOrigin = resource->options().securityOrigin.ge t();
1043 if (!sourceOrigin) 1048 if (!sourceOrigin)
1044 sourceOrigin = context().getSecurityOrigin(); 1049 sourceOrigin = context().getSecurityOrigin();
1045 1050
1046 String errorMessage; 1051 String errorMessage;
1047 StoredCredentials withCredentials = resource->lastResourceRequest(). allowStoredCredentials() ? AllowStoredCredentials : DoNotAllowStoredCredentials; 1052 StoredCredentials withCredentials = resource->lastResourceRequest(). allowStoredCredentials() ? AllowStoredCredentials : DoNotAllowStoredCredentials;
1048 if (!CrossOriginAccessControl::handleRedirect(sourceOrigin, newReque st, redirectResponse, withCredentials, resource->mutableOptions(), errorMessage) ) { 1053 if (!CrossOriginAccessControl::handleRedirect(sourceOrigin, newReque st, redirectResponse, withCredentials, resource->mutableOptions(), errorMessage) ) {
1049 resource->setCORSFailed(); 1054 resource->setCORSFailed();
1050 context().addConsoleMessage(errorMessage); 1055 context().addConsoleMessage(errorMessage);
1051 return false; 1056 return false;
1052 } 1057 }
1053 } 1058 }
1054 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newRe quest.url())) 1059 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newRe quest.url()))
1055 return false; 1060 return false;
1056 } 1061 }
1057 1062
1058 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); 1063 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
1059 if (it != m_resourceTimingInfoMap.end()) 1064 if (it != m_resourceTimingInfoMap.end()) {
1060 it->value->addRedirect(redirectResponse); 1065 RefPtr<SecurityOrigin> redirectedSecurityOrigin = SecurityOrigin::create (redirectResponse.url());
1066 RefPtr<SecurityOrigin> originalSecurityOrigin = SecurityOrigin::create(n ewRequest.url());
Kunihiko Sakamoto 2016/07/04 06:59:04 Wrong variable names? If I'm not mistaken, redire
Adam Rice 2016/07/04 07:36:45 You are right. I was confused. Fixed.
1067 bool crossOrigin = !redirectedSecurityOrigin->isSameSchemeHostPort(origi nalSecurityOrigin.get());
1068 it->value->addRedirect(redirectResponse, encodedDataLength, crossOrigin) ;
1069 }
1061 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour ce->options()); 1070 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour ce->options());
1062 return true; 1071 return true;
1063 } 1072 }
1064 1073
1065 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio ns& options) 1074 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio ns& options)
1066 { 1075 {
1067 newRequest.setAllowStoredCredentials(options.allowCredentials == AllowStored Credentials); 1076 newRequest.setAllowStoredCredentials(options.allowCredentials == AllowStored Credentials);
1068 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, options.initiatorInfo); 1077 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, options.initiatorInfo);
1069 } 1078 }
1070 1079
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 visitor->trace(m_context); 1270 visitor->trace(m_context);
1262 visitor->trace(m_archive); 1271 visitor->trace(m_archive);
1263 visitor->trace(m_loaders); 1272 visitor->trace(m_loaders);
1264 visitor->trace(m_nonBlockingLoaders); 1273 visitor->trace(m_nonBlockingLoaders);
1265 visitor->trace(m_documentResources); 1274 visitor->trace(m_documentResources);
1266 visitor->trace(m_preloads); 1275 visitor->trace(m_preloads);
1267 visitor->trace(m_resourceTimingInfoMap); 1276 visitor->trace(m_resourceTimingInfoMap);
1268 } 1277 }
1269 1278
1270 } // namespace blink 1279 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698