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

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: Fix 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 if (m_preloadDiscoveryTime) { 696 if (m_preloadDiscoveryTime) {
697 int timeSinceDiscovery = static_cast<int>( 697 int timeSinceDiscovery = static_cast<int>(
698 1000 * (monotonicallyIncreasingTime() - m_preloadDiscoveryTime)); 698 1000 * (monotonicallyIncreasingTime() - m_preloadDiscoveryTime));
699 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDiscoveryHistogram, 699 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDiscoveryHistogram,
700 ("PreloadScanner.ReferenceTime", 0, 10000, 50)); 700 ("PreloadScanner.ReferenceTime", 0, 10000, 50));
701 preloadDiscoveryHistogram.count(timeSinceDiscovery); 701 preloadDiscoveryHistogram.count(timeSinceDiscovery);
702 } 702 }
703 } 703 }
704 if (!hasClientsOrObservers()) { 704 if (!hasClientsOrObservers()) {
705 m_isAlive = true; 705 m_isAlive = true;
706 memoryCache()->makeLive(this);
707 } 706 }
708 } 707 }
709 708
710 void Resource::addClient(ResourceClient* client, 709 void Resource::addClient(ResourceClient* client,
711 PreloadReferencePolicy policy) { 710 PreloadReferencePolicy policy) {
712 CHECK(!m_isAddRemoveClientProhibited); 711 CHECK(!m_isAddRemoveClientProhibited);
713 712
714 willAddClientOrObserver(policy); 713 willAddClientOrObserver(policy);
715 714
716 if (m_isRevalidating) { 715 if (m_isRevalidating) {
(...skipping 30 matching lines...) Expand all
747 746
748 if (m_clientsAwaitingCallback.isEmpty()) 747 if (m_clientsAwaitingCallback.isEmpty())
749 ResourceCallback::callbackHandler().cancel(this); 748 ResourceCallback::callbackHandler().cancel(this);
750 749
751 didRemoveClientOrObserver(); 750 didRemoveClientOrObserver();
752 } 751 }
753 752
754 void Resource::didRemoveClientOrObserver() { 753 void Resource::didRemoveClientOrObserver() {
755 if (!hasClientsOrObservers() && m_isAlive) { 754 if (!hasClientsOrObservers() && m_isAlive) {
756 m_isAlive = false; 755 m_isAlive = false;
757 memoryCache()->makeDead(this);
758 allClientsAndObserversRemoved(); 756 allClientsAndObserversRemoved();
759 757
760 // RFC2616 14.9.2: 758 // RFC2616 14.9.2:
761 // "no-store: ... MUST make a best-effort attempt to remove the information 759 // "no-store: ... MUST make a best-effort attempt to remove the information
762 // from volatile storage as promptly as possible" 760 // from volatile storage as promptly as possible"
763 // "... History buffers MAY store such responses as part of their normal 761 // "... History buffers MAY store such responses as part of their normal
764 // operation." 762 // operation."
765 // We allow non-secure content to be reused in history, but we do not allow 763 // We allow non-secure content to be reused in history, but we do not allow
766 // secure content to be reused. 764 // secure content to be reused.
767 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) 765 if (hasCacheControlNoStoreHeader() && url().protocolIs("https"))
(...skipping 13 matching lines...) Expand all
781 if (!hasClientsOrObservers() && m_loader) 779 if (!hasClientsOrObservers() && m_loader)
782 m_loader->cancel(); 780 m_loader->cancel();
783 } 781 }
784 782
785 void Resource::setDecodedSize(size_t decodedSize) { 783 void Resource::setDecodedSize(size_t decodedSize) {
786 if (decodedSize == m_decodedSize) 784 if (decodedSize == m_decodedSize)
787 return; 785 return;
788 size_t oldSize = size(); 786 size_t oldSize = size();
789 m_decodedSize = decodedSize; 787 m_decodedSize = decodedSize;
790 memoryCache()->update(this, oldSize, size()); 788 memoryCache()->update(this, oldSize, size());
791 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange);
792 } 789 }
793 790
794 void Resource::setEncodedSize(size_t encodedSize) { 791 void Resource::setEncodedSize(size_t encodedSize) {
795 if (encodedSize == m_encodedSize && encodedSize == m_encodedSizeMemoryUsage) 792 if (encodedSize == m_encodedSize && encodedSize == m_encodedSizeMemoryUsage)
796 return; 793 return;
797 size_t oldSize = size(); 794 size_t oldSize = size();
798 m_encodedSize = encodedSize; 795 m_encodedSize = encodedSize;
799 m_encodedSizeMemoryUsage = encodedSize; 796 m_encodedSizeMemoryUsage = encodedSize;
800 memoryCache()->update(this, oldSize, size()); 797 memoryCache()->update(this, oldSize, size());
801 } 798 }
802 799
803 void Resource::setEncodedSizeMemoryUsage(size_t encodedSize) { 800 void Resource::setEncodedSizeMemoryUsage(size_t encodedSize) {
804 m_encodedSizeMemoryUsage = encodedSize; 801 m_encodedSizeMemoryUsage = encodedSize;
805 } 802 }
806 803
807 void Resource::didAccessDecodedData() {
808 memoryCache()->updateDecodedResource(this, UpdateForAccess);
809 }
810
811 void Resource::finishPendingClients() { 804 void Resource::finishPendingClients() {
812 // We're going to notify clients one by one. It is simple if the client does 805 // We're going to notify clients one by one. It is simple if the client does
813 // nothing. However there are a couple other things that can happen. 806 // nothing. However there are a couple other things that can happen.
814 // 807 //
815 // 1. Clients can be added during the loop. Make sure they are not processed. 808 // 1. Clients can be added during the loop. Make sure they are not processed.
816 // 2. Clients can be removed during the loop. Make sure they are always 809 // 2. Clients can be removed during the loop. Make sure they are always
817 // available to be removed. Also don't call removed clients or add them 810 // available to be removed. Also don't call removed clients or add them
818 // back. 811 // back.
819 // 812 //
820 // Handle case (1) by saving a list of clients to notify. A separate list also 813 // Handle case (1) by saving a list of clients to notify. A separate list also
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 case Resource::TextTrack: 1100 case Resource::TextTrack:
1108 case Resource::Media: 1101 case Resource::Media:
1109 case Resource::Manifest: 1102 case Resource::Manifest:
1110 return false; 1103 return false;
1111 } 1104 }
1112 NOTREACHED(); 1105 NOTREACHED();
1113 return false; 1106 return false;
1114 } 1107 }
1115 1108
1116 } // namespace blink 1109 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698