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

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

Powered by Google App Engine
This is Rietveld 408576698