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

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

Issue 2411243004: [WeakMemoryCache] Remove LRU lists, prune order control and live/dead distinction (Closed)
Patch Set: reflect yhirano comments Created 4 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 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 rights reserved. 7 rights reserved.
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 if (m_preloadDiscoveryTime) { 698 if (m_preloadDiscoveryTime) {
699 int timeSinceDiscovery = static_cast<int>( 699 int timeSinceDiscovery = static_cast<int>(
700 1000 * (monotonicallyIncreasingTime() - m_preloadDiscoveryTime)); 700 1000 * (monotonicallyIncreasingTime() - m_preloadDiscoveryTime));
701 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDiscoveryHistogram, 701 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDiscoveryHistogram,
702 ("PreloadScanner.ReferenceTime", 0, 10000, 50)); 702 ("PreloadScanner.ReferenceTime", 0, 10000, 50));
703 preloadDiscoveryHistogram.count(timeSinceDiscovery); 703 preloadDiscoveryHistogram.count(timeSinceDiscovery);
704 } 704 }
705 } 705 }
706 if (!hasClientsOrObservers()) { 706 if (!hasClientsOrObservers()) {
707 m_isAlive = true; 707 m_isAlive = true;
708 memoryCache()->makeLive(this);
709 } 708 }
710 } 709 }
711 710
712 void Resource::addClient(ResourceClient* client, 711 void Resource::addClient(ResourceClient* client,
713 PreloadReferencePolicy policy) { 712 PreloadReferencePolicy policy) {
714 CHECK(!m_isAddRemoveClientProhibited); 713 CHECK(!m_isAddRemoveClientProhibited);
715 714
716 willAddClientOrObserver(policy); 715 willAddClientOrObserver(policy);
717 716
718 if (m_isRevalidating) { 717 if (m_isRevalidating) {
(...skipping 30 matching lines...) Expand all
749 748
750 if (m_clientsAwaitingCallback.isEmpty()) 749 if (m_clientsAwaitingCallback.isEmpty())
751 ResourceCallback::callbackHandler().cancel(this); 750 ResourceCallback::callbackHandler().cancel(this);
752 751
753 didRemoveClientOrObserver(); 752 didRemoveClientOrObserver();
754 } 753 }
755 754
756 void Resource::didRemoveClientOrObserver() { 755 void Resource::didRemoveClientOrObserver() {
757 if (!hasClientsOrObservers() && m_isAlive) { 756 if (!hasClientsOrObservers() && m_isAlive) {
758 m_isAlive = false; 757 m_isAlive = false;
759 memoryCache()->makeDead(this);
760 allClientsAndObserversRemoved(); 758 allClientsAndObserversRemoved();
761 759
762 // RFC2616 14.9.2: 760 // RFC2616 14.9.2:
763 // "no-store: ... MUST make a best-effort attempt to remove the information 761 // "no-store: ... MUST make a best-effort attempt to remove the information
764 // from volatile storage as promptly as possible" 762 // from volatile storage as promptly as possible"
765 // "... History buffers MAY store such responses as part of their normal 763 // "... History buffers MAY store such responses as part of their normal
766 // operation." 764 // operation."
767 // We allow non-secure content to be reused in history, but we do not allow 765 // We allow non-secure content to be reused in history, but we do not allow
768 // secure content to be reused. 766 // secure content to be reused.
769 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) 767 if (hasCacheControlNoStoreHeader() && url().protocolIs("https"))
(...skipping 13 matching lines...) Expand all
783 if (!hasClientsOrObservers() && m_loader) 781 if (!hasClientsOrObservers() && m_loader)
784 m_loader->cancel(); 782 m_loader->cancel();
785 } 783 }
786 784
787 void Resource::setDecodedSize(size_t decodedSize) { 785 void Resource::setDecodedSize(size_t decodedSize) {
788 if (decodedSize == m_decodedSize) 786 if (decodedSize == m_decodedSize)
789 return; 787 return;
790 size_t oldSize = size(); 788 size_t oldSize = size();
791 m_decodedSize = decodedSize; 789 m_decodedSize = decodedSize;
792 memoryCache()->update(this, oldSize, size()); 790 memoryCache()->update(this, oldSize, size());
793 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange);
794 } 791 }
795 792
796 void Resource::setEncodedSize(size_t encodedSize) { 793 void Resource::setEncodedSize(size_t encodedSize) {
797 if (encodedSize == m_encodedSize && encodedSize == m_encodedSizeMemoryUsage) 794 if (encodedSize == m_encodedSize && encodedSize == m_encodedSizeMemoryUsage)
798 return; 795 return;
799 size_t oldSize = size(); 796 size_t oldSize = size();
800 m_encodedSize = encodedSize; 797 m_encodedSize = encodedSize;
801 m_encodedSizeMemoryUsage = encodedSize; 798 m_encodedSizeMemoryUsage = encodedSize;
802 memoryCache()->update(this, oldSize, size()); 799 memoryCache()->update(this, oldSize, size());
803 } 800 }
804 801
805 void Resource::setEncodedSizeMemoryUsage(size_t encodedSize) { 802 void Resource::setEncodedSizeMemoryUsage(size_t encodedSize) {
806 m_encodedSizeMemoryUsage = encodedSize; 803 m_encodedSizeMemoryUsage = encodedSize;
807 } 804 }
808 805
809 void Resource::didAccessDecodedData() {
810 memoryCache()->updateDecodedResource(this, UpdateForAccess);
811 }
812
813 void Resource::finishPendingClients() { 806 void Resource::finishPendingClients() {
814 // We're going to notify clients one by one. It is simple if the client does 807 // We're going to notify clients one by one. It is simple if the client does
815 // nothing. However there are a couple other things that can happen. 808 // nothing. However there are a couple other things that can happen.
816 // 809 //
817 // 1. Clients can be added during the loop. Make sure they are not processed. 810 // 1. Clients can be added during the loop. Make sure they are not processed.
818 // 2. Clients can be removed during the loop. Make sure they are always 811 // 2. Clients can be removed during the loop. Make sure they are always
819 // available to be removed. Also don't call removed clients or add them 812 // available to be removed. Also don't call removed clients or add them
820 // back. 813 // back.
821 // 814 //
822 // Handle case (1) by saving a list of clients to notify. A separate list also 815 // Handle case (1) by saving a list of clients to notify. A separate list also
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 case Resource::TextTrack: 1096 case Resource::TextTrack:
1104 case Resource::Media: 1097 case Resource::Media:
1105 case Resource::Manifest: 1098 case Resource::Manifest:
1106 return false; 1099 return false;
1107 } 1100 }
1108 NOTREACHED(); 1101 NOTREACHED();
1109 return false; 1102 return false;
1110 } 1103 }
1111 1104
1112 } // namespace blink 1105 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698