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 adf843dd7e9831f464f8fd72224979f566c5ea9f..dd87816afb9aa87dc8d1690751d34b5492685547 100644 |
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp |
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp |
@@ -341,14 +341,25 @@ void Resource::setLoader(ResourceLoader* loader) |
m_status = Pending; |
} |
-void Resource::checkNotify() |
+void Resource::checkNotify(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) |
@@ -381,14 +392,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,8 +406,7 @@ void Resource::error(const ResourceError& error) |
ASSERT(errorOccurred()); |
m_data.clear(); |
m_loader = nullptr; |
- checkNotify(); |
- markClientsAndObserversFinished(); |
+ checkNotify(MarkFinishedOption::ShouldMarkFinished); |
} |
void Resource::finish(double loadFinishTime) |
@@ -414,8 +416,7 @@ void Resource::finish(double loadFinishTime) |
if (!errorOccurred()) |
m_status = Cached; |
m_loader = nullptr; |
- checkNotify(); |
- markClientsAndObserversFinished(); |
+ checkNotify(MarkFinishedOption::ShouldMarkFinished); |
} |
AtomicString Resource::httpContentType() const |