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