dom/plugins/ipc/PluginIdentifierParent.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++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * vim: sw=2 ts=2 et :
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "PluginIdentifierParent.h"
michael@0 8
michael@0 9 #include "nsNPAPIPlugin.h"
michael@0 10 #include "nsServiceManagerUtils.h"
michael@0 11 #include "PluginScriptableObjectUtils.h"
michael@0 12 #include "nsCxPusher.h"
michael@0 13 #include "mozilla/unused.h"
michael@0 14
michael@0 15 using namespace mozilla::plugins::parent;
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18 namespace plugins {
michael@0 19
michael@0 20 bool
michael@0 21 PluginIdentifierParent::RecvRetain()
michael@0 22 {
michael@0 23 mTemporaryRefs = 0;
michael@0 24
michael@0 25 // Intern the jsid if necessary.
michael@0 26 AutoSafeJSContext cx;
michael@0 27 JS::Rooted<jsid> id(cx, NPIdentifierToJSId(mIdentifier));
michael@0 28 if (JSID_IS_INT(id)) {
michael@0 29 return true;
michael@0 30 }
michael@0 31
michael@0 32 // The following is what nsNPAPIPlugin.cpp does. Gross, but the API doesn't
michael@0 33 // give you a NPP to play with.
michael@0 34 JS::Rooted<JSString*> str(cx, JSID_TO_STRING(id));
michael@0 35 JSString* str2 = JS_InternJSString(cx, str);
michael@0 36 if (!str2) {
michael@0 37 return false;
michael@0 38 }
michael@0 39
michael@0 40 NS_ASSERTION(str == str2, "Interning a string in a JSID should always return the same string.");
michael@0 41
michael@0 42 return true;
michael@0 43 }
michael@0 44
michael@0 45 PluginIdentifierParent::StackIdentifier::StackIdentifier
michael@0 46 (PluginInstanceParent* inst, NPIdentifier aIdentifier)
michael@0 47 : mIdentifier(inst->Module()->GetIdentifierForNPIdentifier(inst->GetNPP(), aIdentifier))
michael@0 48 {
michael@0 49 }
michael@0 50
michael@0 51 PluginIdentifierParent::StackIdentifier::StackIdentifier
michael@0 52 (NPObject* aObject, NPIdentifier aIdentifier)
michael@0 53 : mIdentifier(nullptr)
michael@0 54 {
michael@0 55 PluginInstanceParent* inst = GetInstance(aObject);
michael@0 56 mIdentifier = inst->Module()->GetIdentifierForNPIdentifier(inst->GetNPP(), aIdentifier);
michael@0 57 }
michael@0 58
michael@0 59 PluginIdentifierParent::StackIdentifier::~StackIdentifier()
michael@0 60 {
michael@0 61 if (!mIdentifier) {
michael@0 62 return;
michael@0 63 }
michael@0 64
michael@0 65 if (!mIdentifier->IsTemporary()) {
michael@0 66 return;
michael@0 67 }
michael@0 68
michael@0 69 if (mIdentifier->RemoveTemporaryRef()) {
michael@0 70 unused << PPluginIdentifierParent::Send__delete__(mIdentifier);
michael@0 71 }
michael@0 72 }
michael@0 73
michael@0 74 } // namespace mozilla::plugins
michael@0 75 } // namespace mozilla

mercurial