Bug 1148012 - Expose run ID through nsIObjectLoadingContent.idl. r=josh,smaug.

The run ID for a plugin is retrieved and cached in the nsObjectLoadingContent
on plugin instantiation.

--HG--
extra : rebase_source : d1e87b7751e6367c482b2420aa43bfadbce5e3e8
This commit is contained in:
Mike Conley 2015-03-17 13:28:32 -04:00
parent 22a0f74e8f
commit d95fcd35e3
9 changed files with 82 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class nsNPAPIPluginInstance;
* interface to mirror this interface when changing it.
*/
[scriptable, uuid(16c14177-52eb-49d3-9842-a1a0b92be11a)]
[scriptable, uuid(5efbd411-5bbe-4de1-9f3a-1c3459696eb2)]
interface nsIObjectLoadingContent : nsISupports
{
/**
@ -188,4 +188,12 @@ interface nsIObjectLoadingContent : nsISupports
* This method will disable the play-preview plugin state.
*/
void cancelPlayPreview();
/**
* If this plugin runs out-of-process, it has a runID to differentiate
* between different times the plugin process has been instantiated.
*
* This throws NS_ERROR_NOT_IMPLEMENTED for in-process plugins.
*/
readonly attribute unsigned long runID;
};

View File

@ -701,6 +701,8 @@ nsObjectLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
nsObjectLoadingContent::nsObjectLoadingContent()
: mType(eType_Loading)
, mFallbackType(eFallbackAlternate)
, mRunID(0)
, mHasRunID(false)
, mChannelLoaded(false)
, mInstantiating(false)
, mNetworkCreated(true)
@ -815,6 +817,17 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
mInstanceOwner = newOwner;
if (mInstanceOwner) {
nsRefPtr<nsNPAPIPluginInstance> inst;
rv = mInstanceOwner->GetInstance(getter_AddRefs(inst));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = inst->GetRunID(&mRunID);
mHasRunID = NS_SUCCEEDED(rv);
}
// Ensure the frame did not change during instantiation re-entry (common).
// HasNewFrame would not have mInstanceOwner yet, so the new frame would be
// dangling. (Bug 854082)
@ -3145,6 +3158,24 @@ nsObjectLoadingContent::CancelPlayPreview()
return NS_OK;
}
NS_IMETHODIMP
nsObjectLoadingContent::GetRunID(uint32_t* aRunID)
{
if (NS_WARN_IF(!nsContentUtils::IsCallerChrome())) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_WARN_IF(!aRunID)) {
return NS_ERROR_INVALID_POINTER;
}
if (!mHasRunID) {
// The plugin instance must not have a run ID, so we must
// be running the plugin in-process.
return NS_ERROR_NOT_IMPLEMENTED;
}
*aRunID = mRunID;
return NS_OK;
}
static bool sPrefsInitialized;
static uint32_t sSessionTimeoutMinutes;
static uint32_t sPersistentTimeoutDays;

View File

@ -233,6 +233,18 @@ class nsObjectLoadingContent : public nsImageLoadingContent
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv);
uint32_t GetRunID(mozilla::ErrorResult& aRv)
{
uint32_t runID;
nsresult rv = GetRunID(&runID);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return 0;
}
return runID;
}
protected:
/**
* Begins loading the object when called
@ -579,6 +591,9 @@ class nsObjectLoadingContent : public nsImageLoadingContent
// The type of fallback content we're showing (see ObjectState())
FallbackType mFallbackType : 8;
uint32_t mRunID;
bool mHasRunID;
// If true, we have opened a channel as the listener and it has reached
// OnStartRequest. Does not get set for channels that are passed directly to
// the plugin listener.

View File

@ -122,6 +122,7 @@ public:
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext* aCtx, const nsIntRect&) override;
virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); }
virtual nsresult GetRunID(uint32_t* aRunID) override { return NS_ERROR_NOT_IMPLEMENTED; }
private:
NP_InitializeFunc mNP_Initialize;

View File

@ -1778,3 +1778,22 @@ nsNPAPIPluginInstance::GetContentsScaleFactor()
}
return scaleFactor;
}
nsresult
nsNPAPIPluginInstance::GetRunID(uint32_t* aRunID)
{
if (NS_WARN_IF(!aRunID)) {
return NS_ERROR_INVALID_POINTER;
}
if (NS_WARN_IF(!mPlugin)) {
return NS_ERROR_FAILURE;
}
PluginLibrary* library = mPlugin->GetLibrary();
if (!library) {
return NS_ERROR_FAILURE;
}
return library->GetRunID(aRunID);
}

View File

@ -286,6 +286,8 @@ public:
// Returns the contents scale factor of the screen the plugin is drawn on.
double GetContentsScaleFactor();
nsresult GetRunID(uint32_t *aRunID);
static bool InPluginCallUnsafeForReentry() { return gInUnsafePluginCalls > 0; }
static void BeginPluginCall(NSPluginCallReentry aReentryState)
{

View File

@ -84,6 +84,7 @@ public:
const nsIntRect&, gfxContext**) = 0;
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext*, const nsIntRect&) = 0;
virtual nsresult GetRunID(uint32_t* aRunID) = 0;
};

View File

@ -128,7 +128,7 @@ public:
return mPluginName + mPluginVersion;
}
nsresult GetRunID(uint32_t* aRunID);
virtual nsresult GetRunID(uint32_t* aRunID) override;
protected:
virtual mozilla::ipc::RacyInterruptPolicy

View File

@ -211,6 +211,9 @@ interface MozObjectLoadingContent {
*/
[ChromeOnly, Throws]
void cancelPlayPreview();
[ChromeOnly, Throws]
readonly attribute unsigned long runID;
};
/**