| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 m_preloadCount(0), | 306 m_preloadCount(0), |
| 307 m_preloadDiscoveryTime(0.0), | 307 m_preloadDiscoveryTime(0.0), |
| 308 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), | 308 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), |
| 309 m_preloadResult(PreloadNotReferenced), | 309 m_preloadResult(PreloadNotReferenced), |
| 310 m_type(type), | 310 m_type(type), |
| 311 m_status(NotStarted), | 311 m_status(NotStarted), |
| 312 m_needsSynchronousCacheHit(false), | 312 m_needsSynchronousCacheHit(false), |
| 313 m_linkPreload(false), | 313 m_linkPreload(false), |
| 314 m_isRevalidating(false), | 314 m_isRevalidating(false), |
| 315 m_isAlive(false), | 315 m_isAlive(false), |
| 316 m_isAddRemoveClientProhibited(false), |
| 316 m_options(options), | 317 m_options(options), |
| 317 m_responseTimestamp(currentTime()), | 318 m_responseTimestamp(currentTime()), |
| 318 m_cancelTimer(this, &Resource::cancelTimerFired), | 319 m_cancelTimer(this, &Resource::cancelTimerFired), |
| 319 m_resourceRequest(request) { | 320 m_resourceRequest(request) { |
| 320 // m_type is a bitfield, so this tests careless updates of the enum. | 321 // m_type is a bitfield, so this tests careless updates of the enum. |
| 321 DCHECK_EQ(m_type, unsigned(type)); | 322 DCHECK_EQ(m_type, unsigned(type)); |
| 322 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); | 323 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); |
| 323 | 324 |
| 324 // Currently we support the metadata caching only for HTTP family. | 325 // Currently we support the metadata caching only for HTTP family. |
| 325 if (m_resourceRequest.url().protocolIsInHTTPFamily()) | 326 if (m_resourceRequest.url().protocolIsInHTTPFamily()) |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } | 681 } |
| 681 } | 682 } |
| 682 if (!hasClientsOrObservers()) { | 683 if (!hasClientsOrObservers()) { |
| 683 m_isAlive = true; | 684 m_isAlive = true; |
| 684 memoryCache()->makeLive(this); | 685 memoryCache()->makeLive(this); |
| 685 } | 686 } |
| 686 } | 687 } |
| 687 | 688 |
| 688 void Resource::addClient(ResourceClient* client, | 689 void Resource::addClient(ResourceClient* client, |
| 689 PreloadReferencePolicy policy) { | 690 PreloadReferencePolicy policy) { |
| 691 CHECK(!m_isAddRemoveClientProhibited); |
| 692 |
| 690 willAddClientOrObserver(policy); | 693 willAddClientOrObserver(policy); |
| 691 | 694 |
| 692 if (m_isRevalidating) { | 695 if (m_isRevalidating) { |
| 693 m_clients.add(client); | 696 m_clients.add(client); |
| 694 return; | 697 return; |
| 695 } | 698 } |
| 696 | 699 |
| 697 // If we have existing data to send to the new client and the resource type | 700 // If we have existing data to send to the new client and the resource type |
| 698 // supprts it, send it asynchronously. | 701 // supprts it, send it asynchronously. |
| 699 if (!m_response.isNull() && | 702 if (!m_response.isNull() && |
| 700 !shouldSendCachedDataSynchronouslyForType(getType()) && | 703 !shouldSendCachedDataSynchronouslyForType(getType()) && |
| 701 !m_needsSynchronousCacheHit) { | 704 !m_needsSynchronousCacheHit) { |
| 702 m_clientsAwaitingCallback.add(client); | 705 m_clientsAwaitingCallback.add(client); |
| 703 ResourceCallback::callbackHandler().schedule(this); | 706 ResourceCallback::callbackHandler().schedule(this); |
| 704 return; | 707 return; |
| 705 } | 708 } |
| 706 | 709 |
| 707 m_clients.add(client); | 710 m_clients.add(client); |
| 708 didAddClient(client); | 711 didAddClient(client); |
| 709 return; | 712 return; |
| 710 } | 713 } |
| 711 | 714 |
| 712 void Resource::removeClient(ResourceClient* client) { | 715 void Resource::removeClient(ResourceClient* client) { |
| 716 CHECK(!m_isAddRemoveClientProhibited); |
| 717 |
| 713 // This code may be called in a pre-finalizer, where weak members in the | 718 // This code may be called in a pre-finalizer, where weak members in the |
| 714 // HashCountedSet are already swept out. | 719 // HashCountedSet are already swept out. |
| 715 | 720 |
| 716 if (m_finishedClients.contains(client)) | 721 if (m_finishedClients.contains(client)) |
| 717 m_finishedClients.remove(client); | 722 m_finishedClients.remove(client); |
| 718 else if (m_clientsAwaitingCallback.contains(client)) | 723 else if (m_clientsAwaitingCallback.contains(client)) |
| 719 m_clientsAwaitingCallback.remove(client); | 724 m_clientsAwaitingCallback.remove(client); |
| 720 else | 725 else |
| 721 m_clients.remove(client); | 726 m_clients.remove(client); |
| 722 | 727 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 case Resource::TextTrack: | 1079 case Resource::TextTrack: |
| 1075 case Resource::Media: | 1080 case Resource::Media: |
| 1076 case Resource::Manifest: | 1081 case Resource::Manifest: |
| 1077 return false; | 1082 return false; |
| 1078 } | 1083 } |
| 1079 NOTREACHED(); | 1084 NOTREACHED(); |
| 1080 return false; | 1085 return false; |
| 1081 } | 1086 } |
| 1082 | 1087 |
| 1083 } // namespace blink | 1088 } // namespace blink |
| OLD | NEW |