本文整理汇总了C++中wtf::RefPtr::createHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::createHandle方法的具体用法?C++ RefPtr::createHandle怎么用?C++ RefPtr::createHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wtf::RefPtr
的用法示例。
在下文中一共展示了RefPtr::createHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
void QQuickNetworkReply::send()
{
if (m_data.isNull())
return;
uint64_t smLength = 0;
const void* ptrData = 0;
QString stringData;
QByteArray byteArrayData;
if (m_data.type() == QVariant::String) {
stringData = m_data.toString();
ptrData = reinterpret_cast<const void*>(stringData.constData());
smLength = sizeof(QChar) * stringData.length();
setContentType(QLatin1String("text/html; charset=utf-16"));
} else {
if (!m_data.canConvert<QByteArray>())
return;
byteArrayData = m_data.toByteArray();
ptrData = byteArrayData.data();
smLength = byteArrayData.size();
}
if (contentType().isEmpty()) {
qWarning("QQuickNetworkReply::send - Cannot send raw data without a content type being specified!");
return;
}
WTF::RefPtr<WebKit::SharedMemory> sharedMemory = SharedMemory::create(smLength);
if (!sharedMemory)
return;
// The size of the allocated shared memory can be bigger than requested.
// Usually the size will be rounded up to the next multiple of a page size.
memcpy(sharedMemory->data(), ptrData, smLength);
if (sharedMemory->createHandle(m_networkReplyData->data().m_dataHandle, SharedMemory::ReadOnly)) {
m_networkReplyData->data().m_contentLength = smLength;
if (m_webViewExperimental)
m_webViewExperimental.data()->sendApplicationSchemeReply(this);
}
// After sending the reply data, we have to reinitialize the m_networkReplyData,
// to make sure we have a fresh SharesMemory::Handle.
m_networkReplyData = adoptRef(new WebKit::QtRefCountedNetworkReplyData);
}