当前位置: 首页>>代码示例>>C++>>正文


C++ WebURLResponse::initialize方法代码示例

本文整理汇总了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);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:34,代码来源:WebEmbeddedWorkerImplTest.cpp

示例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;
 }
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:11,代码来源:AssociatedURLLoaderTest.cpp

示例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);
    }
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:13,代码来源:PageSerializerTest.cpp

示例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);
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:45,代码来源:ResourceLoader.cpp

示例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);
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:38,代码来源:ResourceLoader.cpp


注:本文中的WebURLResponse::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。