1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/ipc/PluginStreamChild.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "PluginStreamChild.h" 1.10 +#include "mozilla/plugins/PluginInstanceChild.h" 1.11 + 1.12 +namespace mozilla { 1.13 +namespace plugins { 1.14 + 1.15 +PluginStreamChild::PluginStreamChild() 1.16 + : mClosed(false) 1.17 +{ 1.18 + memset(&mStream, 0, sizeof(mStream)); 1.19 + mStream.ndata = static_cast<AStream*>(this); 1.20 +} 1.21 + 1.22 +bool 1.23 +PluginStreamChild::Answer__delete__(const NPReason& reason, 1.24 + const bool& artificial) 1.25 +{ 1.26 + AssertPluginThread(); 1.27 + if (!artificial) 1.28 + NPP_DestroyStream(reason); 1.29 + return true; 1.30 +} 1.31 + 1.32 +int32_t 1.33 +PluginStreamChild::NPN_Write(int32_t length, void* buffer) 1.34 +{ 1.35 + AssertPluginThread(); 1.36 + 1.37 + int32_t written = 0; 1.38 + CallNPN_Write(nsCString(static_cast<char*>(buffer), length), 1.39 + &written); 1.40 + if (written < 0) 1.41 + PPluginStreamChild::Call__delete__(this, NPERR_GENERIC_ERROR, true); 1.42 + // careful after here! |this| just got deleted 1.43 + 1.44 + return written; 1.45 +} 1.46 + 1.47 +void 1.48 +PluginStreamChild::NPP_DestroyStream(NPError reason) 1.49 +{ 1.50 + AssertPluginThread(); 1.51 + 1.52 + if (mClosed) 1.53 + return; 1.54 + 1.55 + mClosed = true; 1.56 + Instance()->mPluginIface->destroystream( 1.57 + &Instance()->mData, &mStream, reason); 1.58 +} 1.59 + 1.60 +PluginInstanceChild* 1.61 +PluginStreamChild::Instance() 1.62 +{ 1.63 + return static_cast<PluginInstanceChild*>(Manager()); 1.64 +} 1.65 + 1.66 +} // namespace plugins 1.67 +} // namespace mozilla