2009-09-21 18:51:35 +04:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-09-21 18:51:35 +04:00
|
|
|
|
|
|
|
#include "PluginStreamChild.h"
|
|
|
|
#include "mozilla/plugins/PluginInstanceChild.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
|
2009-12-03 11:16:14 +03:00
|
|
|
PluginStreamChild::PluginStreamChild()
|
2010-07-13 22:56:42 +04:00
|
|
|
: mClosed(false)
|
2009-09-21 18:51:35 +04:00
|
|
|
{
|
|
|
|
memset(&mStream, 0, sizeof(mStream));
|
|
|
|
mStream.ndata = static_cast<AStream*>(this);
|
|
|
|
}
|
|
|
|
|
2009-12-03 11:16:14 +03:00
|
|
|
bool
|
|
|
|
PluginStreamChild::Answer__delete__(const NPReason& reason,
|
|
|
|
const bool& artificial)
|
|
|
|
{
|
|
|
|
AssertPluginThread();
|
|
|
|
if (!artificial)
|
|
|
|
NPP_DestroyStream(reason);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-21 18:51:35 +04:00
|
|
|
int32_t
|
|
|
|
PluginStreamChild::NPN_Write(int32_t length, void* buffer)
|
|
|
|
{
|
2009-10-08 23:11:13 +04:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-21 18:51:35 +04:00
|
|
|
int32_t written = 0;
|
|
|
|
CallNPN_Write(nsCString(static_cast<char*>(buffer), length),
|
|
|
|
&written);
|
|
|
|
if (written < 0)
|
2009-12-03 11:16:14 +03:00
|
|
|
PPluginStreamChild::Call__delete__(this, NPERR_GENERIC_ERROR, true);
|
|
|
|
// careful after here! |this| just got deleted
|
2009-09-21 18:51:35 +04:00
|
|
|
|
|
|
|
return written;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginStreamChild::NPP_DestroyStream(NPError reason)
|
|
|
|
{
|
2009-10-08 23:11:13 +04:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-21 18:51:35 +04:00
|
|
|
if (mClosed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mClosed = true;
|
2009-12-03 11:16:14 +03:00
|
|
|
Instance()->mPluginIface->destroystream(
|
|
|
|
&Instance()->mData, &mStream, reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginInstanceChild*
|
|
|
|
PluginStreamChild::Instance()
|
|
|
|
{
|
|
|
|
return static_cast<PluginInstanceChild*>(Manager());
|
2009-09-21 18:51:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|