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) const | |
368 { | |
369 return m_handleCount == targetCount + memoryCache()->contains(this); | |
370 } | |
371 | |
372 void Resource::responseReceived(const ResourceResponse& response) | 367 void Resource::responseReceived(const ResourceResponse& response) |
373 { | 368 { |
374 setResponse(response); | 369 setResponse(response); |
375 m_responseTimestamp = currentTime(); | 370 m_responseTimestamp = currentTime(); |
376 String encoding = response.textEncodingName(); | 371 String encoding = response.textEncodingName(); |
377 if (!encoding.isNull()) | 372 if (!encoding.isNull()) |
378 setEncoding(encoding); | 373 setEncoding(encoding); |
379 | 374 |
380 if (!m_resourceToRevalidate) | 375 if (!m_resourceToRevalidate) |
381 return; | 376 return; |
(...skipping 19 matching lines...) Expand all Loading... |
401 // Currently, only one type of cached metadata per resource is supported. | 396 // Currently, only one type of cached metadata per resource is supported. |
402 // If the need arises for multiple types of metadata per resource this could | 397 // If the need arises for multiple types of metadata per resource this could |
403 // be enhanced to store types of metadata in a map. | 398 // be enhanced to store types of metadata in a map. |
404 ASSERT(!m_cachedMetadata); | 399 ASSERT(!m_cachedMetadata); |
405 | 400 |
406 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); | 401 m_cachedMetadata = CachedMetadata::create(dataTypeID, data, size); |
407 const Vector<char>& serializedData = m_cachedMetadata->serialize(); | 402 const Vector<char>& serializedData = m_cachedMetadata->serialize(); |
408 blink::Platform::current()->cacheMetadata(m_response.url(), m_response.respo
nseTime(), serializedData.data(), serializedData.size()); | 403 blink::Platform::current()->cacheMetadata(m_response.url(), m_response.respo
nseTime(), serializedData.data(), serializedData.size()); |
409 } | 404 } |
410 | 405 |
411 bool Resource::canDelete() const | |
412 { | |
413 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA
partFromCache(0) | |
414 && !m_protectorCount && !m_resourceToRevalidate && !m_proxyResource; | |
415 } | |
416 | |
417 bool Resource::hasOneHandleApartFromCache() const | |
418 { | |
419 return hasRightHandleCountApartFromCache(1); | |
420 } | |
421 | |
422 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const | 406 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const |
423 { | 407 { |
424 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) | 408 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
425 return 0; | 409 return 0; |
426 return m_cachedMetadata.get(); | 410 return m_cachedMetadata.get(); |
427 } | 411 } |
428 | 412 |
429 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) | 413 void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority) |
430 { | 414 { |
431 if (memoryCache()->contains(this) && memoryCache()->isInLiveDecodedResources
List(this) && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) { | 415 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... |
780 | 764 |
781 if (m_resourceToRevalidate) | 765 if (m_resourceToRevalidate) |
782 m_handlesToRevalidate.remove(h); | 766 m_handlesToRevalidate.remove(h); |
783 | 767 |
784 if (!m_handleCount) { | 768 if (!m_handleCount) { |
785 if (deleteIfPossible()) | 769 if (deleteIfPossible()) |
786 return; | 770 return; |
787 unlock(); | 771 unlock(); |
788 } else if (m_handleCount == 1 && memoryCache()->contains(this)) { | 772 } else if (m_handleCount == 1 && memoryCache()->contains(this)) { |
789 unlock(); | 773 unlock(); |
790 if (!hasClients()) | |
791 memoryCache()->prune(this); | |
792 } | 774 } |
793 } | 775 } |
794 | 776 |
795 bool Resource::canReuseRedirectChain() const | 777 bool Resource::canReuseRedirectChain() const |
796 { | 778 { |
797 for (size_t i = 0; i < m_redirectChain.size(); ++i) { | 779 for (size_t i = 0; i < m_redirectChain.size(); ++i) { |
798 if (!canUseResponse(m_redirectChain[i].m_redirectResponse, m_responseTim
estamp)) | 780 if (!canUseResponse(m_redirectChain[i].m_redirectResponse, m_responseTim
estamp)) |
799 return false; | 781 return false; |
800 } | 782 } |
801 return true; | 783 return true; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 return "Shader"; | 974 return "Shader"; |
993 case Resource::ImportResource: | 975 case Resource::ImportResource: |
994 return "ImportResource"; | 976 return "ImportResource"; |
995 } | 977 } |
996 ASSERT_NOT_REACHED(); | 978 ASSERT_NOT_REACHED(); |
997 return "Unknown"; | 979 return "Unknown"; |
998 } | 980 } |
999 #endif // !LOG_DISABLED | 981 #endif // !LOG_DISABLED |
1000 | 982 |
1001 } | 983 } |
OLD | NEW |