| 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 dbb8562fdd1443bd6c9ea20ac00e11804238bca3..af2b8840deb80fd62209e70391f228b40fc7b4f2 100644
|
| --- a/third_party/WebKit/Source/core/fetch/Resource.cpp
|
| +++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
|
| @@ -433,7 +433,7 @@ bool Resource::unlock()
|
| if (!m_data->isLocked())
|
| return true;
|
|
|
| - if (!memoryCache()->contains(this) || hasClients() || !m_revalidatingRequest.isNull() || !m_loadFinishTime || !isSafeToUnlock())
|
| + if (!memoryCache()->contains(this) || hasClientsOrObservers() || !m_revalidatingRequest.isNull() || !m_loadFinishTime || !isSafeToUnlock())
|
| return false;
|
|
|
| m_data->unlock();
|
| @@ -513,7 +513,7 @@ WeakPtrWillBeRawPtr<Resource> Resource::asWeakPtr()
|
| String Resource::reasonNotDeletable() const
|
| {
|
| StringBuilder builder;
|
| - if (hasClients()) {
|
| + if (hasClientsOrObservers()) {
|
| builder.append("hasClients(");
|
| builder.appendNumber(m_clients.size());
|
| if (!m_clientsAwaitingCallback.isEmpty()) {
|
| @@ -588,10 +588,9 @@ static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type)
|
| return false;
|
| }
|
|
|
| -void Resource::addClient(ResourceClient* client)
|
| +void Resource::willAddClientOrObserver()
|
| {
|
| ASSERT(!isPurgeable());
|
| -
|
| if (m_preloadResult == PreloadNotReferenced) {
|
| if (isLoaded())
|
| m_preloadResult = PreloadReferencedWhileComplete;
|
| @@ -600,8 +599,13 @@ void Resource::addClient(ResourceClient* client)
|
| else
|
| m_preloadResult = PreloadReferenced;
|
| }
|
| - if (!hasClients())
|
| + if (!hasClientsOrObservers())
|
| memoryCache()->makeLive(this);
|
| +}
|
| +
|
| +void Resource::addClient(ResourceClient* client)
|
| +{
|
| + willAddClientOrObserver();
|
|
|
| if (!m_revalidatingRequest.isNull()) {
|
| m_clients.add(client);
|
| @@ -630,15 +634,19 @@ void Resource::removeClient(ResourceClient* client)
|
| else
|
| m_clients.remove(client);
|
|
|
| - didRemoveClient(client);
|
| -
|
| if (m_clientsAwaitingCallback.isEmpty())
|
| ResourceCallback::callbackHandler()->cancel(this);
|
|
|
| - if (!hasClients()) {
|
| + didRemoveClientOrObserver();
|
| + // This object may be dead here.
|
| +}
|
| +
|
| +void Resource::didRemoveClientOrObserver()
|
| +{
|
| + if (!hasClientsOrObservers()) {
|
| RefPtrWillBeRawPtr<Resource> protect(this);
|
| memoryCache()->makeDead(this);
|
| - allClientsRemoved();
|
| + allClientsAndObserversRemoved();
|
|
|
| // RFC2616 14.9.2:
|
| // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
|
| @@ -654,7 +662,7 @@ void Resource::removeClient(ResourceClient* client)
|
| // This object may be dead here.
|
| }
|
|
|
| -void Resource::allClientsRemoved()
|
| +void Resource::allClientsAndObserversRemoved()
|
| {
|
| if (!m_loader)
|
| return;
|
| @@ -669,7 +677,7 @@ void Resource::allClientsRemoved()
|
| void Resource::cancelTimerFired(Timer<Resource>* timer)
|
| {
|
| ASSERT_UNUSED(timer, timer == &m_cancelTimer);
|
| - if (hasClients() || !m_loader)
|
| + if (hasClientsOrObservers() || !m_loader)
|
| return;
|
| RefPtrWillBeRawPtr<Resource> protect(this);
|
| m_loader->cancelIfNotFinishing();
|
| @@ -885,7 +893,7 @@ bool Resource::lock()
|
| if (m_data->isLocked())
|
| return true;
|
|
|
| - ASSERT(!hasClients());
|
| + ASSERT(!hasClientsOrObservers());
|
|
|
| // If locking fails, our buffer has been purged. There's no point
|
| // in leaving a purged resource in MemoryCache.
|
| @@ -909,20 +917,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
|
|
|