| 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 | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 7 rights reserved. | 7 rights reserved. |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 void Resource::didAddClient(ResourceClient* c) { | 658 void Resource::didAddClient(ResourceClient* c) { |
| 659 if (isLoaded()) { | 659 if (isLoaded()) { |
| 660 c->notifyFinished(this); | 660 c->notifyFinished(this); |
| 661 if (m_clients.contains(c)) { | 661 if (m_clients.contains(c)) { |
| 662 m_finishedClients.add(c); | 662 m_finishedClients.add(c); |
| 663 m_clients.remove(c); | 663 m_clients.remove(c); |
| 664 } | 664 } |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type) { | 668 static bool typeNeedsSynchronousCacheHit(Resource::Type type) { |
| 669 // Some resources types default to return data synchronously. For most of | 669 // Some resources types default to return data synchronously. For most of |
| 670 // these, it's because there are layout tests that expect data to return | 670 // these, it's because there are layout tests that expect data to return |
| 671 // synchronously in case of cache hit. In the case of fonts, there was a | 671 // synchronously in case of cache hit. In the case of fonts, there was a |
| 672 // performance regression. | 672 // performance regression. |
| 673 // FIXME: Get to the point where we don't need to special-case sync/async | 673 // FIXME: Get to the point where we don't need to special-case sync/async |
| 674 // behavior for different resource types. | 674 // behavior for different resource types. |
| 675 if (type == Resource::Image) | 675 if (type == Resource::Image) |
| 676 return true; | 676 return true; |
| 677 if (type == Resource::CSSStyleSheet) | 677 if (type == Resource::CSSStyleSheet) |
| 678 return true; | 678 return true; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 PreloadReferencePolicy policy) { | 710 PreloadReferencePolicy policy) { |
| 711 CHECK(!m_isAddRemoveClientProhibited); | 711 CHECK(!m_isAddRemoveClientProhibited); |
| 712 | 712 |
| 713 willAddClientOrObserver(policy); | 713 willAddClientOrObserver(policy); |
| 714 | 714 |
| 715 if (m_isRevalidating) { | 715 if (m_isRevalidating) { |
| 716 m_clients.add(client); | 716 m_clients.add(client); |
| 717 return; | 717 return; |
| 718 } | 718 } |
| 719 | 719 |
| 720 // If we have existing data to send to the new client and the resource type | 720 // If an error has occurred or we have existing data to send to the new client |
| 721 // supprts it, send it asynchronously. | 721 // and the resource type supprts it, send it asynchronously. |
| 722 if (!m_response.isNull() && | 722 if ((errorOccurred() || !m_response.isNull()) && |
| 723 !shouldSendCachedDataSynchronouslyForType(getType()) && | 723 !typeNeedsSynchronousCacheHit(getType()) && !m_needsSynchronousCacheHit) { |
| 724 !m_needsSynchronousCacheHit) { | |
| 725 m_clientsAwaitingCallback.add(client); | 724 m_clientsAwaitingCallback.add(client); |
| 726 ResourceCallback::callbackHandler().schedule(this); | 725 ResourceCallback::callbackHandler().schedule(this); |
| 727 return; | 726 return; |
| 728 } | 727 } |
| 729 | 728 |
| 730 m_clients.add(client); | 729 m_clients.add(client); |
| 731 didAddClient(client); | 730 didAddClient(client); |
| 732 return; | 731 return; |
| 733 } | 732 } |
| 734 | 733 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 case Resource::TextTrack: | 1096 case Resource::TextTrack: |
| 1098 case Resource::Media: | 1097 case Resource::Media: |
| 1099 case Resource::Manifest: | 1098 case Resource::Manifest: |
| 1100 return false; | 1099 return false; |
| 1101 } | 1100 } |
| 1102 NOTREACHED(); | 1101 NOTREACHED(); |
| 1103 return false; | 1102 return false; |
| 1104 } | 1103 } |
| 1105 | 1104 |
| 1106 } // namespace blink | 1105 } // namespace blink |
| OLD | NEW |