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

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: Rebase+ 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 if (cacheType == CachedMetadataHandler::SendToPlatform) 514 if (cacheType == CachedMetadataHandler::SendToPlatform)
515 Platform::current()->cacheMetadata(m_response.url(), m_response.response Time(), 0, 0); 515 Platform::current()->cacheMetadata(m_response.url(), m_response.response Time(), 0, 0);
516 } 516 }
517 517
518 bool Resource::canDelete() const 518 bool Resource::canDelete() const
519 { 519 {
520 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0) 520 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0)
521 && !m_protectorCount; 521 && !m_protectorCount;
522 } 522 }
523 523
524 String Resource::reasonNotDeletable() const
525 {
526 StringBuilder builder;
527 if (hasClients()) {
528 builder.append("hasClients(");
529 builder.appendNumber(m_clients.size());
530 if (!m_clientsAwaitingCallback.isEmpty()) {
531 builder.append(", AwaitingCallback=");
532 builder.appendNumber(m_clientsAwaitingCallback.size());
533 }
534 if (!m_finishedClients.isEmpty()) {
535 builder.append(", Finished=");
536 builder.appendNumber(m_finishedClients.size());
537 }
538 builder.append(")");
539 }
540 if (m_loader) {
541 if (!builder.isEmpty())
542 builder.append(' ');
543 builder.append("m_loader");
ssid 2015/10/30 07:00:31 Can we get rid of m_ and display more useful info
hiroshige 2015/10/30 07:34:33 I made the names to directly corresponding to the
kinuko 2015/11/02 07:41:57 Either looks fine with me given that it seems diff
ssid 2015/11/04 12:12:57 Sorry for the late reply. It is fine as it is, sin
544 }
545 if (m_preloadCount) {
546 if (!builder.isEmpty())
547 builder.append(' ');
548 builder.append("m_preloadCount(");
ssid 2015/10/30 07:00:31 preloaded_with_count or just preloaded, and simila
549 builder.appendNumber(m_preloadCount);
550 builder.append(")");
551 }
552 if (!hasRightHandleCountApartFromCache(0)) {
553 if (!builder.isEmpty())
554 builder.append(' ');
555 builder.append("m_handleCount(");
556 builder.appendNumber(m_handleCount);
557 builder.append(")");
558 }
559 if (m_protectorCount) {
560 if (!builder.isEmpty())
561 builder.append(' ');
562 builder.append("m_protectorCount(");
563 builder.appendNumber(m_protectorCount);
564 builder.append(")");
565 }
566 if (memoryCache()->contains(this)) {
567 if (!builder.isEmpty())
568 builder.append(' ');
569 builder.append("memoryCache");
ssid 2015/10/30 07:00:31 reason_not_deletable : memoryCache -> in_memory_ca
hiroshige 2015/10/30 07:34:33 Acknowledged.
hiroshige 2015/11/09 20:53:58 Done.
570 }
571 return builder.toString();
572 }
573
524 bool Resource::hasOneHandle() const 574 bool Resource::hasOneHandle() const
525 { 575 {
526 return hasRightHandleCountApartFromCache(1); 576 return hasRightHandleCountApartFromCache(1);
527 } 577 }
528 578
529 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const 579 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const
530 { 580 {
531 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) 581 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID)
532 return nullptr; 582 return nullptr;
533 return m_cachedMetadata.get(); 583 return m_cachedMetadata.get();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 781
732 void Resource::prune() 782 void Resource::prune()
733 { 783 {
734 destroyDecodedDataIfPossible(); 784 destroyDecodedDataIfPossible();
735 unlock(); 785 unlock();
736 } 786 }
737 787
738 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess MemoryDump* memoryDump) const 788 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcess MemoryDump* memoryDump) const
739 { 789 {
740 static const size_t kMaxURLReportLength = 128; 790 static const size_t kMaxURLReportLength = 128;
791 static const int kMaxResourceClientToShowInMemoryInfra = 10;
741 792
742 const String dumpName = getMemoryDumpName(); 793 const String dumpName = getMemoryDumpName();
743 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam e); 794 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam e);
744 dump->addScalar("encoded_size", "bytes", m_encodedSize); 795 dump->addScalar("encoded_size", "bytes", m_encodedSize);
745 if (canDelete()) { 796 if (canDelete()) {
746 dump->addScalar("dead_size", "bytes", m_encodedSize); 797 dump->addScalar("dead_size", "bytes", m_encodedSize);
747 } else { 798 } else {
748 dump->addScalar("live_size", "bytes", m_encodedSize); 799 dump->addScalar("live_size", "bytes", m_encodedSize);
749 } 800 }
750 801
751 if (m_data) { 802 if (m_data) {
752 dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0); 803 dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0);
753 m_data->onMemoryDump(dumpName, memoryDump); 804 m_data->onMemoryDump(dumpName, memoryDump);
754 } 805 }
755 806
756 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { 807 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
757 String urlToReport = url().string(); 808 String urlToReport = url().string();
758 if (urlToReport.length() > kMaxURLReportLength) { 809 if (urlToReport.length() > kMaxURLReportLength) {
759 urlToReport.truncate(kMaxURLReportLength); 810 urlToReport.truncate(kMaxURLReportLength);
760 urlToReport = urlToReport + "..."; 811 urlToReport = urlToReport + "...";
761 } 812 }
762 dump->addString("url", "", urlToReport); 813 dump->addString("url", "", urlToReport);
814
815 dump->addString("not_deletable_because", "", reasonNotDeletable());
ssid 2015/10/30 07:00:31 I think it is better to show "reason_not_deletable
hiroshige 2015/11/09 20:53:58 Done.
816
817 Vector<String> clientNames;
818 ResourceClientWalker<ResourceClient> w(m_clients);
819 while (ResourceClient* c = w.next())
820 clientNames.append(c->debugName());
821 ResourceClientWalker<ResourceClient> w2(m_clientsAwaitingCallback);
822 while (ResourceClient* c = w2.next())
823 clientNames.append("(awaiting) " + c->debugName());
824 ResourceClientWalker<ResourceClient> w3(m_finishedClients);
825 while (ResourceClient* c = w3.next())
826 clientNames.append("(finished) " + c->debugName());
827 std::sort(clientNames.begin(), clientNames.end(), codePointCompareLessTh an);
828
829 StringBuilder builder;
830 for (size_t i = 0; i < clientNames.size() && i < kMaxResourceClientToSho wInMemoryInfra; ++i) {
831 if (i > 0)
832 builder.append(" / ");
833 builder.append(clientNames[i]);
834 }
835 if (clientNames.size() > kMaxResourceClientToShowInMemoryInfra) {
836 builder.append(" / and ");
837 builder.appendNumber(clientNames.size() - kMaxResourceClientToShowIn MemoryInfra);
838 builder.append(" more");
839 }
840 dump->addString("ResourceClient", "", builder.toString());
763 } 841 }
764 842
765 const String overheadName = dumpName + "/metadata"; 843 const String overheadName = dumpName + "/metadata";
766 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump (overheadName); 844 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump (overheadName);
767 overheadDump->addScalar("size", "bytes", overheadSize()); 845 overheadDump->addScalar("size", "bytes", overheadSize());
768 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k AllocatedObjectPoolName)); 846 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k AllocatedObjectPoolName));
769 } 847 }
770 848
771 String Resource::getMemoryDumpName() const 849 String Resource::getMemoryDumpName() const
772 { 850 {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 return "ImportResource"; 1142 return "ImportResource";
1065 case Resource::Media: 1143 case Resource::Media:
1066 return "Media"; 1144 return "Media";
1067 } 1145 }
1068 ASSERT_NOT_REACHED(); 1146 ASSERT_NOT_REACHED();
1069 return "Unknown"; 1147 return "Unknown";
1070 } 1148 }
1071 #endif // !LOG_DISABLED 1149 #endif // !LOG_DISABLED
1072 1150
1073 } // namespace blink 1151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698