Ejemplo n.º 1
0
BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
                                       const nsCString& url,
                                       const uint32_t& length,
                                       const uint32_t& lastmodified,
                                       StreamNotifyChild* notifyData,
                                       const nsCString& headers)
  : mInstance(instance)
  , mStreamStatus(kStreamOpen)
  , mDestroyPending(NOT_DESTROYED)
  , mNotifyPending(false)
  , mStreamAsFilePending(false)
  , mInstanceDying(false)
  , mState(CONSTRUCTING)
  , mURL(url)
  , mHeaders(headers)
  , mStreamNotify(notifyData)
  , mDeliveryTracker(this)
{
  PLUGIN_LOG_DEBUG(("%s (%s, %i, %i, %p, %s)", FULLFUNCTION,
                    url.get(), length, lastmodified, (void*) notifyData,
                    headers.get()));

  AssertPluginThread();

  memset(&mStream, 0, sizeof(mStream));
  mStream.ndata = static_cast<AStream*>(this);
  mStream.url = NullableStringGet(mURL);
  mStream.end = length;
  mStream.lastmodified = lastmodified;
  mStream.headers = NullableStringGet(mHeaders);
  if (notifyData) {
    mStream.notifyData = notifyData->mClosure;
    notifyData->SetAssociatedStream(this);
  }
}
NPError
BrowserStreamChild::StreamConstructed(
            const nsCString& mimeType,
            const bool& seekable,
            uint16_t* stype)
{
  NPError rv = NPERR_NO_ERROR;

  *stype = NP_NORMAL;
  rv = mInstance->mPluginIface->newstream(
    &mInstance->mData, const_cast<char*>(NullableStringGet(mimeType)),
    &mStream, seekable, stype);
  if (rv != NPERR_NO_ERROR) {
    mState = DELETING;
    mStreamNotify = NULL;
  }
  else {
    mState = ALIVE;

    if (mStreamNotify)
      mStreamNotify->SetAssociatedStream(this);
  }

  return rv;
}
Ejemplo n.º 3
0
void
PluginAsyncSurrogate::OnInstanceCreated(PluginInstanceParent* aInstance)
{
  for (PRUint32 i = 0, len = mPendingNewStreamCalls.Length(); i < len; ++i) {
    PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[i];
    uint16_t streamType = NP_NORMAL;
    NPError curError = aInstance->NPP_NewStream(
                    const_cast<char*>(NullableStringGet(curPendingCall.mType)),
                    curPendingCall.mStream, curPendingCall.mSeekable,
                    &streamType);
    if (curError != NPERR_NO_ERROR) {
      // If we failed here then the send failed and we need to clean up
      parent::_destroystream(mInstance, curPendingCall.mStream, NPRES_DONE);
    }
  }
  mPendingNewStreamCalls.Clear();
  mInstantiated = true;
}
Ejemplo n.º 4
0
void
PluginAsyncSurrogate::OnInstanceCreated(PluginInstanceParent* aInstance)
{
  if (!mDestroyPending) {
    // If NPP_Destroy has already been called then these streams have already
    // been cleaned up on the browser side and are no longer valid.
    for (uint32_t i = 0, len = mPendingNewStreamCalls.Length(); i < len; ++i) {
      PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[i];
      uint16_t streamType = NP_NORMAL;
      NPError curError = aInstance->NPP_NewStream(
                      const_cast<char*>(NullableStringGet(curPendingCall.mType)),
                      curPendingCall.mStream, curPendingCall.mSeekable,
                      &streamType);
      if (curError != NPERR_NO_ERROR) {
        // If we failed here then the send failed and we need to clean up
        DestroyAsyncStream(curPendingCall.mStream);
      }
    }
  }
  mPendingNewStreamCalls.Clear();
  mInstantiated = true;
}