Пример #1
0
// static
MessagePortArray* MessagePort::toMessagePortArray(
    ExecutionContext* context,
    const WebMessagePortChannelArray& webChannels) {
  std::unique_ptr<MessagePortChannelArray> channels =
      wrapUnique(new MessagePortChannelArray(webChannels.size()));
  for (size_t i = 0; i < webChannels.size(); ++i)
    (*channels)[i] = WebMessagePortChannelUniquePtr(webChannels[i]);
  return MessagePort::entanglePorts(*context, std::move(channels));
}
Пример #2
0
static bool tryGetMessageFrom(
    WebMessagePortChannel& webChannel,
    RefPtr<SerializedScriptValue>& message,
    std::unique_ptr<MessagePortChannelArray>& channels) {
  WebString messageString;
  WebMessagePortChannelArray webChannels;
  if (!webChannel.tryGetMessage(&messageString, webChannels))
    return false;

  if (webChannels.size()) {
    channels = wrapUnique(new MessagePortChannelArray(webChannels.size()));
    for (size_t i = 0; i < webChannels.size(); ++i)
      (*channels)[i] = WebMessagePortChannelUniquePtr(webChannels[i]);
  }
  message = SerializedScriptValue::create(messageString);
  return true;
}
Пример #3
0
void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) {
  workerThread()->postTask(
      BLINK_FROM_HERE,
      createCrossThreadTask(
          &connectTask, passed(WebMessagePortChannelUniquePtr(webChannel))));
}