本文整理汇总了C++中WebURLResponse::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ WebURLResponse::initialize方法的具体用法?C++ WebURLResponse::initialize怎么用?C++ WebURLResponse::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebURLResponse
的用法示例。
在下文中一共展示了WebURLResponse::initialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: workerReadyForInspection
TEST_F(WebEmbeddedWorkerImplTest, ScriptNotFound)
{
WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw-404.js");
WebURLResponse response;
response.initialize();
response.setMIMEType("text/javascript");
response.setHTTPStatusCode(404);
WebURLError error;
error.reason = 1010;
error.domain = "WebEmbeddedWorkerImplTest";
Platform::current()->unitTestSupport()->registerMockedErrorURL(scriptURL, response, error);
m_startData.scriptURL = scriptURL;
EXPECT_CALL(*m_mockClient, workerReadyForInspection())
.Times(1);
m_worker->startWorkerContext(m_startData);
::testing::Mock::VerifyAndClearExpectations(m_mockClient);
// Load the shadow page.
EXPECT_CALL(*m_mockClient, createServiceWorkerNetworkProvider(::testing::_))
.WillOnce(::testing::Return(nullptr));
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
::testing::Mock::VerifyAndClearExpectations(m_mockClient);
// Load the script.
EXPECT_CALL(*m_mockClient, workerScriptLoaded())
.Times(0);
EXPECT_CALL(*m_mockClient, createServiceWorkerProvider())
.Times(0);
EXPECT_CALL(*m_mockClient, workerContextFailedToStart())
.Times(1);
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
::testing::Mock::VerifyAndClearExpectations(m_mockClient);
}
示例2: RegisterMockedUrl
KURL RegisterMockedUrl(const std::string& urlRoot, const WTF::String& filename)
{
WebURLResponse response;
response.initialize();
response.setMIMEType("text/html");
WTF::String localPath = m_baseFilePath;
localPath.append(filename);
KURL url = toKURL(urlRoot + filename.utf8().data());
Platform::current()->unitTestSupport()->registerMockedURL(url, response, localPath);
return url;
}
示例3: registerErrorURL
void registerErrorURL(const char* file, int statusCode)
{
WebURLError error;
error.reason = 0xdead + statusCode;
error.domain = "PageSerializerTest";
WebURLResponse response;
response.initialize();
response.setMIMEType("text/html");
response.setHTTPStatusCode(statusCode);
Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_baseUrl, file), response, error);
}
示例4: requestSynchronously
void ResourceLoader::requestSynchronously()
{
OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader());
ASSERT(loader);
// downloadToFile is not supported for synchronous requests.
ASSERT(!m_request.downloadToFile());
ResourcePtr<Resource> protectResource(m_resource);
RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
m_connectionState = ConnectionStateStarted;
WrappedResourceRequest requestIn(m_request);
WebURLResponse responseOut;
responseOut.initialize();
WebURLError errorOut;
WebData dataOut;
loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
if (errorOut.reason) {
if (m_state == Terminated) {
// A message dispatched while synchronously fetching the resource
// can bring about the cancellation of this load.
ASSERT(!m_resource);
return;
}
didFail(0, errorOut);
return;
}
didReceiveResponse(0, responseOut);
if (m_state == Terminated)
return;
RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse().resourceLoadInfo();
int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLength : WebURLLoaderClient::kUnknownEncodedDataLength;
// Follow the async case convention of not calling didReceiveData or
// appending data to m_resource if the response body is empty. Copying the
// empty buffer is a noop in most cases, but is destructive in the case of
// a 304, where it will overwrite the cached data we should be reusing.
if (dataOut.size()) {
m_fetcher->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDataLength);
m_resource->setResourceBuffer(dataOut);
}
didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
}
示例5: requestSynchronously
void ResourceLoader::requestSynchronously()
{
OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader());
ASSERT(loader);
// downloadToFile is not supported for synchronous requests.
ASSERT(!m_request.downloadToFile());
ResourcePtr<Resource> protectResource(m_resource);
RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
m_connectionState = ConnectionStateStarted;
WrappedResourceRequest requestIn(m_request);
WebURLResponse responseOut;
responseOut.initialize();
WebURLError errorOut;
WebData dataOut;
loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
if (errorOut.reason) {
if (m_state == Terminated) {
// A message dispatched while synchronously fetching the resource
// can bring about the cancellation of this load.
ASSERT(!m_resource);
return;
}
didFail(0, errorOut);
return;
}
didReceiveResponse(0, responseOut);
if (m_state == Terminated)
return;
RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse().resourceLoadInfo();
int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLength : WebURLLoaderClient::kUnknownEncodedDataLength;
m_fetcher->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDataLength);
m_resource->setResourceBuffer(dataOut);
didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
}