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

Unified Diff: third_party/WebKit/Source/core/fetch/Resource.cpp

Issue 1706083002: Split ImageResourceClient into ResourceClient and ImageResourceObserver [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More consistent Client/Observer Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/Resource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp
index fb32fc9cb99bbfe20480f148aad71201944379dc..02bbcd6bf51327b8497d40a78f3b0e7769541f28 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -594,10 +594,9 @@ static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type)
return false;
}
-void Resource::addClient(ResourceClient* client)
+void Resource::willAddClient()
{
ASSERT(!isPurgeable());
-
if (m_preloadResult == PreloadNotReferenced) {
if (isLoaded())
m_preloadResult = PreloadReferencedWhileComplete;
@@ -608,6 +607,11 @@ void Resource::addClient(ResourceClient* client)
}
if (!hasClients())
memoryCache()->makeLive(this);
+}
+
+void Resource::addClient(ResourceClient* client)
+{
+ willAddClient();
if (!m_revalidatingRequest.isNull()) {
m_clients.add(client);
@@ -636,11 +640,15 @@ void Resource::removeClient(ResourceClient* client)
else
m_clients.remove(client);
- didRemoveClient(client);
-
if (m_clientsAwaitingCallback.isEmpty())
ResourceCallback::callbackHandler()->cancel(this);
+ didRemoveClient();
+ // This object may be dead here.
+}
+
+void Resource::didRemoveClient()
+{
if (!hasClients()) {
RefPtrWillBeRawPtr<Resource> protect(this);
memoryCache()->makeDead(this);
@@ -914,20 +922,6 @@ void Resource::didChangePriority(ResourceLoadPriority loadPriority, int intraPri
m_loader->didChangePriority(loadPriority, intraPriorityValue);
}
-ResourcePriority Resource::priorityFromClients()
-{
- ResourcePriority priority;
- ResourceClientWalker<ResourceClient> walker(m_clients);
- while (ResourceClient* c = walker.next()) {
- ResourcePriority nextPriority = c->computeResourcePriority();
- if (nextPriority.visibility == ResourcePriority::NotVisible)
- continue;
- priority.visibility = ResourcePriority::Visible;
- priority.intraPriorityValue += nextPriority.intraPriorityValue;
- }
- return priority;
-}
-
Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler()
{
// Oilpan + LSan: as the callbackHandler() singleton is used by Resource

Powered by Google App Engine
This is Rietveld 408576698