OLD | NEW |
---|---|
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) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 if (!m_data->isLocked()) | 357 if (!m_data->isLocked()) |
358 return true; | 358 return true; |
359 | 359 |
360 if (!memoryCache()->contains(this) || hasClients() || m_handleCount > 1 || m _proxyResource || m_resourceToRevalidate || !m_loadFinishTime || !isSafeToUnlock ()) | 360 if (!memoryCache()->contains(this) || hasClients() || m_handleCount > 1 || m _proxyResource || m_resourceToRevalidate || !m_loadFinishTime || !isSafeToUnlock ()) |
361 return false; | 361 return false; |
362 | 362 |
363 m_data->unlock(); | 363 m_data->unlock(); |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
367 bool Resource::hasRightHandleCountApartFromCache(unsigned targetCount) | |
368 { | |
369 bool inCache = memoryCache()->contains(this); | |
370 return (inCache && m_handleCount == targetCount + 1) || (!inCache && m_handl eCount == targetCount); | |
Philippe
2014/03/26 16:04:07
Nit: not sure this is more readable but in case yo
Philippe
2014/03/26 17:08:33
You might not even need the '!!' though. We usuall
clamy
2014/03/27 10:47:16
Done.
| |
371 } | |
372 | |
367 void Resource::responseReceived(const ResourceResponse& response) | 373 void Resource::responseReceived(const ResourceResponse& response) |
368 { | 374 { |
369 setResponse(response); | 375 setResponse(response); |
370 m_responseTimestamp = currentTime(); | 376 m_responseTimestamp = currentTime(); |
371 String encoding = response.textEncodingName(); | 377 String encoding = response.textEncodingName(); |
372 if (!encoding.isNull()) | 378 if (!encoding.isNull()) |
373 setEncoding(encoding); | 379 setEncoding(encoding); |
374 | 380 |
375 if (!m_resourceToRevalidate) | 381 if (!m_resourceToRevalidate) |
376 return; | 382 return; |
(...skipping 19 matching lines...) Expand all Loading... | |
396 // Currently, only one type of cached metadata per resource is supported. | 402 // Currently, only one type of cached metadata per resource is supported. |
397 // If the need arises for multiple types of metadata per resource this could | 403 // If the need arises for multiple types of metadata per resource this could |
398 // be enhanced to store types of metadata in a map. | 404 // be enhanced to store types of metadata in a map. |
399 ASSERT(!m_cachedMetadata); | 405 ASSERT(!m_cachedMetadata); |
400 | 406 |
401 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); | 407 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); |
402 const Vector<char>& serializedData = m_cachedMetadata->serialize(); | 408 const Vector<char>& serializedData = m_cachedMetadata->serialize(); |
403 blink::Platform::current()->cacheMetadata(m_response.url(), m_response.respo nseTime(), serializedData.data(), serializedData.size()); | 409 blink::Platform::current()->cacheMetadata(m_response.url(), m_response.respo nseTime(), serializedData.data(), serializedData.size()); |
404 } | 410 } |
405 | 411 |
412 bool Resource::canDelete() | |
413 { | |
414 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0) | |
415 && !m_protectorCount && !m_resourceToRevalidate && !m_proxyResource; | |
416 } | |
417 | |
418 bool Resource::hasOneHandleApartFromCache() | |
419 { | |
420 return hasRightHandleCountApartFromCache(1); | |
421 } | |
422 | |
406 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const | 423 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const |
407 { | 424 { |
408 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) | 425 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
409 return 0; | 426 return 0; |
410 return m_cachedMetadata.get(); | 427 return m_cachedMetadata.get(); |
411 } | 428 } |
412 | 429 |
413 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) | 430 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) |
414 { | 431 { |
415 if (memoryCache()->contains(this) && memoryCache()->isInLiveDecodedResources List(this) && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) { | 432 if (memoryCache()->contains(this) && memoryCache()->isInLiveDecodedResources List(this) && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 | 781 |
765 if (m_resourceToRevalidate) | 782 if (m_resourceToRevalidate) |
766 m_handlesToRevalidate.remove(h); | 783 m_handlesToRevalidate.remove(h); |
767 | 784 |
768 if (!m_handleCount) { | 785 if (!m_handleCount) { |
769 if (deleteIfPossible()) | 786 if (deleteIfPossible()) |
770 return; | 787 return; |
771 unlock(); | 788 unlock(); |
772 } else if (m_handleCount == 1 && memoryCache()->contains(this)) { | 789 } else if (m_handleCount == 1 && memoryCache()->contains(this)) { |
773 unlock(); | 790 unlock(); |
791 if (!hasClients()) | |
Philippe
2014/03/26 16:04:07
Nit: Do we still need this change?
clamy
2014/03/27 10:47:16
Yes this is what is making it work with the rebase
| |
792 memoryCache()->prune(this); | |
774 } | 793 } |
775 } | 794 } |
776 | 795 |
777 bool Resource::canReuseRedirectChain() const | 796 bool Resource::canReuseRedirectChain() const |
778 { | 797 { |
779 for (size_t i = 0; i < m_redirectChain.size(); ++i) { | 798 for (size_t i = 0; i < m_redirectChain.size(); ++i) { |
780 if (!canUseResponse(m_redirectChain[i].m_redirectResponse, m_responseTim estamp)) | 799 if (!canUseResponse(m_redirectChain[i].m_redirectResponse, m_responseTim estamp)) |
781 return false; | 800 return false; |
782 } | 801 } |
783 return true; | 802 return true; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
974 return "Shader"; | 993 return "Shader"; |
975 case Resource::ImportResource: | 994 case Resource::ImportResource: |
976 return "ImportResource"; | 995 return "ImportResource"; |
977 } | 996 } |
978 ASSERT_NOT_REACHED(); | 997 ASSERT_NOT_REACHED(); |
979 return "Unknown"; | 998 return "Unknown"; |
980 } | 999 } |
981 #endif // !LOG_DISABLED | 1000 #endif // !LOG_DISABLED |
982 | 1001 |
983 } | 1002 } |
OLD | NEW |