本文整理汇总了C++中MessagePortArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePortArray::begin方法的具体用法?C++ MessagePortArray::begin怎么用?C++ MessagePortArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePortArray
的用法示例。
在下文中一共展示了MessagePortArray::begin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: channel
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Odd sizes are handled in various ways, depending how they arrive.
// Let's not worry about that case here.
if (size % sizeof(UChar))
return 0;
// Used to control what kind of extra data is provided to the deserializer.
unsigned hash = StringHasher::hashMemory(data, size);
// If message ports are requested, make some.
MessagePortArray* messagePorts = nullptr;
if (hash & kFuzzMessagePorts) {
messagePorts = new MessagePortArray(3);
std::generate(messagePorts->begin(), messagePorts->end(), []() {
WebMessagePortChannelUniquePtr channel(new WebMessagePortChannelImpl());
MessagePort* port = MessagePort::create(pageHolder->document());
port->entangle(std::move(channel));
return port;
});
}
// If blobs are requested, supply blob info.
const auto* blobs = (hash & kFuzzBlobInfo) ? blobInfoArray : nullptr;
// Set up.
ScriptState* scriptState = ScriptState::forMainWorld(&pageHolder->frame());
v8::Isolate* isolate = scriptState->isolate();
ScriptState::Scope scope(scriptState);
v8::TryCatch tryCatch(isolate);
// Deserialize.
RefPtr<SerializedScriptValue> serializedScriptValue =
SerializedScriptValue::create(reinterpret_cast<const char*>(data), size);
serializedScriptValue->deserialize(isolate, messagePorts, blobs);
CHECK(!tryCatch.HasCaught())
<< "deserialize() should return null rather than throwing an exception.";
// Clean up. We have to periodically run pending tasks so that scheduled
// Oilpan GC occurs.
static int iterations = 0;
if (iterations++ == 2048) {
testing::runPendingTasks();
iterations = 0;
}
return 0;
}