2010-03-23 07:30:51 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et :
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-23 07:30:51 -07:00
|
|
|
|
|
|
|
#ifndef dom_plugins_PluginIdentifierParent_h
|
|
|
|
#define dom_plugins_PluginIdentifierParent_h
|
|
|
|
|
|
|
|
#include "mozilla/plugins/PPluginIdentifierParent.h"
|
|
|
|
|
|
|
|
#include "npapi.h"
|
|
|
|
#include "npruntime.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
|
2011-06-14 12:49:48 -07:00
|
|
|
class PluginInstanceParent;
|
|
|
|
|
2010-03-23 07:30:51 -07:00
|
|
|
class PluginIdentifierParent : public PPluginIdentifierParent
|
|
|
|
{
|
|
|
|
friend class PluginModuleParent;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NPIdentifier ToNPIdentifier()
|
|
|
|
{
|
|
|
|
return mIdentifier;
|
|
|
|
}
|
|
|
|
|
2011-06-14 12:49:48 -07:00
|
|
|
bool IsTemporary() {
|
|
|
|
return !!mTemporaryRefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds a perhaps-temporary identifier for the current stack frame.
|
|
|
|
*/
|
|
|
|
class NS_STACK_CLASS StackIdentifier
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StackIdentifier(PluginInstanceParent* inst, NPIdentifier aIdentifier);
|
|
|
|
StackIdentifier(NPObject* aObject, NPIdentifier aIdentifier);
|
|
|
|
~StackIdentifier();
|
|
|
|
|
|
|
|
operator PluginIdentifierParent*() {
|
|
|
|
return mIdentifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(StackIdentifier);
|
|
|
|
|
|
|
|
PluginIdentifierParent* mIdentifier;
|
|
|
|
};
|
|
|
|
|
2010-03-23 07:30:51 -07:00
|
|
|
protected:
|
2011-06-14 12:49:48 -07:00
|
|
|
PluginIdentifierParent(NPIdentifier aIdentifier, bool aTemporary)
|
2010-03-23 07:30:51 -07:00
|
|
|
: mIdentifier(aIdentifier)
|
2011-06-14 12:49:48 -07:00
|
|
|
, mTemporaryRefs(aTemporary ? 1 : 0)
|
2010-03-23 07:30:51 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(PluginIdentifierParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~PluginIdentifierParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(PluginIdentifierParent);
|
|
|
|
}
|
|
|
|
|
2011-06-14 12:49:48 -07:00
|
|
|
virtual bool RecvRetain();
|
|
|
|
|
|
|
|
void AddTemporaryRef() {
|
|
|
|
mTemporaryRefs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns true if the last temporary reference was removed.
|
|
|
|
*/
|
|
|
|
bool RemoveTemporaryRef() {
|
|
|
|
--mTemporaryRefs;
|
|
|
|
return !mTemporaryRefs;
|
|
|
|
}
|
|
|
|
|
2010-03-23 07:30:51 -07:00
|
|
|
private:
|
|
|
|
NPIdentifier mIdentifier;
|
2011-06-14 12:49:48 -07:00
|
|
|
unsigned int mTemporaryRefs;
|
2010-03-23 07:30:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // dom_plugins_PluginIdentifierParent_h
|