本文整理汇总了C++中MessagePort::isCloned方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePort::isCloned方法的具体用法?C++ MessagePort::isCloned怎么用?C++ MessagePort::isCloned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePort
的用法示例。
在下文中一共展示了MessagePort::isCloned方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessagePortChannelArray
PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionCode& ec)
{
if (!ports || !ports->size())
return 0;
// HashSet used to efficiently check for duplicates in the passed-in array.
HashSet<MessagePort*> portSet;
// Walk the incoming array - if there are any duplicate ports, or null ports or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
for (unsigned int i = 0; i < ports->size(); ++i) {
MessagePort* port = (*ports)[i].get();
if (!port || port->isCloned() || portSet.contains(port)) {
ec = INVALID_STATE_ERR;
return 0;
}
portSet.add(port);
}
// Passed-in ports passed validity checks, so we can disentangle them.
MessagePortChannelArray* portArray = new MessagePortChannelArray(ports->size());
for (unsigned int i = 0 ; i < ports->size() ; ++i) {
OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(ec);
ASSERT(!ec); // Can't generate exception here if passed above checks.
(*portArray)[i] = channel.release();
}
return portArray;
}