This source file includes following definitions.
- addAllResources
- addResource
- archiveResourceForURL
- popSubframeArchive
#include "config.h"
#include "platform/mhtml/ArchiveResourceCollection.h"
#include "platform/weborigin/KURL.h"
namespace WebCore {
ArchiveResourceCollection::ArchiveResourceCollection()
{
}
void ArchiveResourceCollection::addAllResources(MHTMLArchive* archive)
{
ASSERT(archive);
if (!archive)
return;
const Vector<RefPtr<ArchiveResource> >& subresources = archive->subresources();
for (Vector<RefPtr<ArchiveResource> >::const_iterator iterator = subresources.begin(); iterator != subresources.end(); ++iterator)
m_subresources.set((*iterator)->url(), iterator->get());
const Vector<RefPtr<MHTMLArchive> >& subframes = archive->subframeArchives();
for (Vector<RefPtr<MHTMLArchive> >::const_iterator iterator = subframes.begin(); iterator != subframes.end(); ++iterator) {
RefPtr<MHTMLArchive> archive = *iterator;
ASSERT(archive->mainResource());
const String& frameName = archive->mainResource()->frameName();
if (!frameName.isNull()) {
m_subframes.set(frameName, archive.get());
} else {
m_subframes.set(archive->mainResource()->url().string(), archive.get());
}
}
}
void ArchiveResourceCollection::addResource(PassRefPtr<ArchiveResource> resource)
{
ASSERT(resource);
if (!resource)
return;
const KURL& url = resource->url();
m_subresources.set(url, resource);
}
ArchiveResource* ArchiveResourceCollection::archiveResourceForURL(const KURL& url)
{
ArchiveResource* resource = m_subresources.get(url);
if (!resource)
return 0;
return resource;
}
PassRefPtr<MHTMLArchive> ArchiveResourceCollection::popSubframeArchive(const String& frameName, const KURL& url)
{
RefPtr<MHTMLArchive> archive = m_subframes.take(frameName);
if (archive)
return archive.release();
return m_subframes.take(url.string());
}
}