| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 return true; | 587 return true; |
| 588 if (type == Resource::CSSStyleSheet) | 588 if (type == Resource::CSSStyleSheet) |
| 589 return true; | 589 return true; |
| 590 if (type == Resource::Script) | 590 if (type == Resource::Script) |
| 591 return true; | 591 return true; |
| 592 if (type == Resource::Font) | 592 if (type == Resource::Font) |
| 593 return true; | 593 return true; |
| 594 return false; | 594 return false; |
| 595 } | 595 } |
| 596 | 596 |
| 597 void Resource::addClient(ResourceClient* client) | 597 void Resource::willAddClient() |
| 598 { | 598 { |
| 599 ASSERT(!isPurgeable()); | 599 ASSERT(!isPurgeable()); |
| 600 | |
| 601 if (m_preloadResult == PreloadNotReferenced) { | 600 if (m_preloadResult == PreloadNotReferenced) { |
| 602 if (isLoaded()) | 601 if (isLoaded()) |
| 603 m_preloadResult = PreloadReferencedWhileComplete; | 602 m_preloadResult = PreloadReferencedWhileComplete; |
| 604 else if (m_requestedFromNetworkingLayer) | 603 else if (m_requestedFromNetworkingLayer) |
| 605 m_preloadResult = PreloadReferencedWhileLoading; | 604 m_preloadResult = PreloadReferencedWhileLoading; |
| 606 else | 605 else |
| 607 m_preloadResult = PreloadReferenced; | 606 m_preloadResult = PreloadReferenced; |
| 608 } | 607 } |
| 609 if (!hasClients()) | 608 if (!hasClients()) |
| 610 memoryCache()->makeLive(this); | 609 memoryCache()->makeLive(this); |
| 610 } |
| 611 |
| 612 void Resource::addClient(ResourceClient* client) |
| 613 { |
| 614 willAddClient(); |
| 611 | 615 |
| 612 if (!m_revalidatingRequest.isNull()) { | 616 if (!m_revalidatingRequest.isNull()) { |
| 613 m_clients.add(client); | 617 m_clients.add(client); |
| 614 return; | 618 return; |
| 615 } | 619 } |
| 616 | 620 |
| 617 // If we have existing data to send to the new client and the resource type
supprts it, send it asynchronously. | 621 // If we have existing data to send to the new client and the resource type
supprts it, send it asynchronously. |
| 618 if (!m_response.isNull() && !shouldSendCachedDataSynchronouslyForType(type()
) && !m_needsSynchronousCacheHit) { | 622 if (!m_response.isNull() && !shouldSendCachedDataSynchronouslyForType(type()
) && !m_needsSynchronousCacheHit) { |
| 619 m_clientsAwaitingCallback.add(client); | 623 m_clientsAwaitingCallback.add(client); |
| 620 ResourceCallback::callbackHandler()->schedule(this); | 624 ResourceCallback::callbackHandler()->schedule(this); |
| 621 return; | 625 return; |
| 622 } | 626 } |
| 623 | 627 |
| 624 m_clients.add(client); | 628 m_clients.add(client); |
| 625 didAddClient(client); | 629 didAddClient(client); |
| 626 return; | 630 return; |
| 627 } | 631 } |
| 628 | 632 |
| 629 void Resource::removeClient(ResourceClient* client) | 633 void Resource::removeClient(ResourceClient* client) |
| 630 { | 634 { |
| 631 ASSERT(hasClient(client)); | 635 ASSERT(hasClient(client)); |
| 632 if (m_finishedClients.contains(client)) | 636 if (m_finishedClients.contains(client)) |
| 633 m_finishedClients.remove(client); | 637 m_finishedClients.remove(client); |
| 634 else if (m_clientsAwaitingCallback.contains(client)) | 638 else if (m_clientsAwaitingCallback.contains(client)) |
| 635 m_clientsAwaitingCallback.remove(client); | 639 m_clientsAwaitingCallback.remove(client); |
| 636 else | 640 else |
| 637 m_clients.remove(client); | 641 m_clients.remove(client); |
| 638 | 642 |
| 639 didRemoveClient(client); | |
| 640 | |
| 641 if (m_clientsAwaitingCallback.isEmpty()) | 643 if (m_clientsAwaitingCallback.isEmpty()) |
| 642 ResourceCallback::callbackHandler()->cancel(this); | 644 ResourceCallback::callbackHandler()->cancel(this); |
| 643 | 645 |
| 646 didRemoveClient(); |
| 647 // This object may be dead here. |
| 648 } |
| 649 |
| 650 void Resource::didRemoveClient() |
| 651 { |
| 644 if (!hasClients()) { | 652 if (!hasClients()) { |
| 645 RefPtrWillBeRawPtr<Resource> protect(this); | 653 RefPtrWillBeRawPtr<Resource> protect(this); |
| 646 memoryCache()->makeDead(this); | 654 memoryCache()->makeDead(this); |
| 647 allClientsRemoved(); | 655 allClientsRemoved(); |
| 648 | 656 |
| 649 // RFC2616 14.9.2: | 657 // RFC2616 14.9.2: |
| 650 // "no-store: ... MUST make a best-effort attempt to remove the informat
ion from volatile storage as promptly as possible" | 658 // "no-store: ... MUST make a best-effort attempt to remove the informat
ion from volatile storage as promptly as possible" |
| 651 // "... History buffers MAY store such responses as part of their normal
operation." | 659 // "... History buffers MAY store such responses as part of their normal
operation." |
| 652 // We allow non-secure content to be reused in history, but we do not al
low secure content to be reused. | 660 // We allow non-secure content to be reused in history, but we do not al
low secure content to be reused. |
| 653 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { | 661 if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 return sizeof(Resource) + m_response.memoryUsage() + kAverageClientsHashMapS
ize + m_resourceRequest.url().string().length() * 2; | 915 return sizeof(Resource) + m_response.memoryUsage() + kAverageClientsHashMapS
ize + m_resourceRequest.url().string().length() * 2; |
| 908 } | 916 } |
| 909 | 917 |
| 910 void Resource::didChangePriority(ResourceLoadPriority loadPriority, int intraPri
orityValue) | 918 void Resource::didChangePriority(ResourceLoadPriority loadPriority, int intraPri
orityValue) |
| 911 { | 919 { |
| 912 m_resourceRequest.setPriority(loadPriority, intraPriorityValue); | 920 m_resourceRequest.setPriority(loadPriority, intraPriorityValue); |
| 913 if (m_loader) | 921 if (m_loader) |
| 914 m_loader->didChangePriority(loadPriority, intraPriorityValue); | 922 m_loader->didChangePriority(loadPriority, intraPriorityValue); |
| 915 } | 923 } |
| 916 | 924 |
| 917 ResourcePriority Resource::priorityFromClients() | |
| 918 { | |
| 919 ResourcePriority priority; | |
| 920 ResourceClientWalker<ResourceClient> walker(m_clients); | |
| 921 while (ResourceClient* c = walker.next()) { | |
| 922 ResourcePriority nextPriority = c->computeResourcePriority(); | |
| 923 if (nextPriority.visibility == ResourcePriority::NotVisible) | |
| 924 continue; | |
| 925 priority.visibility = ResourcePriority::Visible; | |
| 926 priority.intraPriorityValue += nextPriority.intraPriorityValue; | |
| 927 } | |
| 928 return priority; | |
| 929 } | |
| 930 | |
| 931 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() | 925 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() |
| 932 { | 926 { |
| 933 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource | 927 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource |
| 934 // and ResourcePtr finalizers, it cannot be released upon shutdown in | 928 // and ResourcePtr finalizers, it cannot be released upon shutdown in |
| 935 // preparation for leak detection. | 929 // preparation for leak detection. |
| 936 // | 930 // |
| 937 // Keep it out of LSan's reach instead. | 931 // Keep it out of LSan's reach instead. |
| 938 LEAK_SANITIZER_DISABLED_SCOPE; | 932 LEAK_SANITIZER_DISABLED_SCOPE; |
| 939 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ResourceCallback>, callbackHandle
r, (adoptPtrWillBeNoop(new ResourceCallback))); | 933 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ResourceCallback>, callbackHandle
r, (adoptPtrWillBeNoop(new ResourceCallback))); |
| 940 return callbackHandler.get(); | 934 return callbackHandler.get(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 case Resource::Media: | 1105 case Resource::Media: |
| 1112 return "Media"; | 1106 return "Media"; |
| 1113 case Resource::Manifest: | 1107 case Resource::Manifest: |
| 1114 return "Manifest"; | 1108 return "Manifest"; |
| 1115 } | 1109 } |
| 1116 ASSERT_NOT_REACHED(); | 1110 ASSERT_NOT_REACHED(); |
| 1117 return "Unknown"; | 1111 return "Unknown"; |
| 1118 } | 1112 } |
| 1119 | 1113 |
| 1120 } // namespace blink | 1114 } // namespace blink |
| OLD | NEW |