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

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: Initialise encoded_body_length for sync XHR to data: URLs 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 moveResourceLoaderToNonBlocking(resource->loader()); 910 moveResourceLoaderToNonBlocking(resource->loader());
911 else 911 else
912 removeResourceLoader(resource->loader()); 912 removeResourceLoader(resource->loader());
913 DCHECK(!m_loaders.contains(resource->loader())); 913 DCHECK(!m_loaders.contains(resource->loader()));
914 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader s.contains(resource->loader())); 914 DCHECK(finishReason == DidFinishFirstPartInMultipart || !m_nonBlockingLoader s.contains(resource->loader()));
915 915
916 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take( resource)) { 916 if (std::unique_ptr<ResourceTimingInfo> info = m_resourceTimingInfoMap.take( resource)) {
917 if (resource->response().isHTTP() && resource->response().httpStatusCode () < 400) { 917 if (resource->response().isHTTP() && resource->response().httpStatusCode () < 400) {
918 populateResourceTiming(info.get(), resource); 918 populateResourceTiming(info.get(), resource);
919 info->setLoadFinishTime(finishTime); 919 info->setLoadFinishTime(finishTime);
920 // encodedDataLength == -1 means "not available".
921 // TODO(ricea): Find cases where it is not available but the
922 // PerformanceResourceTiming spec requires it to be available and
923 // fix them.
924 info->addFinalTransferSize(encodedDataLength == -1 ? 0 : encodedData Length);
920 if (resource->options().requestInitiatorContext == DocumentContext) 925 if (resource->options().requestInitiatorContext == DocumentContext)
921 context().addResourceTiming(*info); 926 context().addResourceTiming(*info);
922 resource->reportResourceTimingToClients(*info); 927 resource->reportResourceTimingToClients(*info);
923 } 928 }
924 } 929 }
925 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod edDataLength); 930 context().dispatchDidFinishLoading(resource->identifier(), finishTime, encod edDataLength);
926 if (finishReason == DidFinishLoading) 931 if (finishReason == DidFinishLoading)
927 resource->finish(finishTime); 932 resource->finish(finishTime);
928 context().didLoadResource(resource); 933 context().didLoadResource(resource);
929 } 934 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 bool ResourceFetcher::defersLoading() const 1032 bool ResourceFetcher::defersLoading() const
1028 { 1033 {
1029 return context().defersLoading(); 1034 return context().defersLoading();
1030 } 1035 }
1031 1036
1032 static bool isManualRedirectFetchRequest(const ResourceRequest& request) 1037 static bool isManualRedirectFetchRequest(const ResourceRequest& request)
1033 { 1038 {
1034 return request.fetchRedirectMode() == WebURLRequest::FetchRedirectModeManual && request.requestContext() == WebURLRequest::RequestContextFetch; 1039 return request.fetchRedirectMode() == WebURLRequest::FetchRedirectModeManual && request.requestContext() == WebURLRequest::RequestContextFetch;
1035 } 1040 }
1036 1041
1037 bool ResourceFetcher::willFollowRedirect(Resource* resource, ResourceRequest& ne wRequest, const ResourceResponse& redirectResponse) 1042 bool ResourceFetcher::willFollowRedirect(Resource* resource, ResourceRequest& ne wRequest, const ResourceResponse& redirectResponse, int64_t encodedDataLength)
1038 { 1043 {
1039 if (!isManualRedirectFetchRequest(resource->resourceRequest())) { 1044 if (!isManualRedirectFetchRequest(resource->resourceRequest())) {
1040 if (!context().canRequest(resource->getType(), newRequest, newRequest.ur l(), resource->options(), resource->isUnusedPreload(), FetchRequest::UseDefaultO riginRestrictionForType)) 1045 if (!context().canRequest(resource->getType(), newRequest, newRequest.ur l(), resource->options(), resource->isUnusedPreload(), FetchRequest::UseDefaultO riginRestrictionForType))
1041 return false; 1046 return false;
1042 if (resource->options().corsEnabled == IsCORSEnabled) { 1047 if (resource->options().corsEnabled == IsCORSEnabled) {
1043 SecurityOrigin* sourceOrigin = resource->options().securityOrigin.ge t(); 1048 SecurityOrigin* sourceOrigin = resource->options().securityOrigin.ge t();
1044 if (!sourceOrigin) 1049 if (!sourceOrigin)
1045 sourceOrigin = context().getSecurityOrigin(); 1050 sourceOrigin = context().getSecurityOrigin();
1046 1051
1047 String errorMessage; 1052 String errorMessage;
1048 StoredCredentials withCredentials = resource->lastResourceRequest(). allowStoredCredentials() ? AllowStoredCredentials : DoNotAllowStoredCredentials; 1053 StoredCredentials withCredentials = resource->lastResourceRequest(). allowStoredCredentials() ? AllowStoredCredentials : DoNotAllowStoredCredentials;
1049 if (!CrossOriginAccessControl::handleRedirect(sourceOrigin, newReque st, redirectResponse, withCredentials, resource->mutableOptions(), errorMessage) ) { 1054 if (!CrossOriginAccessControl::handleRedirect(sourceOrigin, newReque st, redirectResponse, withCredentials, resource->mutableOptions(), errorMessage) ) {
1050 resource->setCORSFailed(); 1055 resource->setCORSFailed();
1051 context().addConsoleMessage(errorMessage); 1056 context().addConsoleMessage(errorMessage);
1052 return false; 1057 return false;
1053 } 1058 }
1054 } 1059 }
1055 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newRe quest.url())) 1060 if (resource->getType() == Resource::Image && shouldDeferImageLoad(newRe quest.url()))
1056 return false; 1061 return false;
1057 } 1062 }
1058 1063
1059 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); 1064 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
1060 if (it != m_resourceTimingInfoMap.end()) 1065 if (it != m_resourceTimingInfoMap.end()) {
1061 it->value->addRedirect(redirectResponse); 1066 RefPtr<SecurityOrigin> originalSecurityOrigin = SecurityOrigin::create(r edirectResponse.url());
1067 RefPtr<SecurityOrigin> redirectedSecurityOrigin = SecurityOrigin::create (newRequest.url());
1068 bool crossOrigin = !redirectedSecurityOrigin->isSameSchemeHostPort(origi nalSecurityOrigin.get());
1069 it->value->addRedirect(redirectResponse, encodedDataLength, crossOrigin) ;
1070 }
1062 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour ce->options()); 1071 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour ce->options());
1063 return true; 1072 return true;
1064 } 1073 }
1065 1074
1066 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio ns& options) 1075 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio ns& options)
1067 { 1076 {
1068 newRequest.setAllowStoredCredentials(options.allowCredentials == AllowStored Credentials); 1077 newRequest.setAllowStoredCredentials(options.allowCredentials == AllowStored Credentials);
1069 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, options.initiatorInfo); 1078 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, options.initiatorInfo);
1070 } 1079 }
1071 1080
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 visitor->trace(m_context); 1271 visitor->trace(m_context);
1263 visitor->trace(m_archive); 1272 visitor->trace(m_archive);
1264 visitor->trace(m_loaders); 1273 visitor->trace(m_loaders);
1265 visitor->trace(m_nonBlockingLoaders); 1274 visitor->trace(m_nonBlockingLoaders);
1266 visitor->trace(m_documentResources); 1275 visitor->trace(m_documentResources);
1267 visitor->trace(m_preloads); 1276 visitor->trace(m_preloads);
1268 visitor->trace(m_resourceTimingInfoMap); 1277 visitor->trace(m_resourceTimingInfoMap);
1269 } 1278 }
1270 1279
1271 } // namespace blink 1280 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698