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

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

Powered by Google App Engine
This is Rietveld 408576698