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

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

Issue 1771473002: [MemoryCache] Exclude data URLs and SubstituteData from MemoryCache UMAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comment Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue to not-block even after being preloaded and discovered. 378 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue to not-block even after being preloaded and discovered.
379 if (resource && resource->loader() && resource->isLoadEventBlockingResourceT ype() && resource->isLinkPreload() && !request.forPreload()) { 379 if (resource && resource->loader() && resource->isLoadEventBlockingResourceT ype() && resource->isLinkPreload() && !request.forPreload()) {
380 if (m_nonBlockingLoaders) 380 if (m_nonBlockingLoaders)
381 m_nonBlockingLoaders->remove(resource->loader()); 381 m_nonBlockingLoaders->remove(resource->loader());
382 if (!m_loaders) 382 if (!m_loaders)
383 m_loaders = ResourceLoaderSet::create(); 383 m_loaders = ResourceLoaderSet::create();
384 m_loaders->add(resource->loader()); 384 m_loaders->add(resource->loader());
385 } 385 }
386 } 386 }
387 387
388 void ResourceFetcher::updateMemoryCacheStats(Resource* resource, RevalidationPol icy policy, const FetchRequest& request, const ResourceFactory& factory, bool i sStaticData) const
389 {
390 if (isStaticData)
391 return;
392
393 if (request.forPreload()) {
394 DEFINE_RESOURCE_HISTOGRAM("Preload.");
395 } else {
396 DEFINE_RESOURCE_HISTOGRAM("");
397 }
398
399 // Aims to count Resource only referenced from MemoryCache (i.e. what
400 // would be dead if MemoryCache holds weak references to Resource).
401 // Currently we check references to Resource from ResourceClient and
402 // |m_preloads| only, because they are major sources of references.
403 if (resource && !resource->hasClients() && (!m_preloads || !m_preloads->cont ains(resource))) {
404 DEFINE_RESOURCE_HISTOGRAM("Dead.");
405 }
406 }
407
388 PassRefPtrWillBeRawPtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData) 408 PassRefPtrWillBeRawPtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData)
389 { 409 {
390 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || facto ry.type() == Resource::Raw || factory.type() == Resource::XSLStyleSheet); 410 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || facto ry.type() == Resource::Raw || factory.type() == Resource::XSLStyleSheet);
391 411
392 context().upgradeInsecureRequest(request); 412 context().upgradeInsecureRequest(request);
393 context().addClientHintsIfNecessary(request); 413 context().addClientHintsIfNecessary(request);
394 context().addCSPHeaderIfNecessary(factory.type(), request); 414 context().addCSPHeaderIfNecessary(factory.type(), request);
395 415
396 KURL url = request.resourceRequest().url(); 416 KURL url = request.resourceRequest().url();
397 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", urlForTrace Event(url)); 417 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", urlForTrace Event(url));
(...skipping 29 matching lines...) Expand all
427 if (isStaticData) 447 if (isStaticData)
428 resource = resourceForStaticData(request, factory, substituteData); 448 resource = resourceForStaticData(request, factory, substituteData);
429 if (!resource) 449 if (!resource)
430 resource = memoryCache()->resourceForURL(url, getCacheIdentifier()); 450 resource = memoryCache()->resourceForURL(url, getCacheIdentifier());
431 451
432 // See if we can use an existing resource from the cache. If so, we need to move it to be load blocking. 452 // See if we can use an existing resource from the cache. If so, we need to move it to be load blocking.
433 moveCachedNonBlockingResourceToBlocking(resource.get(), request); 453 moveCachedNonBlockingResourceToBlocking(resource.get(), request);
434 454
435 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type() , request, resource.get(), isStaticData); 455 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type() , request, resource.get(), isStaticData);
436 456
437 if (request.forPreload()) { 457 updateMemoryCacheStats(resource.get(), policy, request, factory, isStaticDat a);
438 DEFINE_RESOURCE_HISTOGRAM("Preload.");
439 } else {
440 DEFINE_RESOURCE_HISTOGRAM("");
441 }
442 // Aims to count Resource only referenced from MemoryCache (i.e. what
443 // would be dead if MemoryCache holds weak references to Resource).
444 // Currently we check references to Resource from ResourceClient and
445 // |m_preloads| only, because they are major sources of references.
446 if (resource && !resource->hasClients() && (!m_preloads || !m_preloads->cont ains(resource)) && !isStaticData) {
447 DEFINE_RESOURCE_HISTOGRAM("Dead.");
448 }
449 458
450 switch (policy) { 459 switch (policy) {
451 case Reload: 460 case Reload:
452 memoryCache()->remove(resource.get()); 461 memoryCache()->remove(resource.get());
453 // Fall through 462 // Fall through
454 case Load: 463 case Load:
455 resource = createResourceForLoading(request, request.charset(), factory) ; 464 resource = createResourceForLoading(request, request.charset(), factory) ;
456 break; 465 break;
457 case Revalidate: 466 case Revalidate:
458 initializeRevalidation(request, resource.get()); 467 initializeRevalidation(request, resource.get());
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 visitor->trace(m_loaders); 1242 visitor->trace(m_loaders);
1234 visitor->trace(m_nonBlockingLoaders); 1243 visitor->trace(m_nonBlockingLoaders);
1235 #if ENABLE(OILPAN) 1244 #if ENABLE(OILPAN)
1236 visitor->trace(m_documentResources); 1245 visitor->trace(m_documentResources);
1237 visitor->trace(m_preloads); 1246 visitor->trace(m_preloads);
1238 visitor->trace(m_resourceTimingInfoMap); 1247 visitor->trace(m_resourceTimingInfoMap);
1239 #endif 1248 #endif
1240 } 1249 }
1241 1250
1242 } // namespace blink 1251 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698