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

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

Issue 2337733002: [tracing] Support BACKGROUND mode in MemoryCache dump provider (Closed)
Patch Set: remove trace_event change. Created 4 years, 3 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 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 memoryCache()->remove(resource); 585 memoryCache()->remove(resource);
586 } 586 }
587 587
588 void MemoryCache::TypeStatistic::addResource(Resource* o) 588 void MemoryCache::TypeStatistic::addResource(Resource* o)
589 { 589 {
590 count++; 590 count++;
591 size += o->size(); 591 size += o->size();
592 liveSize += o->isAlive() ? o->size() : 0; 592 liveSize += o->isAlive() ? o->size() : 0;
593 decodedSize += o->decodedSize(); 593 decodedSize += o->decodedSize();
594 encodedSize += o->encodedSize(); 594 encodedSize += o->encodedSize();
595 overheadSize += o->overheadSize();
595 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz e() : 0; 596 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz e() : 0;
596 } 597 }
597 598
598 MemoryCache::Statistics MemoryCache::getStatistics() 599 MemoryCache::Statistics MemoryCache::getStatistics()
599 { 600 {
600 Statistics stats; 601 Statistics stats;
601 for (const auto& resourceMapIter : m_resourceMaps) { 602 for (const auto& resourceMapIter : m_resourceMaps) {
602 for (const auto& resourceIter : *resourceMapIter.value) { 603 for (const auto& resourceIter : *resourceMapIter.value) {
603 Resource* resource = resourceIter.value->resource(); 604 Resource* resource = resourceIter.value->resource();
604 DCHECK(resource); 605 DCHECK(resource);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 m_pruneTimeStamp = currentTime; 723 m_pruneTimeStamp = currentTime;
723 } 724 }
724 725
725 void MemoryCache::updateFramePaintTimestamp() 726 void MemoryCache::updateFramePaintTimestamp()
726 { 727 {
727 m_lastFramePaintTimeStamp = currentTime(); 728 m_lastFramePaintTimeStamp = currentTime();
728 } 729 }
729 730
730 bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc essMemoryDump* memoryDump) 731 bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc essMemoryDump* memoryDump)
731 { 732 {
733 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Background) {
734 Statistics stats = getStatistics();
735 WebMemoryAllocatorDump* dump1 = memoryDump->createMemoryAllocatorDump("w eb_cache/Image_resources");
736 dump1->addScalar("size", "bytes", stats.images.encodedSize + stats.image s.overheadSize);
737 WebMemoryAllocatorDump* dump2 = memoryDump->createMemoryAllocatorDump("w eb_cache/CSS stylesheet_resources");
738 dump2->addScalar("size", "bytes", stats.cssStyleSheets.encodedSize + sta ts.cssStyleSheets.overheadSize);
739 WebMemoryAllocatorDump* dump3 = memoryDump->createMemoryAllocatorDump("w eb_cache/Script_resources");
740 dump3->addScalar("size", "bytes", stats.scripts.encodedSize + stats.scri pts.overheadSize);
741 WebMemoryAllocatorDump* dump4 = memoryDump->createMemoryAllocatorDump("w eb_cache/XSL stylesheet_resources");
742 dump4->addScalar("size", "bytes", stats.xslStyleSheets.encodedSize + sta ts.xslStyleSheets.overheadSize);
743 WebMemoryAllocatorDump* dump5 = memoryDump->createMemoryAllocatorDump("w eb_cache/Font_resources");
744 dump5->addScalar("size", "bytes", stats.fonts.encodedSize + stats.fonts. overheadSize);
745 WebMemoryAllocatorDump* dump6 = memoryDump->createMemoryAllocatorDump("w eb_cache/Other_resources");
746 dump6->addScalar("size", "bytes", stats.other.encodedSize + stats.other. overheadSize);
747 return true;
748 }
749
732 for (const auto& resourceMapIter : m_resourceMaps) { 750 for (const auto& resourceMapIter : m_resourceMaps) {
733 for (const auto& resourceIter : *resourceMapIter.value) { 751 for (const auto& resourceIter : *resourceMapIter.value) {
734 Resource* resource = resourceIter.value->resource(); 752 Resource* resource = resourceIter.value->resource();
735 resource->onMemoryDump(levelOfDetail, memoryDump); 753 resource->onMemoryDump(levelOfDetail, memoryDump);
736 } 754 }
737 } 755 }
738 return true; 756 return true;
739 } 757 }
740 758
741 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level) 759 void MemoryCache::onMemoryPressure(WebMemoryPressureLevel level)
742 { 760 {
743 pruneAll(); 761 pruneAll();
744 } 762 }
745 763
746 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) 764 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y)
747 { 765 {
748 MemoryCacheEntry* ex = getEntryForResource(x); 766 MemoryCacheEntry* ex = getEntryForResource(x);
749 MemoryCacheEntry* ey = getEntryForResource(y); 767 MemoryCacheEntry* ey = getEntryForResource(y);
750 ASSERT(ex); 768 ASSERT(ex);
751 ASSERT(ey); 769 ASSERT(ey);
752 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size()); 770 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo unt, y->size());
753 } 771 }
754 772
755 } // namespace blink 773 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.h ('k') | third_party/WebKit/Source/platform/MemoryCacheDumpProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698