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

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

Issue 174523002: Reland "Move MemoryCache implementation details out of Resource" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/Resource.h ('k') | Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 , m_loadFinishTime(0) 101 , m_loadFinishTime(0)
102 , m_identifier(0) 102 , m_identifier(0)
103 , m_encodedSize(0) 103 , m_encodedSize(0)
104 , m_decodedSize(0) 104 , m_decodedSize(0)
105 , m_accessCount(0) 105 , m_accessCount(0)
106 , m_handleCount(0) 106 , m_handleCount(0)
107 , m_preloadCount(0) 107 , m_preloadCount(0)
108 , m_protectorCount(0) 108 , m_protectorCount(0)
109 , m_preloadResult(PreloadNotReferenced) 109 , m_preloadResult(PreloadNotReferenced)
110 , m_cacheLiveResourcePriority(CacheLiveResourcePriorityLow) 110 , m_cacheLiveResourcePriority(CacheLiveResourcePriorityLow)
111 , m_inLiveDecodedResourcesList(false)
112 , m_requestedFromNetworkingLayer(false) 111 , m_requestedFromNetworkingLayer(false)
113 , m_inCache(false) 112 , m_inCache(false)
114 , m_loading(false) 113 , m_loading(false)
115 , m_switchingClientsToRevalidatedResource(false) 114 , m_switchingClientsToRevalidatedResource(false)
116 , m_type(type) 115 , m_type(type)
117 , m_status(Pending) 116 , m_status(Pending)
118 , m_wasPurged(false) 117 , m_wasPurged(false)
119 , m_needsSynchronousCacheHit(false) 118 , m_needsSynchronousCacheHit(false)
120 #ifndef NDEBUG 119 #ifndef NDEBUG
121 , m_deleted(false) 120 , m_deleted(false)
122 , m_lruIndex(0)
123 #endif 121 #endif
124 , m_nextInAllResourcesList(0)
125 , m_prevInAllResourcesList(0)
126 , m_nextInLiveResourcesList(0)
127 , m_prevInLiveResourcesList(0)
128 , m_resourceToRevalidate(0) 122 , m_resourceToRevalidate(0)
129 , m_proxyResource(0) 123 , m_proxyResource(0)
130 { 124 {
131 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum. 125 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum.
132 #ifndef NDEBUG 126 #ifndef NDEBUG
133 cachedResourceLeakCounter.increment(); 127 cachedResourceLeakCounter.increment();
134 #endif 128 #endif
135 129
136 if (!m_resourceRequest.url().hasFragmentIdentifier()) 130 if (!m_resourceRequest.url().hasFragmentIdentifier())
137 return; 131 return;
138 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR equest.url()); 132 KURL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceR equest.url());
139 if (urlForCache.hasFragmentIdentifier()) 133 if (urlForCache.hasFragmentIdentifier())
140 return; 134 return;
141 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier( ); 135 m_fragmentIdentifierForRequest = m_resourceRequest.url().fragmentIdentifier( );
142 m_resourceRequest.setURL(urlForCache); 136 m_resourceRequest.setURL(urlForCache);
143 } 137 }
144 138
145 Resource::~Resource() 139 Resource::~Resource()
146 { 140 {
147 ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() check s this. 141 ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() check s this.
148 ASSERT(canDelete()); 142 ASSERT(canDelete());
149 ASSERT(!inCache()); 143 RELEASE_ASSERT(!inCache());
150 ASSERT(!m_deleted); 144 ASSERT(!m_deleted);
151 ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this); 145 ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this);
152 146
153 #ifndef NDEBUG 147 #ifndef NDEBUG
154 m_deleted = true; 148 m_deleted = true;
155 cachedResourceLeakCounter.decrement(); 149 cachedResourceLeakCounter.decrement();
156 #endif 150 #endif
157 } 151 }
158 152
159 void Resource::failBeforeStarting() 153 void Resource::failBeforeStarting()
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 399
406 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const 400 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const
407 { 401 {
408 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) 402 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID)
409 return 0; 403 return 0;
410 return m_cachedMetadata.get(); 404 return m_cachedMetadata.get();
411 } 405 }
412 406
413 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) 407 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority)
414 { 408 {
415 if (inCache() && m_inLiveDecodedResourcesList && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) { 409 if (inCache() && memoryCache()->isInLiveDecodedResourcesList(this) && cacheL iveResourcePriority() != static_cast<unsigned>(priority)) {
416 memoryCache()->removeFromLiveDecodedResourcesList(this); 410 memoryCache()->removeFromLiveDecodedResourcesList(this);
417 m_cacheLiveResourcePriority = priority; 411 m_cacheLiveResourcePriority = priority;
418 memoryCache()->insertInLiveDecodedResourcesList(this); 412 memoryCache()->insertInLiveDecodedResourcesList(this);
419 memoryCache()->prune(); 413 memoryCache()->prune();
420 } 414 }
421 } 415 }
422 416
423 void Resource::clearLoader() 417 void Resource::clearLoader()
424 { 418 {
425 m_loader = nullptr; 419 m_loader = nullptr;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // Now insert into the new LRU list. 562 // Now insert into the new LRU list.
569 memoryCache()->insertInLRUList(this); 563 memoryCache()->insertInLRUList(this);
570 564
571 // Insert into or remove from the live decoded list if necessary. 565 // Insert into or remove from the live decoded list if necessary.
572 // When inserting into the LiveDecodedResourcesList it is possible 566 // When inserting into the LiveDecodedResourcesList it is possible
573 // that the m_lastDecodedAccessTime is still zero or smaller than 567 // that the m_lastDecodedAccessTime is still zero or smaller than
574 // the m_lastDecodedAccessTime of the current list head. This is a 568 // the m_lastDecodedAccessTime of the current list head. This is a
575 // violation of the invariant that the list is to be kept sorted 569 // violation of the invariant that the list is to be kept sorted
576 // by access time. The weakening of the invariant does not pose 570 // by access time. The weakening of the invariant does not pose
577 // a problem. For more details please see: https://bugs.webkit.org/show_ bug.cgi?id=30209 571 // a problem. For more details please see: https://bugs.webkit.org/show_ bug.cgi?id=30209
578 if (m_decodedSize && !m_inLiveDecodedResourcesList && hasClients()) 572 if (m_decodedSize && !memoryCache()->isInLiveDecodedResourcesList(this) && hasClients())
579 memoryCache()->insertInLiveDecodedResourcesList(this); 573 memoryCache()->insertInLiveDecodedResourcesList(this);
580 else if (!m_decodedSize && m_inLiveDecodedResourcesList) 574 else if (!m_decodedSize && memoryCache()->isInLiveDecodedResourcesList(t his))
581 memoryCache()->removeFromLiveDecodedResourcesList(this); 575 memoryCache()->removeFromLiveDecodedResourcesList(this);
582 576
583 // Update the cache's size totals. 577 // Update the cache's size totals.
584 memoryCache()->adjustSize(hasClients(), delta); 578 memoryCache()->adjustSize(hasClients(), delta);
585 } 579 }
586 } 580 }
587 581
588 void Resource::setEncodedSize(size_t size) 582 void Resource::setEncodedSize(size_t size)
589 { 583 {
590 if (size == m_encodedSize) 584 if (size == m_encodedSize)
(...skipping 15 matching lines...) Expand all
606 600
607 // Update the cache's size totals. 601 // Update the cache's size totals.
608 memoryCache()->adjustSize(hasClients(), delta); 602 memoryCache()->adjustSize(hasClients(), delta);
609 } 603 }
610 } 604 }
611 605
612 void Resource::didAccessDecodedData(double timeStamp) 606 void Resource::didAccessDecodedData(double timeStamp)
613 { 607 {
614 m_lastDecodedAccessTime = timeStamp; 608 m_lastDecodedAccessTime = timeStamp;
615 if (inCache()) { 609 if (inCache()) {
616 if (m_inLiveDecodedResourcesList) { 610 if (memoryCache()->isInLiveDecodedResourcesList(this)) {
617 memoryCache()->removeFromLiveDecodedResourcesList(this); 611 memoryCache()->removeFromLiveDecodedResourcesList(this);
618 memoryCache()->insertInLiveDecodedResourcesList(this); 612 memoryCache()->insertInLiveDecodedResourcesList(this);
619 } 613 }
620 memoryCache()->prune(); 614 memoryCache()->prune();
621 } 615 }
622 } 616 }
623 617
624 void Resource::finishPendingClients() 618 void Resource::finishPendingClients()
625 { 619 {
626 while (!m_clientsAwaitingCallback.isEmpty()) { 620 while (!m_clientsAwaitingCallback.isEmpty()) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 return "Shader"; 986 return "Shader";
993 case Resource::ImportResource: 987 case Resource::ImportResource:
994 return "ImportResource"; 988 return "ImportResource";
995 } 989 }
996 ASSERT_NOT_REACHED(); 990 ASSERT_NOT_REACHED();
997 return "Unknown"; 991 return "Unknown";
998 } 992 }
999 #endif // !LOG_DISABLED 993 #endif // !LOG_DISABLED
1000 994
1001 } 995 }
OLDNEW
« no previous file with comments | « Source/core/fetch/Resource.h ('k') | Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698