Bug 998863: Asynchronous Plugin Initialization, Part 5: PluginModuleChild changes; r=jimm

This commit is contained in:
Aaron Klotz 2014-12-29 16:13:01 -07:00
Родитель 5374a7a76b
Коммит fa4fa1ef01
2 изменённых файлов: 69 добавлений и 71 удалений

Просмотреть файл

@ -95,6 +95,13 @@ static GetWindowInfoPtr sGetWindowInfoPtrStub = nullptr;
static HWND sBrowserHwnd = nullptr;
#endif
template<>
struct RunnableMethodTraits<PluginModuleChild>
{
static void RetainCallee(PluginModuleChild* obj) { }
static void ReleaseCallee(PluginModuleChild* obj) { }
};
/* static */
PluginModuleChild*
PluginModuleChild::CreateForContentProcess(mozilla::ipc::Transport* aTransport,
@ -1881,7 +1888,21 @@ PluginModuleChild::AnswerNP_GetEntryPoints(NPError* _retval)
}
bool
PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError* _retval)
PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError* rv)
{
*rv = DoNP_Initialize(aSettings);
return true;
}
bool
PluginModuleChild::RecvAsyncNP_Initialize(const PluginSettings& aSettings)
{
NPError error = DoNP_Initialize(aSettings);
return SendNP_InitializeResult(error);
}
NPError
PluginModuleChild::DoNP_Initialize(const PluginSettings& aSettings)
{
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
@ -1900,12 +1921,11 @@ PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError*
SendBackUpXResources(FileDescriptor(xSocketFd));
#endif
NPError result;
#if defined(OS_LINUX) || defined(OS_BSD)
*_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions);
return true;
result = mInitializeFunc(&sBrowserFuncs, &mFunctions);
#elif defined(OS_WIN) || defined(OS_MACOSX)
*_retval = mInitializeFunc(&sBrowserFuncs);
return true;
result = mInitializeFunc(&sBrowserFuncs);
#else
# error Please implement me for your platform
#endif
@ -1913,6 +1933,8 @@ PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError*
#ifdef XP_WIN
CleanupProtectedModeHook();
#endif
return result;
}
#if defined(XP_WIN)
@ -2035,8 +2057,7 @@ PPluginInstanceChild*
PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv)
const InfallibleTArray<nsCString>& aValues)
{
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
@ -2052,7 +2073,8 @@ PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
}
#endif
return new PluginInstanceChild(&mFunctions);
return new PluginInstanceChild(&mFunctions, aMimeType, aMode, aNames,
aValues);
}
void
@ -2105,68 +2127,39 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
}
bool
PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv)
PluginModuleChild::RecvPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
{
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
NS_ASSERTION(aActor, "Null actor!");
return true;
}
bool
PluginModuleChild::AnswerSyncNPP_New(PPluginInstanceChild* aActor, NPError* rv)
{
PLUGIN_LOG_DEBUG_METHOD;
PluginInstanceChild* childInstance =
reinterpret_cast<PluginInstanceChild*>(aActor);
NS_ASSERTION(childInstance, "Null actor!");
// unpack the arguments into a C format
int argc = aNames.Length();
NS_ASSERTION(argc == (int) aValues.Length(),
"argn.length != argv.length");
nsAutoArrayPtr<char*> argn(new char*[1 + argc]);
nsAutoArrayPtr<char*> argv(new char*[1 + argc]);
argn[argc] = 0;
argv[argc] = 0;
for (int i = 0; i < argc; ++i) {
argn[i] = const_cast<char*>(NullableStringGet(aNames[i]));
argv[i] = const_cast<char*>(NullableStringGet(aValues[i]));
}
NPP npp = childInstance->GetNPP();
// FIXME/cjones: use SAFE_CALL stuff
*rv = mFunctions.newp((char*)NullableStringGet(aMimeType),
npp,
aMode,
argc,
argn,
argv,
0);
if (NPERR_NO_ERROR != *rv) {
return true;
}
childInstance->Initialize();
#if defined(XP_MACOSX) && defined(__i386__)
// If an i386 Mac OS X plugin has selected the Carbon event model then
// we have to fail. We do not support putting Carbon event model plugins
// out of process. Note that Carbon is the default model so out of process
// plugins need to actively negotiate something else in order to work
// out of process.
if (childInstance->EventModel() == NPEventModelCarbon) {
// Send notification that a plugin tried to negotiate Carbon NPAPI so that
// users can be notified that restarting the browser in i386 mode may allow
// them to use the plugin.
childInstance->SendNegotiatedCarbon();
// Fail to instantiate.
*rv = NPERR_MODULE_LOAD_FAILED_ERROR;
}
#endif
AssertPluginThread();
*rv = childInstance->DoNPP_New();
return true;
}
bool
PluginModuleChild::RecvAsyncNPP_New(PPluginInstanceChild* aActor)
{
PLUGIN_LOG_DEBUG_METHOD;
PluginInstanceChild* childInstance =
reinterpret_cast<PluginInstanceChild*>(aActor);
AssertPluginThread();
NPError rv = childInstance->DoNPP_New();
childInstance->SendAsyncNPP_NewResult(rv);
return true;
}

Просмотреть файл

@ -78,6 +78,10 @@ protected:
virtual bool RecvDisableFlashProtectedMode() MOZ_OVERRIDE;
virtual bool AnswerNP_GetEntryPoints(NPError* rv) MOZ_OVERRIDE;
virtual bool AnswerNP_Initialize(const PluginSettings& aSettings, NPError* rv) MOZ_OVERRIDE;
virtual bool RecvAsyncNP_Initialize(const PluginSettings& aSettings) MOZ_OVERRIDE;
virtual bool AnswerSyncNPP_New(PPluginInstanceChild* aActor, NPError* rv)
MOZ_OVERRIDE;
virtual bool RecvAsyncNPP_New(PPluginInstanceChild* aActor) MOZ_OVERRIDE;
virtual PPluginModuleChild*
AllocPPluginModuleChild(mozilla::ipc::Transport* aTransport,
@ -87,19 +91,19 @@ protected:
AllocPPluginInstanceChild(const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv) MOZ_OVERRIDE;
const InfallibleTArray<nsCString>& aValues)
MOZ_OVERRIDE;
virtual bool
DeallocPPluginInstanceChild(PPluginInstanceChild* aActor) MOZ_OVERRIDE;
virtual bool
AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv) MOZ_OVERRIDE;
RecvPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
MOZ_OVERRIDE;
virtual bool
AnswerNP_Shutdown(NPError *rv) MOZ_OVERRIDE;
@ -286,6 +290,7 @@ public:
const PluginSettings& Settings() const { return mCachedSettings; }
private:
NPError DoNP_Initialize(const PluginSettings& aSettings);
void AddQuirk(PluginQuirks quirk) {
if (mQuirks == QUIRKS_NOT_INITIALIZED)
mQuirks = 0;