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

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

Issue 2210473002: Mark ResourceClient/ImageResourceObserver finished just before notifying (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrap by 80 cols and Rebase. Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b3c7ec8ebbb71dd0aab5c29013d765809e0adee0..c9f92d5e06416c61257c48443dbeee45ea567d8e 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -342,12 +342,28 @@ void Resource::setLoader(ResourceLoader* loader)
void Resource::checkNotify()
{
+ notifyClientsInternal(MarkFinishedOption::ShouldMarkFinished);
+}
+
+void Resource::notifyClientsInternal(MarkFinishedOption markFinishedOption)
+{
if (isLoading())
return;
ResourceClientWalker<ResourceClient> w(m_clients);
- while (ResourceClient* c = w.next())
+ while (ResourceClient* c = w.next()) {
+ if (markFinishedOption == MarkFinishedOption::ShouldMarkFinished)
+ markClientFinished(c);
c->notifyFinished(this);
+ }
+}
+
+void Resource::markClientFinished(ResourceClient* client)
+{
+ if (m_clients.contains(client)) {
+ m_finishedClients.add(client);
+ m_clients.remove(client);
+ }
}
void Resource::appendData(const char* data, size_t length)
@@ -380,14 +396,6 @@ void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
setEncodedSize(0);
}
-void Resource::markClientsAndObserversFinished()
-{
- HashCountedSet<ResourceClient*> clients;
- m_clients.swap(clients);
- for (const auto& it : clients)
- m_finishedClients.add(it.key, it.value);
-}
-
void Resource::error(const ResourceError& error)
{
ASSERT(!error.isNull());
@@ -403,7 +411,6 @@ void Resource::error(const ResourceError& error)
m_data.clear();
m_loader = nullptr;
checkNotify();
- markClientsAndObserversFinished();
}
void Resource::finish(double loadFinishTime)
@@ -414,7 +421,6 @@ void Resource::finish(double loadFinishTime)
m_status = Cached;
m_loader = nullptr;
checkNotify();
- markClientsAndObserversFinished();
}
AtomicString Resource::httpContentType() const
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698