michael@0: /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "PluginStreamChild.h" michael@0: #include "mozilla/plugins/PluginInstanceChild.h" michael@0: michael@0: namespace mozilla { michael@0: namespace plugins { michael@0: michael@0: PluginStreamChild::PluginStreamChild() michael@0: : mClosed(false) michael@0: { michael@0: memset(&mStream, 0, sizeof(mStream)); michael@0: mStream.ndata = static_cast(this); michael@0: } michael@0: michael@0: bool michael@0: PluginStreamChild::Answer__delete__(const NPReason& reason, michael@0: const bool& artificial) michael@0: { michael@0: AssertPluginThread(); michael@0: if (!artificial) michael@0: NPP_DestroyStream(reason); michael@0: return true; michael@0: } michael@0: michael@0: int32_t michael@0: PluginStreamChild::NPN_Write(int32_t length, void* buffer) michael@0: { michael@0: AssertPluginThread(); michael@0: michael@0: int32_t written = 0; michael@0: CallNPN_Write(nsCString(static_cast(buffer), length), michael@0: &written); michael@0: if (written < 0) michael@0: PPluginStreamChild::Call__delete__(this, NPERR_GENERIC_ERROR, true); michael@0: // careful after here! |this| just got deleted michael@0: michael@0: return written; michael@0: } michael@0: michael@0: void michael@0: PluginStreamChild::NPP_DestroyStream(NPError reason) michael@0: { michael@0: AssertPluginThread(); michael@0: michael@0: if (mClosed) michael@0: return; michael@0: michael@0: mClosed = true; michael@0: Instance()->mPluginIface->destroystream( michael@0: &Instance()->mData, &mStream, reason); michael@0: } michael@0: michael@0: PluginInstanceChild* michael@0: PluginStreamChild::Instance() michael@0: { michael@0: return static_cast(Manager()); michael@0: } michael@0: michael@0: } // namespace plugins michael@0: } // namespace mozilla