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

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

Issue 1413233005: tracing: Report ResourceClients and the reason for not deletable for web-caches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comments. Created 5 years, 1 month 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 if (cacheType == CachedMetadataHandler::SendToPlatform) 505 if (cacheType == CachedMetadataHandler::SendToPlatform)
506 Platform::current()->cacheMetadata(m_response.url(), m_response.response Time(), 0, 0); 506 Platform::current()->cacheMetadata(m_response.url(), m_response.response Time(), 0, 0);
507 } 507 }
508 508
509 bool Resource::canDelete() const 509 bool Resource::canDelete() const
510 { 510 {
511 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0) 511 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0)
512 && !m_protectorCount; 512 && !m_protectorCount;
513 } 513 }
514 514
515 String Resource::reasonNotDeletable() const
516 {
517 StringBuilder builder;
518 if (hasClients()) {
519 builder.append("hasClients(");
520 builder.appendNumber(m_clients.size());
521 if (!m_clientsAwaitingCallback.isEmpty()) {
522 builder.append(", AwaitingCallback=");
523 builder.appendNumber(m_clientsAwaitingCallback.size());
524 }
525 if (!m_finishedClients.isEmpty()) {
526 builder.append(", Finished=");
527 builder.appendNumber(m_finishedClients.size());
528 }
529 builder.append(")");
530 }
531 if (m_loader) {
532 if (!builder.isEmpty())
533 builder.append(' ');
534 builder.append("m_loader");
535 }
536 if (m_preloadCount) {
537 if (!builder.isEmpty())
538 builder.append(' ');
539 builder.append("m_preloadCount(");
540 builder.appendNumber(m_preloadCount);
541 builder.append(")");
542 }
543 if (!hasRightHandleCountApartFromCache(0)) {
544 if (!builder.isEmpty())
545 builder.append(' ');
546 builder.append("m_handleCount(");
547 builder.appendNumber(m_handleCount);
548 builder.append(")");
549 }
550 if (m_protectorCount) {
551 if (!builder.isEmpty())
552 builder.append(' ');
553 builder.append("m_protectorCount(");
554 builder.appendNumber(m_protectorCount);
555 builder.append(")");
556 }
557 if (memoryCache()->contains(this)) {
558 if (!builder.isEmpty())
559 builder.append(' ');
560 builder.append("in_memory_cache");
561 }
562 return builder.toString();
563 }
564
515 bool Resource::hasOneHandle() const 565 bool Resource::hasOneHandle() const
516 { 566 {
517 return hasRightHandleCountApartFromCache(1); 567 return hasRightHandleCountApartFromCache(1);
518 } 568 }
519 569
520 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const 570 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const
521 { 571 {
522 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) 572 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID)
523 return nullptr; 573 return nullptr;
524 return m_cachedMetadata.get(); 574 return m_cachedMetadata.get();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 772
723 void Resource::prune() 773 void Resource::prune()
724 { 774 {
725 destroyDecodedDataIfPossible(); 775 destroyDecodedDataIfPossible();
726 unlock(); 776 unlock();
727 } 777 }
728 778
729 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess MemoryDump* memoryDump) const 779 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess MemoryDump* memoryDump) const
730 { 780 {
731 static const size_t kMaxURLReportLength = 128; 781 static const size_t kMaxURLReportLength = 128;
782 static const int kMaxResourceClientToShowInMemoryInfra = 10;
732 783
733 const String dumpName = getMemoryDumpName(); 784 const String dumpName = getMemoryDumpName();
734 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam e); 785 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam e);
735 dump->addScalar("encoded_size", "bytes", m_encodedSize); 786 dump->addScalar("encoded_size", "bytes", m_encodedSize);
736 if (canDelete()) { 787 if (canDelete()) {
737 dump->addScalar("dead_size", "bytes", m_encodedSize); 788 dump->addScalar("dead_size", "bytes", m_encodedSize);
738 } else { 789 } else {
739 dump->addScalar("live_size", "bytes", m_encodedSize); 790 dump->addScalar("live_size", "bytes", m_encodedSize);
740 } 791 }
741 792
742 if (m_data) { 793 if (m_data) {
743 dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0); 794 dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0);
744 m_data->onMemoryDump(dumpName, memoryDump); 795 m_data->onMemoryDump(dumpName, memoryDump);
745 } 796 }
746 797
747 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { 798 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
748 String urlToReport = url().string(); 799 String urlToReport = url().string();
749 if (urlToReport.length() > kMaxURLReportLength) { 800 if (urlToReport.length() > kMaxURLReportLength) {
750 urlToReport.truncate(kMaxURLReportLength); 801 urlToReport.truncate(kMaxURLReportLength);
751 urlToReport = urlToReport + "..."; 802 urlToReport = urlToReport + "...";
752 } 803 }
753 dump->addString("url", "", urlToReport); 804 dump->addString("url", "", urlToReport);
805
806 dump->addString("reason_not_deletable", "", reasonNotDeletable());
807
808 Vector<String> clientNames;
809 ResourceClientWalker<ResourceClient> w(m_clients);
haraken 2015/11/09 23:30:20 w => walker
hiroshige 2015/11/10 00:12:10 Done.
810 while (ResourceClient* c = w.next())
haraken 2015/11/09 23:30:20 c => client
hiroshige 2015/11/10 00:12:10 Done.
811 clientNames.append(c->debugName());
812 ResourceClientWalker<ResourceClient> w2(m_clientsAwaitingCallback);
813 while (ResourceClient* c = w2.next())
814 clientNames.append("(awaiting) " + c->debugName());
815 ResourceClientWalker<ResourceClient> w3(m_finishedClients);
816 while (ResourceClient* c = w3.next())
817 clientNames.append("(finished) " + c->debugName());
818 std::sort(clientNames.begin(), clientNames.end(), codePointCompareLessTh an);
819
820 StringBuilder builder;
821 for (size_t i = 0; i < clientNames.size() && i < kMaxResourceClientToSho wInMemoryInfra; ++i) {
822 if (i > 0)
823 builder.append(" / ");
824 builder.append(clientNames[i]);
825 }
826 if (clientNames.size() > kMaxResourceClientToShowInMemoryInfra) {
827 builder.append(" / and ");
828 builder.appendNumber(clientNames.size() - kMaxResourceClientToShowIn MemoryInfra);
829 builder.append(" more");
830 }
831 dump->addString("ResourceClient", "", builder.toString());
754 } 832 }
755 833
756 const String overheadName = dumpName + "/metadata"; 834 const String overheadName = dumpName + "/metadata";
757 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump (overheadName); 835 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump (overheadName);
758 overheadDump->addScalar("size", "bytes", overheadSize()); 836 overheadDump->addScalar("size", "bytes", overheadSize());
759 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k AllocatedObjectPoolName)); 837 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k AllocatedObjectPoolName));
760 } 838 }
761 839
762 String Resource::getMemoryDumpName() const 840 String Resource::getMemoryDumpName() const
763 { 841 {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 return "ImportResource"; 1147 return "ImportResource";
1070 case Resource::Media: 1148 case Resource::Media:
1071 return "Media"; 1149 return "Media";
1072 } 1150 }
1073 ASSERT_NOT_REACHED(); 1151 ASSERT_NOT_REACHED();
1074 return "Unknown"; 1152 return "Unknown";
1075 } 1153 }
1076 #endif // !LOG_DISABLED 1154 #endif // !LOG_DISABLED
1077 1155
1078 } // namespace blink 1156 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698