This source file includes following definitions.
- isSafeToSendToAnotherThread
- completeURL
- resourceRequest
- takeAndPreload
- preload
#include "config.h"
#include "core/html/parser/HTMLResourcePreloader.h"
#include "core/dom/Document.h"
#include "core/fetch/FetchInitiatorInfo.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/html/imports/HTMLImport.h"
#include "core/rendering/RenderObject.h"
#include "public/platform/Platform.h"
namespace WebCore {
bool PreloadRequest::isSafeToSendToAnotherThread() const
{
return m_initiatorName.isSafeToSendToAnotherThread()
&& m_charset.isSafeToSendToAnotherThread()
&& m_resourceURL.isSafeToSendToAnotherThread()
&& m_baseURL.isSafeToSendToAnotherThread();
}
KURL PreloadRequest::completeURL(Document* document)
{
return document->completeURLWithOverride(m_resourceURL, m_baseURL.isEmpty() ? document->url() : m_baseURL);
}
FetchRequest PreloadRequest::resourceRequest(Document* document)
{
ASSERT(isMainThread());
FetchInitiatorInfo initiatorInfo;
initiatorInfo.name = AtomicString(m_initiatorName);
initiatorInfo.position = m_initiatorPosition;
FetchRequest request(ResourceRequest(completeURL(document)), initiatorInfo);
if (m_isCORSEnabled)
request.setCrossOriginAccessControl(document->securityOrigin(), m_allowCredentials);
return request;
}
void HTMLResourcePreloader::takeAndPreload(PreloadRequestStream& r)
{
PreloadRequestStream requests;
requests.swap(r);
for (PreloadRequestStream::iterator it = requests.begin(); it != requests.end(); ++it)
preload(it->release());
}
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload)
{
FetchRequest request = preload->resourceRequest(m_document);
blink::Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20);
m_document->fetcher()->preload(preload->resourceType(), request, preload->charset());
}
}