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


C++ MessagePortArray::size方法代码示例

本文整理汇总了C++中MessagePortArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePortArray::size方法的具体用法?C++ MessagePortArray::size怎么用?C++ MessagePortArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessagePortArray的用法示例。


在下文中一共展示了MessagePortArray::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.MessageEvent.ports");
    MessageEvent* event = V8MessageEvent::toNative(info.Holder());

    MessagePortArray* ports = event->ports();
    if (!ports || ports->isEmpty())
        return v8::Null();

    v8::Local<v8::Array> portArray = v8::Array::New(ports->size());
    for (size_t i = 0; i < ports->size(); ++i)
        portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get()));

    return portArray;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:15,代码来源:V8MessageEventCustom.cpp

示例2: postMessage

void MessagePort::postMessage(ExecutionContext* context,
                              PassRefPtr<SerializedScriptValue> message,
                              const MessagePortArray& ports,
                              ExceptionState& exceptionState) {
  if (!isEntangled())
    return;
  DCHECK(getExecutionContext());
  DCHECK(m_entangledChannel);

  // Make sure we aren't connected to any of the passed-in ports.
  for (unsigned i = 0; i < ports.size(); ++i) {
    if (ports[i] == this) {
      exceptionState.throwDOMException(
          DataCloneError,
          "Port at index " + String::number(i) + " contains the source port.");
      return;
    }
  }
  std::unique_ptr<MessagePortChannelArray> channels =
      MessagePort::disentanglePorts(context, ports, exceptionState);
  if (exceptionState.hadException())
    return;

  if (message->containsTransferableArrayBuffer())
    getExecutionContext()->addConsoleMessage(ConsoleMessage::create(
        JSMessageSource, WarningMessageLevel,
        "MessagePort cannot send an ArrayBuffer as a transferable object yet. "
        "See http://crbug.com/334408"));

  WebString messageString = message->toWireString();
  std::unique_ptr<WebMessagePortChannelArray> webChannels =
      toWebMessagePortChannelArray(std::move(channels));
  m_entangledChannel->postMessage(messageString, webChannels.release());
}
开发者ID:ollie314,项目名称:chromium,代码行数:34,代码来源:MessagePort.cpp

示例3: ports

JSValue JSMessageEvent::ports(ExecState* exec) const
{
    MessagePortArray* ports = static_cast<MessageEvent*>(impl())->ports();
    if (!ports)
        return constructEmptyArray(exec, globalObject());

    MarkedArgumentBuffer list;
    for (size_t i = 0; i < ports->size(); i++)
        list.append(toJS(exec, globalObject(), (*ports)[i].get()));
    return constructArray(exec, globalObject(), list);
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:11,代码来源:JSMessageEventCustom.cpp

示例4: if

std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(
    ExecutionContext* context,
    const MessagePortArray& ports,
    ExceptionState& exceptionState) {
  if (!ports.size())
    return nullptr;

  HeapHashSet<Member<MessagePort>> visited;

  // 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 i = 0; i < ports.size(); ++i) {
    MessagePort* port = ports[i];
    if (!port || port->isNeutered() || visited.contains(port)) {
      String type;
      if (!port)
        type = "null";
      else if (port->isNeutered())
        type = "already neutered";
      else
        type = "a duplicate";
      exceptionState.throwDOMException(
          DataCloneError,
          "Port at index " + String::number(i) + " is " + type + ".");
      return nullptr;
    }
    visited.add(port);
  }

  UseCounter::count(context, UseCounter::MessagePortsTransferred);

  // Passed-in ports passed validity checks, so we can disentangle them.
  std::unique_ptr<MessagePortChannelArray> portArray =
      wrapUnique(new MessagePortChannelArray(ports.size()));
  for (unsigned i = 0; i < ports.size(); ++i)
    (*portArray)[i] = ports[i]->disentangle();
  return portArray;
}
开发者ID:ollie314,项目名称:chromium,代码行数:38,代码来源:MessagePort.cpp


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