Chromium Code Reviews| Index: Source/core/fetch/Resource.cpp |
| diff --git a/Source/core/fetch/Resource.cpp b/Source/core/fetch/Resource.cpp |
| index e4096b63282f3c1579f9ff0e637c25deb02f6444..953d70246a2a8b0665f4f75c34bdc0f07a9a83e0 100644 |
| --- a/Source/core/fetch/Resource.cpp |
| +++ b/Source/core/fetch/Resource.cpp |
| @@ -478,14 +478,15 @@ void Resource::removeClient(ResourceClient* client) |
| if (m_clientsAwaitingCallback.contains(client)) { |
| ASSERT(!m_clients.contains(client)); |
| m_clientsAwaitingCallback.remove(client); |
| - if (m_clientsAwaitingCallback.isEmpty()) |
| - ResourceCallback::callbackHandler()->cancel(this); |
| } else { |
| - RELEASE_ASSERT(m_clients.contains(client)); |
| + ASSERT(m_clients.contains(client)); |
| m_clients.remove(client); |
| didRemoveClient(client); |
| } |
| + if (m_clientsAwaitingCallback.isEmpty()) |
| + ResourceCallback::callbackHandler()->cancel(this); |
| + |
| bool deleted = deleteIfPossible(); |
| if (!deleted && !hasClients()) { |
| memoryCache()->makeDead(this); |
| @@ -588,10 +589,11 @@ void Resource::finishPendingClients() |
| didAddClient(client); |
| } |
| - bool scheduled = ResourceCallback::callbackHandler()->isScheduled(this); |
| - // It is a critical problem if a callback is scheduled but there is no client waiting for it. |
| - // Such a callback cannot be cancelled. It is better to crash the renderer now. |
| - RELEASE_ASSERT(!scheduled || !m_clientsAwaitingCallback.isEmpty()); |
| + // It is still possible for the above loop to finish a new client synchronously. |
| + // If there's no client waiting we should deschedule. |
| + if (ResourceCallback::callbackHandler()->isScheduled(this) && m_clientsAwaitingCallback.isEmpty()) { |
|
Nate Chapin
2014/04/18 18:43:46
Style nit: the curly braces are unnecessary.
|
| + ResourceCallback::callbackHandler()->cancel(this); |
| + } |
| // Prevent the case when there are clients waiting but no callback scheduled. |
| ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); |