dom/plugins/ipc/PluginStreamChild.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "PluginStreamChild.h"
michael@0 7 #include "mozilla/plugins/PluginInstanceChild.h"
michael@0 8
michael@0 9 namespace mozilla {
michael@0 10 namespace plugins {
michael@0 11
michael@0 12 PluginStreamChild::PluginStreamChild()
michael@0 13 : mClosed(false)
michael@0 14 {
michael@0 15 memset(&mStream, 0, sizeof(mStream));
michael@0 16 mStream.ndata = static_cast<AStream*>(this);
michael@0 17 }
michael@0 18
michael@0 19 bool
michael@0 20 PluginStreamChild::Answer__delete__(const NPReason& reason,
michael@0 21 const bool& artificial)
michael@0 22 {
michael@0 23 AssertPluginThread();
michael@0 24 if (!artificial)
michael@0 25 NPP_DestroyStream(reason);
michael@0 26 return true;
michael@0 27 }
michael@0 28
michael@0 29 int32_t
michael@0 30 PluginStreamChild::NPN_Write(int32_t length, void* buffer)
michael@0 31 {
michael@0 32 AssertPluginThread();
michael@0 33
michael@0 34 int32_t written = 0;
michael@0 35 CallNPN_Write(nsCString(static_cast<char*>(buffer), length),
michael@0 36 &written);
michael@0 37 if (written < 0)
michael@0 38 PPluginStreamChild::Call__delete__(this, NPERR_GENERIC_ERROR, true);
michael@0 39 // careful after here! |this| just got deleted
michael@0 40
michael@0 41 return written;
michael@0 42 }
michael@0 43
michael@0 44 void
michael@0 45 PluginStreamChild::NPP_DestroyStream(NPError reason)
michael@0 46 {
michael@0 47 AssertPluginThread();
michael@0 48
michael@0 49 if (mClosed)
michael@0 50 return;
michael@0 51
michael@0 52 mClosed = true;
michael@0 53 Instance()->mPluginIface->destroystream(
michael@0 54 &Instance()->mData, &mStream, reason);
michael@0 55 }
michael@0 56
michael@0 57 PluginInstanceChild*
michael@0 58 PluginStreamChild::Instance()
michael@0 59 {
michael@0 60 return static_cast<PluginInstanceChild*>(Manager());
michael@0 61 }
michael@0 62
michael@0 63 } // namespace plugins
michael@0 64 } // namespace mozilla

mercurial