void CachedResource::removeClient(CachedResourceClient* client) { OwnPtr<CachedResourceCallback> callback = m_clientsAwaitingCallback.take(client); if (callback) { ASSERT(!m_clients.contains(client)); callback->cancel(); callback.clear(); } else { ASSERT(m_clients.contains(client)); m_clients.remove(client); didRemoveClient(client); } bool deleted = deleteIfPossible(); if (!deleted && !hasClients()) { if (inCache()) { memoryCache()->removeFromLiveResourcesSize(this); memoryCache()->removeFromLiveDecodedResourcesList(this); } if (!m_switchingClientsToRevalidatedResource) allClientsRemoved(); destroyDecodedDataIfNeeded(); if (response().cacheControlContainsNoStore() && url().protocolIs("https")) { // RFC2616 14.9.2: // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible" // "... History buffers MAY store such responses as part of their normal operation." // We allow non-secure content to be reused in history, but we do not allow secure content to be reused. memoryCache()->remove(this); } memoryCache()->prune(); } // This object may be dead here. }
void Resource::removeClient(ResourceClient* client) { ASSERT(hasClient(client)); if (m_finishedClients.contains(client)) m_finishedClients.remove(client); else if (m_clientsAwaitingCallback.contains(client)) m_clientsAwaitingCallback.remove(client); else m_clients.remove(client); didRemoveClient(client); if (m_clientsAwaitingCallback.isEmpty()) ResourceCallback::callbackHandler()->cancel(this); bool deleted = deleteIfPossible(); if (!deleted && !hasClients()) { memoryCache()->makeDead(this); if (!m_switchingClientsToRevalidatedResource) allClientsRemoved(); // RFC2616 14.9.2: // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible" // "... History buffers MAY store such responses as part of their normal operation." // We allow non-secure content to be reused in history, but we do not allow secure content to be reused. if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { memoryCache()->remove(this); memoryCache()->prune(); } else { memoryCache()->prune(this); } } // This object may be dead here. }
void CachedResource::clearLoader() { ASSERT(m_loader); m_identifierForLoadWithoutResourceLoader = m_loader->identifier(); m_loader = nullptr; deleteIfPossible(); }
void CachedResource::unregisterHandle(CachedResourceHandleBase* h) { ASSERT(m_handleCount > 0); --m_handleCount; if (m_resourceToRevalidate) m_handlesToRevalidate.remove(h); if (!m_handleCount) deleteIfPossible(); }
void CachedResource::clearResourceToRevalidate() { ASSERT(m_resourceToRevalidate); if (m_switchingClientsToRevalidatedResource) return; // A resource may start revalidation before this method has been called, so check that this resource is still the proxy resource before clearing it out. if (m_resourceToRevalidate->m_proxyResource == this) { m_resourceToRevalidate->m_proxyResource = 0; m_resourceToRevalidate->deleteIfPossible(); } m_handlesToRevalidate.clear(); m_resourceToRevalidate = 0; deleteIfPossible(); }
void CachedResource::clearResourceToRevalidate() { ASSERT(m_resourceToRevalidate); ASSERT(m_resourceToRevalidate->m_proxyResource == this); if (m_switchingClientsToRevalidatedResource) return; m_resourceToRevalidate->m_proxyResource = nullptr; m_resourceToRevalidate->deleteIfPossible(); m_handlesToRevalidate.clear(); m_resourceToRevalidate = nullptr; deleteIfPossible(); }
void Resource::unregisterHandle(ResourcePtrBase* h) { assertAlive(); ASSERT(m_handleCount > 0); --m_handleCount; if (!m_handleCount) { if (deleteIfPossible()) return; unlock(); } else if (m_handleCount == 1 && memoryCache()->contains(this)) { unlock(); if (!hasClients()) memoryCache()->prune(this); } }
void CachedResource::removeClient(CachedResourceClient& client) { auto callback = m_clientsAwaitingCallback.take(&client); if (callback) { ASSERT(!m_clients.contains(&client)); callback->cancel(); callback = nullptr; } else { ASSERT(m_clients.contains(&client)); m_clients.remove(&client); didRemoveClient(client); } if (deleteIfPossible()) { // `this` object is dead here. return; } if (hasClients()) return; auto& memoryCache = MemoryCache::singleton(); if (allowsCaching() && inCache()) { memoryCache.removeFromLiveResourcesSize(*this); memoryCache.removeFromLiveDecodedResourcesList(*this); } if (!m_switchingClientsToRevalidatedResource) allClientsRemoved(); destroyDecodedDataIfNeeded(); if (!allowsCaching()) return; if (response().cacheControlContainsNoStore() && url().protocolIs("https")) { // RFC2616 14.9.2: // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible" // "... History buffers MAY store such responses as part of their normal operation." // We allow non-secure content to be reused in history, but we do not allow secure content to be reused. memoryCache.remove(*this); } memoryCache.pruneSoon(); }