| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "platform/mhtml/ArchiveResourceCollection.h" | 30 #include "platform/mhtml/ArchiveResourceCollection.h" |
| 31 | 31 |
| 32 #include "platform/mhtml/ArchiveResource.h" |
| 33 #include "platform/mhtml/MHTMLArchive.h" |
| 32 #include "platform/weborigin/KURL.h" | 34 #include "platform/weborigin/KURL.h" |
| 33 | 35 |
| 34 namespace WebCore { | 36 namespace WebCore { |
| 35 | 37 |
| 36 ArchiveResourceCollection::ArchiveResourceCollection() | 38 ArchiveResourceCollection::ArchiveResourceCollection() |
| 37 { | 39 { |
| 38 } | 40 } |
| 39 | 41 |
| 42 ArchiveResourceCollection::~ArchiveResourceCollection() |
| 43 { |
| 44 } |
| 45 |
| 40 void ArchiveResourceCollection::addAllResources(MHTMLArchive* archive) | 46 void ArchiveResourceCollection::addAllResources(MHTMLArchive* archive) |
| 41 { | 47 { |
| 42 ASSERT(archive); | 48 ASSERT(archive); |
| 43 if (!archive) | 49 if (!archive) |
| 44 return; | 50 return; |
| 45 | 51 |
| 46 const Vector<RefPtr<ArchiveResource> >& subresources = archive->subresources
(); | 52 const MHTMLArchive::SubArchiveResources& subresources = archive->subresource
s(); |
| 47 for (Vector<RefPtr<ArchiveResource> >::const_iterator iterator = subresource
s.begin(); iterator != subresources.end(); ++iterator) | 53 for (MHTMLArchive::SubArchiveResources::const_iterator iterator = subresourc
es.begin(); iterator != subresources.end(); ++iterator) |
| 48 m_subresources.set((*iterator)->url(), iterator->get()); | 54 m_subresources.set((*iterator)->url(), iterator->get()); |
| 49 | 55 |
| 50 const Vector<RefPtr<MHTMLArchive> >& subframes = archive->subframeArchives()
; | 56 const MHTMLArchive::SubFrameArchives& subframes = archive->subframeArchives(
); |
| 51 for (Vector<RefPtr<MHTMLArchive> >::const_iterator iterator = subframes.begi
n(); iterator != subframes.end(); ++iterator) { | 57 for (MHTMLArchive::SubFrameArchives::const_iterator iterator = subframes.beg
in(); iterator != subframes.end(); ++iterator) { |
| 52 RefPtr<MHTMLArchive> archive = *iterator; | 58 RefPtrWillBeRawPtr<MHTMLArchive> archive = *iterator; |
| 53 ASSERT(archive->mainResource()); | 59 ASSERT(archive->mainResource()); |
| 54 | 60 |
| 55 const String& frameName = archive->mainResource()->frameName(); | 61 const String& frameName = archive->mainResource()->frameName(); |
| 56 if (!frameName.isNull()) { | 62 if (!frameName.isNull()) { |
| 57 m_subframes.set(frameName, archive.get()); | 63 m_subframes.set(frameName, archive.get()); |
| 58 } else { | 64 } else { |
| 59 // In the MHTML case, frames don't have a name so we use the URL ins
tead. | 65 // In the MHTML case, frames don't have a name so we use the URL ins
tead. |
| 60 m_subframes.set(archive->mainResource()->url().string(), archive.get
()); | 66 m_subframes.set(archive->mainResource()->url().string(), archive.get
()); |
| 61 } | 67 } |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 | 70 |
| 65 // FIXME: Adding a resource directly to a DocumentLoader/ArchiveResourceCollecti
on seems like bad design, but is API some apps rely on. | 71 // FIXME: Adding a resource directly to a DocumentLoader/ArchiveResourceCollecti
on seems like bad design, but is API some apps rely on. |
| 66 // Can we change the design in a manner that will let us deprecate that API with
out reducing functionality of those apps? | 72 // Can we change the design in a manner that will let us deprecate that API with
out reducing functionality of those apps? |
| 67 void ArchiveResourceCollection::addResource(PassRefPtr<ArchiveResource> resource
) | 73 void ArchiveResourceCollection::addResource(PassRefPtrWillBeRawPtr<ArchiveResour
ce> resource) |
| 68 { | 74 { |
| 69 ASSERT(resource); | 75 ASSERT(resource); |
| 70 if (!resource) | 76 if (!resource) |
| 71 return; | 77 return; |
| 72 | 78 |
| 73 const KURL& url = resource->url(); // get before passing PassRefPtr (which s
ets it to 0) | 79 const KURL& url = resource->url(); // get before passing PassRefPtr (which s
ets it to 0) |
| 74 m_subresources.set(url, resource); | 80 m_subresources.set(url, resource); |
| 75 } | 81 } |
| 76 | 82 |
| 77 ArchiveResource* ArchiveResourceCollection::archiveResourceForURL(const KURL& ur
l) | 83 ArchiveResource* ArchiveResourceCollection::archiveResourceForURL(const KURL& ur
l) |
| 78 { | 84 { |
| 79 ArchiveResource* resource = m_subresources.get(url); | 85 ArchiveResource* resource = m_subresources.get(url); |
| 80 if (!resource) | 86 if (!resource) |
| 81 return 0; | 87 return 0; |
| 82 | 88 |
| 83 return resource; | 89 return resource; |
| 84 } | 90 } |
| 85 | 91 |
| 86 PassRefPtr<MHTMLArchive> ArchiveResourceCollection::popSubframeArchive(const Str
ing& frameName, const KURL& url) | 92 PassRefPtrWillBeRawPtr<MHTMLArchive> ArchiveResourceCollection::popSubframeArchi
ve(const String& frameName, const KURL& url) |
| 87 { | 93 { |
| 88 RefPtr<MHTMLArchive> archive = m_subframes.take(frameName); | 94 RefPtrWillBeRawPtr<MHTMLArchive> archive = m_subframes.take(frameName); |
| 89 if (archive) | 95 if (archive) |
| 90 return archive.release(); | 96 return archive.release(); |
| 91 | 97 |
| 92 return m_subframes.take(url.string()); | 98 return m_subframes.take(url.string()); |
| 93 } | 99 } |
| 94 | 100 |
| 101 void ArchiveResourceCollection::trace(Visitor* visitor) |
| 102 { |
| 103 visitor->trace(m_subresources); |
| 104 visitor->trace(m_subframes); |
| 95 } | 105 } |
| 106 |
| 107 } |
| OLD | NEW |