本文整理汇总了C++中ResourceResponse函数的典型用法代码示例。如果您正苦于以下问题:C++ ResourceResponse函数的具体用法?C++ ResourceResponse怎么用?C++ ResourceResponse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ResourceResponse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: USE
bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder* decoder, ResourceResponse& resourceResponse)
{
#if USE(CFNETWORK)
bool responseIsPresent;
if (!decoder->decode(responseIsPresent))
return false;
if (!responseIsPresent) {
resourceResponse = ResourceResponse();
return true;
}
RetainPtr<CFDictionaryRef> dictionary;
if (!CoreIPC::decode(decoder, dictionary))
return false;
RetainPtr<CFURLResponseRef> cfURLResponse(AdoptCF, wkCFURLResponseCreateFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef()));
if (!cfURLResponse)
return false;
resourceResponse = ResourceResponse(cfURLResponse.get());
return true;
#else
return false;
#endif
}
示例2: TEST
TEST(ImageResourceTest, DecodedDataRemainsWhileHasClients)
{
ResourcePtr<ImageResource> cachedImage = new ImageResource(ResourceRequest(), nullptr);
cachedImage->setLoading(true);
MockImageResourceClient client(cachedImage);
// Send the image response.
cachedImage->responseReceived(ResourceResponse(KURL(), "multipart/x-mixed-replace", 0, nullAtom, String()), nullptr);
Vector<unsigned char> jpeg = jpegImage();
cachedImage->responseReceived(ResourceResponse(KURL(), "image/jpeg", jpeg.size(), nullAtom, String()), nullptr);
cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.size());
cachedImage->finish();
ASSERT_FALSE(cachedImage->errorOccurred());
ASSERT_TRUE(cachedImage->hasImage());
ASSERT_FALSE(cachedImage->image()->isNull());
ASSERT_TRUE(client.notifyFinishedCalled());
// The prune comes when the ImageResource still has clients. The image should not be deleted.
cachedImage->prune();
ASSERT_TRUE(cachedImage->hasClients());
ASSERT_TRUE(cachedImage->hasImage());
ASSERT_FALSE(cachedImage->image()->isNull());
// The ImageResource no longer has clients. The image should be deleted by prune.
client.removeAsClient();
cachedImage->prune();
ASSERT_FALSE(cachedImage->hasClients());
ASSERT_FALSE(cachedImage->hasImage());
ASSERT_TRUE(cachedImage->image()->isNull());
}
示例3: core
WebCore::ResourceResponse core(WebKitNetworkResponse* response)
{
SoupMessage* soupMessage = webkit_network_response_get_message(response);
if (soupMessage)
return ResourceResponse(soupMessage);
return ResourceResponse();
}
示例4: AtomicString
PassOwnPtr<ResourceTimingInfo> ResourceTimingInfo::adopt(PassOwnPtr<CrossThreadResourceTimingInfoData> data)
{
OwnPtr<ResourceTimingInfo> info = ResourceTimingInfo::create(AtomicString(data->m_type), data->m_initialTime, data->m_isMainResource);
info->m_originalTimingAllowOrigin = AtomicString(data->m_originalTimingAllowOrigin);
info->m_loadFinishTime = data->m_loadFinishTime;
info->m_initialRequest = ResourceRequest(data->m_initialRequest.get());
info->m_finalResponse = ResourceResponse(data->m_finalResponse.get());
for (auto& responseData : data->m_redirectChain)
info->m_redirectChain.append(ResourceResponse(responseData.get()));
return info.release();
}
示例5: createResourceResponseFromPropertyListData
static ResourceResponse createResourceResponseFromPropertyListData(CFDataRef data, CFStringRef responseDataType)
{
ASSERT(data);
if (!data)
return ResourceResponse();
// If the ResourceResponseVersion (passed in as responseDataType) exists at all, this is a "new" webarchive that we can parse well in a cross platform manner
// If it doesn't exist, we will assume this is an "old" Cocoa-based WebArchive, and parse the ResourceResponse as such
if (!responseDataType)
return createResourceResponseFromMacArchivedData(data);
// FIXME: Parse the "new" format that the above comment references here
return ResourceResponse();
}
示例6: ASSERT
ResourceResponse LegacyWebArchive::createResourceResponseFromPropertyListData(CFDataRef data, CFStringRef responseDataType)
{
ASSERT(data);
if (!data)
return ResourceResponse();
// If the ResourceResponseVersion (passed in as responseDataType) exists at all, this is a "new" web archive that we
// can parse well in a cross platform manner If it doesn't exist, we will assume this is an "old" web archive with,
// NSURLResponse objects in it and parse the ResourceResponse as such.
if (!responseDataType)
return createResourceResponseFromMacArchivedData(data);
// FIXME: Parse the "new" format that the above comment references here. This format doesn't exist yet.
return ResourceResponse();
}
示例7: ResourceResponse
void WebLoaderStrategy::loadResourceSynchronously(NetworkingContext* context, unsigned long resourceLoadIdentifier, const ResourceRequest& request, StoredCredentials storedCredentials, ClientCredentialPolicy clientCredentialPolicy, ResourceError& error, ResourceResponse& response, Vector<char>& data)
{
WebFrameNetworkingContext* webContext = static_cast<WebFrameNetworkingContext*>(context);
// FIXME: Some entities in WebCore use WebCore's "EmptyFrameLoaderClient" instead of having a proper WebFrameLoaderClient.
// EmptyFrameLoaderClient shouldn't exist and everything should be using a WebFrameLoaderClient,
// but in the meantime we have to make sure not to mis-cast.
WebFrameLoaderClient* webFrameLoaderClient = webContext->webFrameLoaderClient();
WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
WebPage* webPage = webFrame ? webFrame->page() : 0;
NetworkResourceLoadParameters loadParameters;
loadParameters.identifier = resourceLoadIdentifier;
loadParameters.webPageID = webPage ? webPage->pageID() : 0;
loadParameters.webFrameID = webFrame ? webFrame->frameID() : 0;
loadParameters.sessionID = webPage ? webPage->sessionID() : SessionID::defaultSessionID();
loadParameters.request = request;
loadParameters.contentSniffingPolicy = SniffContent;
loadParameters.allowStoredCredentials = storedCredentials;
loadParameters.clientCredentialPolicy = clientCredentialPolicy;
loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = context->shouldClearReferrerOnHTTPSToHTTPRedirect();
data.resize(0);
HangDetectionDisabler hangDetectionDisabler;
if (!WebProcess::singleton().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad(loadParameters), Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::Reply(error, response, data), 0)) {
response = ResourceResponse();
error = internalError(request.url());
}
}
示例8: ASSERT
bool ResourceLoader::load(const ResourceRequest& r)
{
ASSERT(!m_handle);
ASSERT(m_deferredRequest.isNull());
ASSERT(!m_documentLoader->isSubstituteLoadPending(this));
ResourceRequest clientRequest(r);
willSendRequest(clientRequest, ResourceResponse());
if (clientRequest.isNull()) {
didFail(frameLoader()->cancelledError(r));
return false;
}
if (m_documentLoader->scheduleArchiveLoad(this, clientRequest, r.url()))
return true;
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
if (m_documentLoader->applicationCacheHost()->maybeLoadResource(this, clientRequest, r.url()))
return true;
#endif
if (m_defersLoading) {
m_deferredRequest = clientRequest;
return true;
}
m_handle = ResourceHandle::create(clientRequest, this, m_frame.get(), m_defersLoading, m_shouldContentSniff, true);
return true;
}
示例9: ASSERT
void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& vector, Frame*)
{
ASSERT(!request.isEmpty());
CFURLResponseRef cfResponse = 0;
CFErrorRef cfError = 0;
RetainPtr<CFURLRequestRef> cfRequest(AdoptCF, makeFinalRequest(request, true));
CFDataRef data = CFURLConnectionSendSynchronousRequest(cfRequest.get(), &cfResponse, &cfError, request.timeoutInterval());
if (cfError) {
error = cfError;
CFRelease(cfError);
response = ResourceResponse(request.url(), String(), 0, String(), String());
response.setHTTPStatusCode(404);
} else {
response = cfResponse;
if (cfResponse)
CFRelease(cfResponse);
}
if (data) {
ASSERT(vector.isEmpty());
vector.append(CFDataGetBytePtr(data), CFDataGetLength(data));
CFRelease(data);
}
}
示例10: ASSERT
bool ResourceLoader::load(const ResourceRequest& r)
{
ASSERT(!m_handle);
ASSERT(m_deferredRequest.isNull());
ASSERT(!frameLoader()->isArchiveLoadPending(this));
m_originalURL = r.url();
ResourceRequest clientRequest(r);
willSendRequest(clientRequest, ResourceResponse());
if (clientRequest.isNull()) {
didFail(frameLoader()->cancelledError(r));
return false;
}
if (frameLoader()->willUseArchive(this, clientRequest, m_originalURL))
return true;
if (m_defersLoading) {
m_deferredRequest = clientRequest;
return true;
}
m_handle = ResourceHandle::create(clientRequest, this, m_frame.get(), m_defersLoading, m_shouldContentSniff, true);
return true;
}
示例11: clientRequest
bool ResourceLoader::init(const ResourceRequest& r) {
ResourceRequest clientRequest(r);
willSendRequest(clientRequest, ResourceResponse());
m_request = clientRequest;
return true;
}
示例12: ResourceResponse
ResourceResponse LegacyWebArchive::createResourceResponseFromMacArchivedData(CFDataRef responseData)
{
// FIXME: If is is possible to parse in a serialized NSURLResponse manually, without using
// NSKeyedUnarchiver, manipulating plists directly, then we want to do that here.
// Until then, this can be done on Mac only.
return ResourceResponse();
}
示例13: ASSERT
void MainResourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
{
ASSERT(data);
ASSERT(length != 0);
ASSERT(!m_response.isNull());
#if USE(CFNETWORK) || PLATFORM(MAC)
// Workaround for <rdar://problem/6060782>
if (m_response.isNull()) {
m_response = ResourceResponse(KURL(), "text/html", 0, String(), String());
if (DocumentLoader* documentLoader = frameLoader()->activeDocumentLoader())
documentLoader->setResponse(m_response);
}
#endif
// There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
// See <rdar://problem/6304600> for more details.
#if !USE(CF)
ASSERT(!defersLoading());
#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
documentLoader()->applicationCacheHost()->mainResourceDataReceived(data, length, encodedDataLength, allAtOnce);
#endif
// The additional processing can do anything including possibly removing the last
// reference to this object; one example of this is 3266216.
RefPtr<MainResourceLoader> protect(this);
m_timeOfLastDataReceived = currentTime();
ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
}
示例14: request
PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const KURL& url, ApplicationCacheResource* newestCachedResource)
{
ResourceRequest request(url);
m_frame->loader()->applyUserAgent(request);
request.setHTTPHeaderField("Cache-Control", "max-age=0");
if (newestCachedResource) {
const String& lastModified = newestCachedResource->response().httpHeaderField("Last-Modified");
const String& eTag = newestCachedResource->response().httpHeaderField("ETag");
if (!lastModified.isEmpty() || !eTag.isEmpty()) {
if (!lastModified.isEmpty())
request.setHTTPHeaderField("If-Modified-Since", lastModified);
if (!eTag.isEmpty())
request.setHTTPHeaderField("If-None-Match", eTag);
}
}
RefPtr<ResourceHandle> handle = ResourceHandle::create(m_frame->loader()->networkingContext(), request, this, false, true);
#if ENABLE(INSPECTOR)
// Because willSendRequest only gets called during redirects, we initialize
// the identifier and the first willSendRequest here.
m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdentifier();
if (Page* page = m_frame->page()) {
InspectorController* inspectorController = page->inspectorController();
inspectorController->identifierForInitialRequest(m_currentResourceIdentifier, m_frame->loader()->documentLoader(), handle->firstRequest());
ResourceResponse redirectResponse = ResourceResponse();
inspectorController->willSendRequest(m_currentResourceIdentifier, request, redirectResponse);
}
#endif
return handle;
}
示例15: ResourceResponse
void XMLHttpRequest::clearResponse()
{
m_response = ResourceResponse();
{
JSC::JSLock lock(false);
m_responseText = "";
}
m_createdDocument = false;
m_responseXML = 0;
}