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

Side by Side Diff: Source/core/fetch/Resource.h

Issue 179943002: MemoryCache: make sure that Resources are evicted only when they can be deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 8 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 unified diff | Download patch
« no previous file with comments | « Source/core/fetch/MemoryCacheTest.cpp ('k') | Source/core/fetch/Resource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void setSerializedCachedMetadata(const char*, size_t); 190 void setSerializedCachedMetadata(const char*, size_t);
191 191
192 // Caches the given metadata in association with this resource and suggests 192 // Caches the given metadata in association with this resource and suggests
193 // that the platform persist it. The dataTypeID is a pseudo-randomly chosen 193 // that the platform persist it. The dataTypeID is a pseudo-randomly chosen
194 // identifier that is used to distinguish data generated by the caller. 194 // identifier that is used to distinguish data generated by the caller.
195 void setCachedMetadata(unsigned dataTypeID, const char*, size_t); 195 void setCachedMetadata(unsigned dataTypeID, const char*, size_t);
196 196
197 // Returns cached metadata of the given type associated with this resource. 197 // Returns cached metadata of the given type associated with this resource.
198 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; 198 CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
199 199
200 bool canDelete() const { return !hasClients() && !m_loader && !m_preloadCoun t && !m_handleCount && !m_protectorCount && !m_resourceToRevalidate && !m_proxyR esource; } 200 bool canDelete() const;
201 bool hasOneHandle() const { return m_handleCount == 1; } 201 bool hasOneHandleApartFromCache() const;
202 202
203 // List of acceptable MIME types separated by ",". 203 // List of acceptable MIME types separated by ",".
204 // A MIME type may contain a wildcard, e.g. "text/*". 204 // A MIME type may contain a wildcard, e.g. "text/*".
205 AtomicString accept() const { return m_accept; } 205 AtomicString accept() const { return m_accept; }
206 void setAccept(const AtomicString& accept) { m_accept = accept; } 206 void setAccept(const AtomicString& accept) { m_accept = accept; }
207 207
208 bool wasCanceled() const { return m_error.isCancellation(); } 208 bool wasCanceled() const { return m_error.isCancellation(); }
209 bool errorOccurred() const { return m_status == LoadError || m_status == Dec odeError; } 209 bool errorOccurred() const { return m_status == LoadError || m_status == Dec odeError; }
210 bool loadFailedOrCanceled() { return !m_error.isNull(); } 210 bool loadFailedOrCanceled() { return !m_error.isNull(); }
211 211
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 private: 336 private:
337 bool addClientToSet(ResourceClient*); 337 bool addClientToSet(ResourceClient*);
338 void cancelTimerFired(Timer<Resource>*); 338 void cancelTimerFired(Timer<Resource>*);
339 339
340 void revalidationSucceeded(const ResourceResponse&); 340 void revalidationSucceeded(const ResourceResponse&);
341 void revalidationFailed(); 341 void revalidationFailed();
342 342
343 bool unlock(); 343 bool unlock();
344 344
345 bool hasRightHandleCountApartFromCache(unsigned targetCount) const;
346
345 void failBeforeStarting(); 347 void failBeforeStarting();
346 348
347 String m_fragmentIdentifierForRequest; 349 String m_fragmentIdentifierForRequest;
348 350
349 RefPtr<CachedMetadata> m_cachedMetadata; 351 RefPtr<CachedMetadata> m_cachedMetadata;
350 352
351 ResourceError m_error; 353 ResourceError m_error;
352 354
353 double m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache 355 double m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache
354 double m_loadFinishTime; 356 double m_loadFinishTime;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 const char* ResourceTypeName(Resource::Type); 403 const char* ResourceTypeName(Resource::Type);
402 #endif 404 #endif
403 405
404 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 406 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
405 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \ 407 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \
406 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); } 408 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); }
407 409
408 } 410 }
409 411
410 #endif 412 #endif
OLDNEW
« no previous file with comments | « Source/core/fetch/MemoryCacheTest.cpp ('k') | Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698