Backed out 15 changesets (bug 1070755, bug 998863) for e10s bustage

CLOSED TREE

Backed out changeset 076d1d47d601 (bug 1070755)
Backed out changeset 43819af59ca5 (bug 998863)
Backed out changeset 5f587697ae63 (bug 998863)
Backed out changeset e2cf239e8572 (bug 998863)
Backed out changeset fe21b6b789ce (bug 998863)
Backed out changeset 404f59f86edc (bug 998863)
Backed out changeset 5dd57abaf2b0 (bug 998863)
Backed out changeset 6c1f006a03bc (bug 998863)
Backed out changeset 9e69875e3667 (bug 998863)
Backed out changeset c6b68f8f72ba (bug 998863)
Backed out changeset 713799a7afe4 (bug 998863)
Backed out changeset 4244d662787c (bug 998863)
Backed out changeset ba058cc7a1b2 (bug 998863)
Backed out changeset dabc69b0b09a (bug 998863)
Backed out changeset 18dad6d2e7cc (bug 998863)
This commit is contained in:
Phil Ringnalda 2014-12-24 18:28:45 -08:00
Родитель 25fe9e6ae9
Коммит 0c888c27eb
46 изменённых файлов: 410 добавлений и 2789 удалений

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

@ -951,7 +951,7 @@ mozilla::plugins::PPluginModuleParent*
ContentChild::AllocPPluginModuleParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess)
{
return plugins::PluginModuleContentParent::Initialize(aTransport, aOtherProcess);
return plugins::PluginModuleContentParent::Create(aTransport, aOtherProcess);
}
PContentBridgeChild*
@ -2470,21 +2470,6 @@ ContentChild::RecvGetProfile(nsCString* aProfile)
return true;
}
bool
ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId, const bool& aResult)
{
plugins::PluginModuleContentParent::OnLoadPluginResult(aPluginId, aResult);
return true;
}
bool
ContentChild::RecvAssociatePluginId(const uint32_t& aPluginId,
const base::ProcessId& aProcessId)
{
plugins::PluginModuleContentParent::AssociatePluginId(aPluginId, aProcessId);
return true;
}
PBrowserOrId
ContentChild::GetBrowserOrId(TabChild* aTabChild)
{

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

@ -360,11 +360,6 @@ public:
virtual bool RecvOnAppThemeChanged() MOZ_OVERRIDE;
virtual bool RecvAssociatePluginId(const uint32_t& aPluginId,
const base::ProcessId& aProcessId) MOZ_OVERRIDE;
virtual bool RecvLoadPluginResult(const uint32_t& aPluginId,
const bool& aResult) MOZ_OVERRIDE;
virtual bool RecvStartProfiler(const uint32_t& aEntries,
const double& aInterval,
const nsTArray<nsCString>& aFeatures,

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

@ -59,7 +59,6 @@ using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h";
using struct ResourceMapping from "mozilla/chrome/RegistryMessageUtils.h";
using struct OverrideMapping from "mozilla/chrome/RegistryMessageUtils.h";
using base::ChildPrivileges from "base/process_util.h";
using base::ProcessId from "base/process.h";
using struct IPC::Permission from "mozilla/net/NeckoMessageUtils.h";
using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
@ -516,19 +515,6 @@ child:
*/
OnAppThemeChanged();
/**
* Called during plugin initialization to map a plugin id to a child process
* id.
*/
async AssociatePluginId(uint32_t aPluginId, ProcessId aProcessId);
/**
* This call is used by async plugin initialization to notify the
* PluginModuleContentParent that the PluginModuleChromeParent's async
* init has completed.
*/
async LoadPluginResult(uint32_t aPluginId, bool aResult);
/**
* Control the Gecko Profiler in the child process.
*/

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

@ -28,10 +28,7 @@
#include "js/HashTable.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/plugins/PluginAsyncSurrogate.h"
using mozilla::plugins::AsyncNPObject;
using mozilla::plugins::PluginAsyncSurrogate;
#define NPRUNTIME_JSCLASS_NAME "NPObject JS wrapper class"
@ -97,24 +94,10 @@ static nsTArray<NPObject*>* sDelayedReleases;
namespace {
inline void
CastNPObject(NPObject *aObj, PluginScriptableObjectParent*& aActor,
PluginAsyncSurrogate*& aSurrogate)
{
aActor = nullptr;
aSurrogate = nullptr;
if (aObj->_class == PluginScriptableObjectParent::GetClass()) {
aActor = static_cast<ParentNPObject*>(aObj)->parent;
} else if (aObj->_class == PluginAsyncSurrogate::GetClass()) {
aSurrogate = static_cast<AsyncNPObject*>(aObj)->mSurrogate;
}
}
inline bool
NPObjectIsOutOfProcessProxy(NPObject *obj)
{
return obj->_class == PluginScriptableObjectParent::GetClass() ||
obj->_class == PluginAsyncSurrogate::GetClass();
return obj->_class == PluginScriptableObjectParent::GetClass();
}
} // anonymous namespace
@ -1406,23 +1389,15 @@ NPObjWrapper_GetProperty(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<js
NPIdentifier identifier = JSIdToNPIdentifier(id);
if (NPObjectIsOutOfProcessProxy(npobj)) {
PluginScriptableObjectParent* actor = nullptr;
PluginAsyncSurrogate* surrogate = nullptr;
CastNPObject(npobj, actor, surrogate);
PluginScriptableObjectParent* actor =
static_cast<ParentNPObject*>(npobj)->parent;
// actor and surrogate may be null if the plugin crashed.
if (!actor && !surrogate)
// actor may be null if the plugin crashed.
if (!actor)
return false;
bool success = false;
if (surrogate) {
success = surrogate->GetPropertyHelper(npobj, identifier, &hasProperty,
&hasMethod, &npv);
} else if (actor) {
success = actor->GetPropertyHelper(identifier, &hasProperty, &hasMethod,
&npv);
}
bool success = actor->GetPropertyHelper(identifier, &hasProperty,
&hasMethod, &npv);
if (!ReportExceptionIfPending(cx)) {
if (success)
_releasevariantvalue(&npv);
@ -2278,35 +2253,3 @@ NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
"NPObject Member => npobjWrapper");
}
}
// static
bool
nsJSObjWrapper::HasOwnProperty(NPObject *npobj, NPIdentifier npid)
{
NPP npp = NPPStack::Peek();
dom::AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetGlobalObject(npp)))) {
return false;
}
JSContext *cx = jsapi.cx();
if (!npobj) {
ThrowJSException(cx,
"Null npobj in nsJSObjWrapper::NP_HasOwnProperty!");
return false;
}
nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
bool found, ok = false;
AutoJSExceptionReporter reporter(cx);
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
JSAutoCompartment ac(cx, jsobj);
NS_ASSERTION(NPIdentifierIsInt(npid) || NPIdentifierIsString(npid),
"id must be either string or int!\n");
JS::Rooted<jsid> id(cx, NPIdentifierToJSId(npid));
ok = ::JS_AlreadyHasOwnPropertyById(cx, jsobj, id, &found);
return ok && found;
}

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

@ -44,7 +44,6 @@ public:
static NPObject *GetNewOrUsed(NPP npp, JSContext *cx,
JS::Handle<JSObject*> obj);
static bool HasOwnProperty(NPObject* npobj, NPIdentifier npid);
protected:
explicit nsJSObjWrapper(NPP npp);

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

@ -523,7 +523,7 @@ nsNPAPIPluginInstance::Start()
return NS_ERROR_FAILURE;
}
return newResult;
return NS_OK;
}
nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window)

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

@ -331,32 +331,20 @@ nsNPAPIPluginStreamListener::OnStartBinding(nsPluginStreamListenerPeer* streamPe
if (error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
if (streamType == nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN) {
SuspendRequest();
} else if (!SetStreamType(streamType, false)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
bool
nsNPAPIPluginStreamListener::SetStreamType(uint16_t aType, bool aNeedsResume)
{
switch(aType)
switch(streamType)
{
case NP_NORMAL:
mStreamType = NP_NORMAL;
mStreamType = NP_NORMAL;
break;
case NP_ASFILEONLY:
mStreamType = NP_ASFILEONLY;
mStreamType = NP_ASFILEONLY;
break;
case NP_ASFILE:
mStreamType = NP_ASFILE;
mStreamType = NP_ASFILE;
break;
case NP_SEEK:
mStreamType = NP_SEEK;
mStreamType = NP_SEEK;
// Seekable streams should continue to exist even after OnStopRequest
// is fired, so we AddRef ourself an extra time and Release when the
// plugin calls NPN_DestroyStream (CleanUpStream). If the plugin never
@ -365,16 +353,11 @@ nsNPAPIPluginStreamListener::SetStreamType(uint16_t aType, bool aNeedsResume)
NS_ADDREF_THIS();
break;
default:
return false;
return NS_ERROR_FAILURE;
}
mStreamStarted = true;
if (aNeedsResume) {
if (mStreamListenerPeer) {
mStreamListenerPeer->OnStreamTypeSet(mStreamType);
}
ResumeRequest();
}
return true;
return NS_OK;
}
void
@ -386,20 +369,18 @@ nsNPAPIPluginStreamListener::SuspendRequest()
nsresult rv = StartDataPump();
if (NS_FAILED(rv))
return;
mIsSuspended = true;
if (mStreamListenerPeer) {
mStreamListenerPeer->SuspendRequests();
mStreamListenerPeer->SuspendRequests();
}
}
void
nsNPAPIPluginStreamListener::ResumeRequest()
{
if (mStreamListenerPeer) {
mStreamListenerPeer->ResumeRequests();
}
mStreamListenerPeer->ResumeRequests();
mIsSuspended = false;
}
@ -409,7 +390,7 @@ nsNPAPIPluginStreamListener::StartDataPump()
nsresult rv;
mDataPumpTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Start pumping data to the plugin every 100ms until it obeys and
// eats the data.
return mDataPumpTimer->InitWithCallback(this, 100,

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

@ -83,7 +83,6 @@ public:
nsresult OnStopBinding(nsPluginStreamListenerPeer* streamPeer,
nsresult status);
nsresult GetStreamType(int32_t *result);
bool SetStreamType(uint16_t aType, bool aNeedsResume = true);
bool IsStarted();
nsresult CleanUpStream(NPReason reason);

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

@ -50,7 +50,6 @@
#include "nsPluginStreamListenerPeer.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/plugins/PluginAsyncSurrogate.h"
#include "mozilla/plugins/PluginBridge.h"
#include "mozilla/plugins/PluginTypes.h"
#include "mozilla/Preferences.h"
@ -111,7 +110,6 @@
using namespace mozilla;
using mozilla::TimeStamp;
using mozilla::plugins::PluginTag;
using mozilla::plugins::PluginAsyncSurrogate;
// Null out a strong ref to a linked list iteratively to avoid
// exhausting the stack (bug 486349).
@ -832,7 +830,6 @@ nsPluginHost::InstantiatePluginInstance(const char *aMimeType, nsIURI* aURL,
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
const bool isAsyncInit = (rv == NS_PLUGIN_INIT_PENDING);
nsRefPtr<nsNPAPIPluginInstance> instance;
rv = instanceOwner->GetInstance(getter_AddRefs(instance));
@ -840,9 +837,11 @@ nsPluginHost::InstantiatePluginInstance(const char *aMimeType, nsIURI* aURL,
return rv;
}
// Async init plugins will initiate their own widget creation.
if (!isAsyncInit && instance) {
CreateWidget(instanceOwner);
if (instance) {
instanceOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
instanceOwner->CallSetWindow();
}
// At this point we consider instantiation to be successful. Do not return an error.
@ -3328,14 +3327,6 @@ nsresult nsPluginHost::NewPluginStreamListener(nsIURI* aURI,
return NS_OK;
}
void nsPluginHost::CreateWidget(nsPluginInstanceOwner* aOwner)
{
aOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
aOwner->CallSetWindow();
}
NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject,
const char *aTopic,
const char16_t *someData)
@ -3963,12 +3954,6 @@ PluginDestructionGuard::PluginDestructionGuard(nsNPAPIPluginInstance *aInstance)
Init();
}
PluginDestructionGuard::PluginDestructionGuard(PluginAsyncSurrogate *aSurrogate)
: mInstance(static_cast<nsNPAPIPluginInstance*>(aSurrogate->GetNPP()->ndata))
{
InitAsync();
}
PluginDestructionGuard::PluginDestructionGuard(NPP npp)
: mInstance(npp ? static_cast<nsNPAPIPluginInstance*>(npp->ndata) : nullptr)
{

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

@ -30,12 +30,6 @@
#include "nsCRT.h"
#include "mozilla/plugins/PluginTypes.h"
namespace mozilla {
namespace plugins {
class PluginAsyncSurrogate;
} // namespace mozilla
} // namespace plugins
class nsNPAPIPlugin;
class nsIComponentManager;
class nsIFile;
@ -209,8 +203,6 @@ public:
nsNPAPIPluginInstance* aInstance,
nsIStreamListener **aStreamListener);
void CreateWidget(nsPluginInstanceOwner* aOwner);
private:
friend class nsPluginUnloadRunnable;
@ -341,11 +333,11 @@ private:
static nsPluginHost* sInst;
};
class PluginDestructionGuard : protected PRCList
class MOZ_STACK_CLASS PluginDestructionGuard : protected PRCList
{
public:
explicit PluginDestructionGuard(nsNPAPIPluginInstance *aInstance);
explicit PluginDestructionGuard(mozilla::plugins::PluginAsyncSurrogate *aSurrogate);
explicit PluginDestructionGuard(NPP npp);
~PluginDestructionGuard();
@ -363,18 +355,6 @@ protected:
PR_INSERT_BEFORE(this, &sListHead);
}
void InitAsync()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread");
mDelayedDestroy = false;
PR_INIT_CLIST(this);
// Instances with active surrogates must be inserted *after* sListHead so
// that they appear to be at the bottom of the stack
PR_INSERT_AFTER(this, &sListHead);
}
nsRefPtr<nsNPAPIPluginInstance> mInstance;
bool mDelayedDestroy;

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

@ -1452,28 +1452,6 @@ void nsPluginInstanceOwner::ExitFullScreen(jobject view) {
#endif
void
nsPluginInstanceOwner::NotifyHostAsyncInitFailed()
{
nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
content->StopPluginInstance();
}
void
nsPluginInstanceOwner::NotifyHostCreateWidget()
{
mPluginHost->CreateWidget(this);
#ifdef XP_MACOSX
FixUpPluginWindow(ePluginPaintEnable);
#else
if (mPluginFrame) {
mPluginFrame->InvalidateFrame();
} else {
CallSetWindow();
}
#endif
}
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
{
#ifdef MOZ_WIDGET_ANDROID
@ -3191,10 +3169,6 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive)
NS_IMETHODIMP
nsPluginInstanceOwner::CallSetWindow()
{
if (!mWidgetCreationComplete) {
// No widget yet, we can't run this code
return NS_OK;
}
if (mPluginFrame) {
mPluginFrame->CallSetWindow(false);
} else if (mInstance) {

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

@ -255,10 +255,7 @@ public:
// Called from AndroidJNI when we removed the fullscreen view.
static void ExitFullScreen(jobject view);
#endif
void NotifyHostAsyncInitFailed();
void NotifyHostCreateWidget();
private:
virtual ~nsPluginInstanceOwner();

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

@ -266,7 +266,6 @@ nsPluginStreamListenerPeer::nsPluginStreamListenerPeer()
mHaveFiredOnStartRequest = false;
mDataForwardToRequest = nullptr;
mUseLocalCache = false;
mSeekable = false;
mModified = 0;
mStreamOffset = 0;
@ -534,9 +533,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
// Set up the stream listener...
rv = SetUpStreamListener(request, aURL);
if (NS_FAILED(rv)) {
return rv;
}
if (NS_FAILED(rv)) return rv;
return rv;
}
@ -1049,6 +1046,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
mPStreamListener->SetStreamListenerPeer(this);
bool useLocalCache = false;
// get httpChannel to retrieve some info we need for nsIPluginStreamInfo setup
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
@ -1104,7 +1103,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
nsAutoCString contentEncoding;
if (NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
contentEncoding))) {
mUseLocalCache = true;
useLocalCache = true;
} else {
// set seekability (seekable if the stream has a known length and if the
// http server accepts byte ranges).
@ -1133,9 +1132,6 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
}
}
MOZ_ASSERT(!mRequest);
mRequest = request;
rv = mPStreamListener->OnStartBinding(this);
mStartBinding = true;
@ -1143,37 +1139,23 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
if (NS_FAILED(rv))
return rv;
int32_t streamType = NP_NORMAL;
mPStreamListener->GetStreamType(&streamType);
mPStreamListener->GetStreamType(&mStreamType);
if (streamType != STREAM_TYPE_UNKNOWN) {
OnStreamTypeSet(streamType);
if (!useLocalCache && mStreamType >= NP_ASFILE) {
// check it out if this is not a file channel.
nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(request);
if (!fileChannel) {
useLocalCache = true;
}
}
if (useLocalCache) {
SetupPluginCacheFile(channel);
}
return NS_OK;
}
void
nsPluginStreamListenerPeer::OnStreamTypeSet(const int32_t aStreamType)
{
MOZ_ASSERT(mRequest);
mStreamType = aStreamType;
if (!mUseLocalCache && mStreamType >= NP_ASFILE) {
// check it out if this is not a file channel.
nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(mRequest);
if (!fileChannel) {
mUseLocalCache = true;
}
}
if (mUseLocalCache) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
SetupPluginCacheFile(channel);
}
}
const int32_t nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN = UINT16_MAX;
nsresult
nsPluginStreamListenerPeer::OnFileAvailable(nsIFile* aFile)
{

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

@ -128,11 +128,6 @@ public:
requestsCopy[i]->Resume();
}
// Called by nsNPAPIPluginStreamListener
void OnStreamTypeSet(const int32_t aStreamType);
static const int32_t STREAM_TYPE_UNKNOWN;
private:
nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL);
nsresult SetupPluginCacheFile(nsIChannel* channel);
@ -164,8 +159,6 @@ private:
nsDataHashtable<nsUint32HashKey, uint32_t>* mDataForwardToRequest;
nsCString mContentType;
bool mUseLocalCache;
nsCOMPtr<nsIRequest> mRequest;
bool mSeekable;
uint32_t mModified;
nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;

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

@ -17,7 +17,11 @@ BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
const uint32_t& length,
const uint32_t& lastmodified,
StreamNotifyChild* notifyData,
const nsCString& headers)
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype)
: mInstance(instance)
, mStreamStatus(kStreamOpen)
, mDestroyPending(NOT_DESTROYED)
@ -30,9 +34,9 @@ BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
, mStreamNotify(notifyData)
, mDeliveryTracker(MOZ_THIS_IN_INITIALIZER_LIST())
{
PLUGIN_LOG_DEBUG(("%s (%s, %i, %i, %p, %s)", FULLFUNCTION,
PLUGIN_LOG_DEBUG(("%s (%s, %i, %i, %p, %s, %s)", FULLFUNCTION,
url.get(), length, lastmodified, (void*) notifyData,
headers.get()));
headers.get(), mimeType.get()));
AssertPluginThread();
@ -42,10 +46,8 @@ BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
mStream.end = length;
mStream.lastmodified = lastmodified;
mStream.headers = NullableStringGet(mHeaders);
if (notifyData) {
if (notifyData)
mStream.notifyData = notifyData->mClosure;
notifyData->SetAssociatedStream(this);
}
}
NPError
@ -66,6 +68,9 @@ BrowserStreamChild::StreamConstructed(
}
else {
mState = ALIVE;
if (mStreamNotify)
mStreamNotify->SetAssociatedStream(this);
}
return rv;

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

@ -23,7 +23,11 @@ public:
const uint32_t& length,
const uint32_t& lastmodified,
StreamNotifyChild* notifyData,
const nsCString& headers);
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype);
virtual ~BrowserStreamChild();
virtual bool IsBrowserStream() MOZ_OVERRIDE { return true; }

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

@ -5,7 +5,6 @@
#include "BrowserStreamParent.h"
#include "PluginAsyncSurrogate.h"
#include "PluginInstanceParent.h"
#include "nsNPAPIPlugin.h"
@ -22,15 +21,9 @@ BrowserStreamParent::BrowserStreamParent(PluginInstanceParent* npp,
NPStream* stream)
: mNPP(npp)
, mStream(stream)
, mDeferredDestroyReason(NPRES_DONE)
, mState(INITIALIZING)
, mState(ALIVE)
{
mStream->pdata = static_cast<AStream*>(this);
nsNPAPIStreamWrapper* wrapper =
reinterpret_cast<nsNPAPIStreamWrapper*>(mStream->ndata);
if (wrapper) {
mStreamListener = wrapper->GetStreamListener();
}
}
BrowserStreamParent::~BrowserStreamParent()
@ -43,43 +36,6 @@ BrowserStreamParent::ActorDestroy(ActorDestroyReason aWhy)
// Implement me! Bug 1005159
}
bool
BrowserStreamParent::RecvAsyncNPP_NewStreamResult(const NPError& rv,
const uint16_t& stype)
{
PLUGIN_LOG_DEBUG_FUNCTION;
PluginAsyncSurrogate* surrogate = mNPP->GetAsyncSurrogate();
MOZ_ASSERT(surrogate);
surrogate->AsyncCallArriving();
nsRefPtr<nsNPAPIPluginStreamListener> streamListener = mStreamListener.forget();
if (mState == DEFERRING_DESTROY) {
// We've been asked to destroy ourselves before init was complete.
mState = DYING;
unused << SendNPP_DestroyStream(mDeferredDestroyReason);
return true;
}
NPError error = rv;
if (error == NPERR_NO_ERROR) {
if (!streamListener) {
return false;
}
if (streamListener->SetStreamType(stype)) {
mState = ALIVE;
} else {
error = NPERR_GENERIC_ERROR;
}
}
if (error != NPERR_NO_ERROR) {
// We need to clean up the stream
parent::_destroystream(mNPP->GetNPP(), mStream, NPRES_DONE);
unused << PBrowserStreamParent::Send__delete__(this);
}
return true;
}
bool
BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
NPError* result)
@ -87,11 +43,6 @@ BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
PLUGIN_LOG_DEBUG_FUNCTION;
switch (mState) {
case INITIALIZING:
NS_ERROR("Requesting a read before initialization has completed");
*result = NPERR_GENERIC_ERROR;
return false;
case ALIVE:
break;
@ -144,16 +95,9 @@ BrowserStreamParent::RecvNPN_DestroyStream(const NPReason& reason)
void
BrowserStreamParent::NPP_DestroyStream(NPReason reason)
{
NS_ASSERTION(ALIVE == mState || INITIALIZING == mState,
"NPP_DestroyStream called twice?");
bool stillInitializing = INITIALIZING == mState;
if (stillInitializing) {
mState = DEFERRING_DESTROY;
mDeferredDestroyReason = reason;
} else {
mState = DYING;
unused << SendNPP_DestroyStream(reason);
}
NS_ASSERTION(ALIVE == mState, "NPP_DestroyStream called twice?");
mState = DYING;
unused << SendNPP_DestroyStream(reason);
}
bool
@ -173,9 +117,6 @@ BrowserStreamParent::RecvStreamDestroyed()
int32_t
BrowserStreamParent::WriteReady()
{
if (mState == INITIALIZING) {
return 0;
}
return kSendDataChunk;
}

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

@ -8,8 +8,6 @@
#include "mozilla/plugins/PBrowserStreamParent.h"
#include "mozilla/plugins/AStream.h"
#include "nsNPAPIPluginStreamListener.h"
#include "nsPluginStreamListenerPeer.h"
namespace mozilla {
namespace plugins {
@ -30,10 +28,6 @@ public:
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
virtual bool RecvAsyncNPP_NewStreamResult(
const NPError& rv,
const uint16_t& stype) MOZ_OVERRIDE;
virtual bool AnswerNPN_RequestRead(const IPCByteRanges& ranges,
NPError* result) MOZ_OVERRIDE;
@ -47,25 +41,14 @@ public:
void NPP_DestroyStream(NPReason reason);
void SetAlive()
{
if (mState == INITIALIZING) {
mState = ALIVE;
}
}
private:
using PBrowserStreamParent::SendNPP_DestroyStream;
PluginInstanceParent* mNPP;
NPStream* mStream;
nsCOMPtr<nsISupports> mStreamPeer;
nsRefPtr<nsNPAPIPluginStreamListener> mStreamListener;
NPReason mDeferredDestroyReason;
enum {
INITIALIZING,
DEFERRING_DESTROY,
ALIVE,
DYING,
DELETING

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

@ -36,7 +36,6 @@ child:
async __delete__();
parent:
async AsyncNPP_NewStreamResult(NPError rv, uint16_t stype);
intr NPN_RequestRead(IPCByteRanges ranges)
returns (NPError result);
async NPN_DestroyStream(NPReason reason);

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

@ -207,29 +207,21 @@ parent:
// them to use the plugin.
sync NegotiatedCarbon();
// Notifies the parent of its NPP_New result code.
async AsyncNPP_NewResult(NPError aResult);
both:
async PPluginScriptableObject();
child:
/* NPP_NewStream */
async PBrowserStream(nsCString url,
uint32_t length,
uint32_t lastmodified,
nullable PStreamNotify notifyData,
nsCString headers);
// Implements the legacy (synchronous) version of NPP_NewStream for when
// async plugin init is preffed off.
intr NPP_NewStream(PBrowserStream actor, nsCString mimeType, bool seekable)
intr PBrowserStream(nsCString url,
uint32_t length,
uint32_t lastmodified,
nullable PStreamNotify notifyData,
nsCString headers,
nsCString mimeType,
bool seekable)
returns (NPError rv,
uint16_t stype);
// Implements the async plugin init version of NPP_NewStream.
async AsyncNPP_NewStream(PBrowserStream actor, nsCString mimeType, bool seekable);
parent:
/* NPN_NewStream */
intr PPluginStream(nsCString mimeType,

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

@ -54,21 +54,12 @@ child:
intr NP_Initialize(PluginSettings settings)
returns (NPError rv);
async AsyncNP_Initialize(PluginSettings settings);
async PPluginInstance(nsCString aMimeType,
uint16_t aMode,
nsCString[] aNames,
nsCString[] aValues);
// Implements the synchronous version of NPP_New for when async plugin init
// is preffed off.
intr SyncNPP_New(PPluginInstance aActor)
intr PPluginInstance(nsCString aMimeType,
uint16_t aMode,
nsCString[] aNames,
nsCString[] aValues)
returns (NPError rv);
// Implements the async plugin init version of NPP_New.
async AsyncNPP_New(PPluginInstance aActor);
intr NP_Shutdown()
returns (NPError rv);
@ -98,15 +89,12 @@ child:
async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures,
nsCString[] aThreadNameFilters);
async StopProfiler();
intr GetProfile()
returns (nsCString aProfile);
async SettingChanged(PluginSettings settings);
parent:
async NP_InitializeResult(NPError aError);
/**
* This message is only used on X11 platforms.
*

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

@ -1,882 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "PluginAsyncSurrogate.h"
#include "base/message_loop.h"
#include "base/message_pump_default.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/plugins/PluginModuleParent.h"
#include "mozilla/plugins/PluginScriptableObjectParent.h"
#include "mozilla/Telemetry.h"
#include "nsJSNPRuntime.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginInstance.h"
#include "nsNPAPIPluginStreamListener.h"
#include "nsPluginInstanceOwner.h"
#include "nsPluginStreamListenerPeer.h"
#include "npruntime.h"
#include "nsThreadUtils.h"
#include "PluginMessageUtils.h"
namespace mozilla {
namespace plugins {
AsyncNPObject::AsyncNPObject(PluginAsyncSurrogate* aSurrogate)
: NPObject()
, mSurrogate(aSurrogate)
, mRealObject(nullptr)
{
}
AsyncNPObject::~AsyncNPObject()
{
if (mRealObject) {
parent::_releaseobject(mRealObject);
mRealObject = nullptr;
}
}
NPObject*
AsyncNPObject::GetRealObject()
{
if (mRealObject) {
return mRealObject;
}
PluginInstanceParent* instance = PluginInstanceParent::Cast(mSurrogate->GetNPP());
if (!instance) {
return nullptr;
}
NPError err = instance->NPP_GetValue(NPPVpluginScriptableNPObject,
&mRealObject);
if (err != NPERR_NO_ERROR) {
return nullptr;
}
return mRealObject;
}
class MOZ_STACK_CLASS RecursionGuard
{
public:
RecursionGuard()
: mIsRecursive(sHasEntered)
{
if (!mIsRecursive) {
sHasEntered = true;
}
}
~RecursionGuard()
{
if (!mIsRecursive) {
sHasEntered = false;
}
}
inline bool
IsRecursive()
{
return mIsRecursive;
}
private:
bool mIsRecursive;
static bool sHasEntered;
};
bool RecursionGuard::sHasEntered = false;
PluginAsyncSurrogate::PluginAsyncSurrogate(PluginModuleParent* aParent)
: mParent(aParent)
, mInstance(nullptr)
, mMode(0)
, mWindow(nullptr)
, mAcceptCalls(false)
, mInstantiated(false)
, mAsyncSetWindow(false)
, mInitCancelled(false)
, mAsyncCallsInFlight(0)
{
MOZ_ASSERT(aParent);
}
PluginAsyncSurrogate::~PluginAsyncSurrogate()
{
}
bool
PluginAsyncSurrogate::Init(NPMIMEType aPluginType, NPP aInstance, uint16_t aMode,
int16_t aArgc, char* aArgn[], char* aArgv[])
{
mMimeType = aPluginType;
mInstance = aInstance;
mMode = aMode;
for (int i = 0; i < aArgc; ++i) {
mNames.AppendElement(NullableString(aArgn[i]));
mValues.AppendElement(NullableString(aArgv[i]));
}
return true;
}
/* static */ bool
PluginAsyncSurrogate::Create(PluginModuleParent* aParent, NPMIMEType aPluginType,
NPP aInstance, uint16_t aMode, int16_t aArgc,
char* aArgn[], char* aArgv[])
{
nsRefPtr<PluginAsyncSurrogate> surrogate(new PluginAsyncSurrogate(aParent));
if (!surrogate->Init(aPluginType, aInstance, aMode, aArgc, aArgn, aArgv)) {
return false;
}
PluginAsyncSurrogate* rawSurrogate = nullptr;
surrogate.forget(&rawSurrogate);
aInstance->pdata = static_cast<PluginDataResolver*>(rawSurrogate);
return true;
}
/* static */ PluginAsyncSurrogate*
PluginAsyncSurrogate::Cast(NPP aInstance)
{
MOZ_ASSERT(aInstance);
PluginDataResolver* resolver =
reinterpret_cast<PluginDataResolver*>(aInstance->pdata);
if (!resolver) {
return nullptr;
}
return resolver->GetAsyncSurrogate();
}
nsresult
PluginAsyncSurrogate::NPP_New(NPError* aError)
{
nsresult rv = mParent->NPP_NewInternal(mMimeType.BeginWriting(), mInstance,
mMode, mNames, mValues, nullptr,
aError);
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
void
PluginAsyncSurrogate::NP_GetEntryPoints(NPPluginFuncs* aFuncs)
{
aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
aFuncs->destroy = &NPP_Destroy;
aFuncs->getvalue = &NPP_GetValue;
aFuncs->setvalue = &NPP_SetValue;
aFuncs->newstream = &NPP_NewStream;
aFuncs->setwindow = &NPP_SetWindow;
aFuncs->writeready = &NPP_WriteReady;
aFuncs->event = &NPP_HandleEvent;
// We need to set these so that content code doesn't make assumptions
// about these operations not being supported
aFuncs->write = &PluginModuleParent::NPP_Write;
aFuncs->asfile = &PluginModuleParent::NPP_StreamAsFile;
aFuncs->destroystream = &PluginModuleParent::NPP_DestroyStream;
}
NPError
PluginAsyncSurrogate::NPP_Destroy(NPSavedData** aSave)
{
if (!WaitForInit()) {
return NPERR_GENERIC_ERROR;
}
return PluginModuleParent::NPP_Destroy(mInstance, aSave);
}
NPError
PluginAsyncSurrogate::NPP_GetValue(NPPVariable aVariable, void* aRetval)
{
if (aVariable != NPPVpluginScriptableNPObject) {
if (!WaitForInit()) {
return NPERR_GENERIC_ERROR;
}
PluginInstanceParent* instance = PluginInstanceParent::Cast(mInstance);
MOZ_ASSERT(instance);
return instance->NPP_GetValue(aVariable, aRetval);
}
NPObject* npobject = parent::_createobject(mInstance,
const_cast<NPClass*>(GetClass()));
MOZ_ASSERT(npobject);
MOZ_ASSERT(npobject->_class == GetClass());
MOZ_ASSERT(npobject->referenceCount == 1);
*(NPObject**)aRetval = npobject;
return npobject ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
}
NPError
PluginAsyncSurrogate::NPP_SetValue(NPNVariable aVariable, void* aValue)
{
if (!WaitForInit()) {
return NPERR_GENERIC_ERROR;
}
return PluginModuleParent::NPP_SetValue(mInstance, aVariable, aValue);
}
NPError
PluginAsyncSurrogate::NPP_NewStream(NPMIMEType aType, NPStream* aStream,
NPBool aSeekable, uint16_t* aStype)
{
mPendingNewStreamCalls.AppendElement(PendingNewStreamCall(aType, aStream,
aSeekable));
if (aStype) {
*aStype = nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN;
}
return NPERR_NO_ERROR;
}
NPError
PluginAsyncSurrogate::NPP_SetWindow(NPWindow* aWindow)
{
mWindow = aWindow;
mAsyncSetWindow = false;
return NPERR_NO_ERROR;
}
nsresult
PluginAsyncSurrogate::AsyncSetWindow(NPWindow* aWindow)
{
mWindow = aWindow;
mAsyncSetWindow = true;
return NS_OK;
}
void
PluginAsyncSurrogate::NPP_Print(NPPrint* aPrintInfo)
{
// Do nothing, we've got nothing to print right now
}
int16_t
PluginAsyncSurrogate::NPP_HandleEvent(void* event)
{
// Drop the event -- the plugin isn't around to handle it
return false;
}
int32_t
PluginAsyncSurrogate::NPP_WriteReady(NPStream* aStream)
{
// We'll tell the browser to retry in a bit. Eventually NPP_WriteReady
// will resolve to the plugin's NPP_WriteReady and this should all just work.
return 0;
}
/* static */ NPError
PluginAsyncSurrogate::NPP_Destroy(NPP aInstance, NPSavedData** aSave)
{
PluginAsyncSurrogate* rawSurrogate = Cast(aInstance);
MOZ_ASSERT(rawSurrogate);
PluginModuleParent* module = rawSurrogate->GetParent();
if (module && !module->IsInitialized()) {
// Take ownership of pdata's surrogate since we're going to release it
nsRefPtr<PluginAsyncSurrogate> surrogate(dont_AddRef(rawSurrogate));
aInstance->pdata = nullptr;
// We haven't actually called NPP_New yet, so we should remove the
// surrogate for this instance.
bool removeOk = module->RemovePendingSurrogate(surrogate);
MOZ_ASSERT(removeOk);
if (!removeOk) {
return NPERR_GENERIC_ERROR;
}
surrogate->mInitCancelled = true;
return NPERR_NO_ERROR;
}
return rawSurrogate->NPP_Destroy(aSave);
}
/* static */ NPError
PluginAsyncSurrogate::NPP_GetValue(NPP aInstance, NPPVariable aVariable,
void* aRetval)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
return surrogate->NPP_GetValue(aVariable, aRetval);
}
/* static */ NPError
PluginAsyncSurrogate::NPP_SetValue(NPP aInstance, NPNVariable aVariable,
void* aValue)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
return surrogate->NPP_SetValue(aVariable, aValue);
}
/* static */ NPError
PluginAsyncSurrogate::NPP_NewStream(NPP aInstance, NPMIMEType aType,
NPStream* aStream, NPBool aSeekable,
uint16_t* aStype)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
return surrogate->NPP_NewStream(aType, aStream, aSeekable, aStype);
}
/* static */ NPError
PluginAsyncSurrogate::NPP_SetWindow(NPP aInstance, NPWindow* aWindow)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
return surrogate->NPP_SetWindow(aWindow);
}
/* static */ void
PluginAsyncSurrogate::NPP_Print(NPP aInstance, NPPrint* aPrintInfo)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
surrogate->NPP_Print(aPrintInfo);
}
/* static */ int16_t
PluginAsyncSurrogate::NPP_HandleEvent(NPP aInstance, void* aEvent)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
return surrogate->NPP_HandleEvent(aEvent);
}
/* static */ int32_t
PluginAsyncSurrogate::NPP_WriteReady(NPP aInstance, NPStream* aStream)
{
PluginAsyncSurrogate* surrogate = Cast(aInstance);
MOZ_ASSERT(surrogate);
return surrogate->NPP_WriteReady(aStream);
}
PluginAsyncSurrogate::PendingNewStreamCall::PendingNewStreamCall(
NPMIMEType aType, NPStream* aStream, NPBool aSeekable)
: mType(NullableString(aType))
, mStream(aStream)
, mSeekable(aSeekable)
{
}
/* static */ bool
PluginAsyncSurrogate::SetStreamType(NPStream* aStream, uint16_t aStreamType)
{
nsNPAPIStreamWrapper* wrapper =
reinterpret_cast<nsNPAPIStreamWrapper*>(aStream->ndata);
if (!wrapper) {
return false;
}
nsNPAPIPluginStreamListener* streamListener = wrapper->GetStreamListener();
if (!streamListener) {
return false;
}
return streamListener->SetStreamType(aStreamType);
}
void
PluginAsyncSurrogate::OnInstanceCreated(PluginInstanceParent* aInstance)
{
for (PRUint32 i = 0, len = mPendingNewStreamCalls.Length(); i < len; ++i) {
PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[i];
uint16_t streamType = NP_NORMAL;
NPError curError = aInstance->NPP_NewStream(
const_cast<char*>(NullableStringGet(curPendingCall.mType)),
curPendingCall.mStream, curPendingCall.mSeekable,
&streamType);
if (curError != NPERR_NO_ERROR) {
// If we failed here then the send failed and we need to clean up
parent::_destroystream(mInstance, curPendingCall.mStream, NPRES_DONE);
}
}
mPendingNewStreamCalls.Clear();
mInstantiated = true;
}
/**
* During asynchronous initialization it might be necessary to wait for the
* plugin to complete its initialization. This typically occurs when the result
* of a plugin call depends on the plugin being fully instantiated. For example,
* if some JS calls into the plugin, the call must be executed synchronously to
* preserve correctness.
*
* This function works by pumping the plugin's IPC channel for events until
* initialization has completed.
*/
bool
PluginAsyncSurrogate::WaitForInit()
{
if (mInitCancelled) {
return false;
}
if (mAcceptCalls) {
return true;
}
Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGINASYNCSURROGATE_WAITFORINIT_MS>
timer(mParent->GetHistogramKey());
bool result = false;
MOZ_ASSERT(mParent);
if (mParent->IsChrome()) {
PluginProcessParent* process = static_cast<PluginModuleChromeParent*>(mParent)->Process();
MOZ_ASSERT(process);
process->SetCallRunnableImmediately(true);
if (!process->WaitUntilConnected()) {
return false;
}
}
if (!mParent->WaitForIPCConnection()) {
return false;
}
if (!mParent->IsChrome()) {
// For e10s content processes, we need to spin the content channel until the
// protocol bridging has occurred.
dom::ContentChild* cp = dom::ContentChild::GetSingleton();
mozilla::ipc::MessageChannel* contentChannel = cp->GetIPCChannel();
MOZ_ASSERT(contentChannel);
while (!mParent->mNPInitialized) {
result = contentChannel->WaitForIncomingMessage();
if (!result) {
return result;
}
}
}
mozilla::ipc::MessageChannel* channel = mParent->GetIPCChannel();
MOZ_ASSERT(channel);
while (!mAcceptCalls) {
result = channel->WaitForIncomingMessage();
if (!result) {
break;
}
}
return result;
}
void
PluginAsyncSurrogate::AsyncCallDeparting()
{
++mAsyncCallsInFlight;
if (!mPluginDestructionGuard) {
mPluginDestructionGuard = MakeUnique<PluginDestructionGuard>(this);
}
}
void
PluginAsyncSurrogate::AsyncCallArriving()
{
MOZ_ASSERT(mAsyncCallsInFlight > 0);
if (--mAsyncCallsInFlight == 0) {
mPluginDestructionGuard.reset(nullptr);
}
}
void
PluginAsyncSurrogate::NotifyAsyncInitFailed()
{
// Clean up any pending NewStream requests
for (uint32_t i = 0, len = mPendingNewStreamCalls.Length(); i < len; ++i) {
PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[i];
parent::_destroystream(mInstance, curPendingCall.mStream, NPRES_DONE);
}
mPendingNewStreamCalls.Clear();
nsNPAPIPluginInstance* inst =
static_cast<nsNPAPIPluginInstance*>(mInstance->ndata);
if (!inst) {
return;
}
nsPluginInstanceOwner* owner = inst->GetOwner();
if (!owner) {
return;
}
owner->NotifyHostAsyncInitFailed();
}
// static
NPObject*
PluginAsyncSurrogate::ScriptableAllocate(NPP aInstance, NPClass* aClass)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aClass != GetClass()) {
NS_ERROR("Huh?! Wrong class!");
return nullptr;
}
return new AsyncNPObject(Cast(aInstance));
}
// static
void
PluginAsyncSurrogate::ScriptableInvalidate(NPObject* aObject)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return;
}
realObject->_class->invalidate(realObject);
}
// static
void
PluginAsyncSurrogate::ScriptableDeallocate(NPObject* aObject)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
delete object;
}
// static
bool
PluginAsyncSurrogate::ScriptableHasMethod(NPObject* aObject,
NPIdentifier aName)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
RecursionGuard guard;
if (guard.IsRecursive()) {
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
MOZ_ASSERT(object);
bool checkPluginObject = !object->mSurrogate->mInstantiated &&
!object->mSurrogate->mAcceptCalls;
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
bool result = realObject->_class->hasMethod(realObject, aName);
if (!result && checkPluginObject) {
// We may be calling into this object because properties in the WebIDL
// object hadn't been set yet. Now that we're further along in
// initialization, we should try again.
const NPNetscapeFuncs* npn = object->mSurrogate->mParent->GetNetscapeFuncs();
NPObject* pluginObject = nullptr;
NPError nperror = npn->getvalue(object->mSurrogate->mInstance,
NPNVPluginElementNPObject,
(void*)&pluginObject);
if (nperror == NPERR_NO_ERROR) {
NPPAutoPusher nppPusher(object->mSurrogate->mInstance);
result = pluginObject->_class->hasMethod(pluginObject, aName);
npn->releaseobject(pluginObject);
NPUTF8* idstr = npn->utf8fromidentifier(aName);
npn->memfree(idstr);
}
}
return result;
}
bool
PluginAsyncSurrogate::GetPropertyHelper(NPObject* aObject, NPIdentifier aName,
bool* aHasProperty, bool* aHasMethod,
NPVariant* aResult)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (!aObject) {
return false;
}
RecursionGuard guard;
if (guard.IsRecursive()) {
return false;
}
WaitForInit();
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
NPObject* realObject = object->GetRealObject();
if (realObject->_class != PluginScriptableObjectParent::GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
PluginScriptableObjectParent* actor =
static_cast<ParentNPObject*>(realObject)->parent;
bool success = actor->GetPropertyHelper(aName, aHasProperty, aHasMethod, aResult);
if (!success) {
const NPNetscapeFuncs* npn = mParent->GetNetscapeFuncs();
NPObject* pluginObject = nullptr;
NPError nperror = npn->getvalue(mInstance, NPNVPluginElementNPObject,
(void*)&pluginObject);
if (nperror == NPERR_NO_ERROR) {
NPPAutoPusher nppPusher(mInstance);
bool hasProperty = nsJSObjWrapper::HasOwnProperty(pluginObject, aName);
NPUTF8* idstr = npn->utf8fromidentifier(aName);
npn->memfree(idstr);
bool hasMethod = false;
if (hasProperty) {
hasMethod = pluginObject->_class->hasMethod(pluginObject, aName);
success = pluginObject->_class->getProperty(pluginObject, aName, aResult);
idstr = npn->utf8fromidentifier(aName);
npn->memfree(idstr);
}
*aHasProperty = hasProperty;
*aHasMethod = hasMethod;
npn->releaseobject(pluginObject);
}
}
return success;
}
// static
bool
PluginAsyncSurrogate::ScriptableInvoke(NPObject* aObject,
NPIdentifier aName,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
return realObject->_class->invoke(realObject, aName, aArgs, aArgCount, aResult);
}
// static
bool
PluginAsyncSurrogate::ScriptableInvokeDefault(NPObject* aObject,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
return realObject->_class->invokeDefault(realObject, aArgs, aArgCount, aResult);
}
// static
bool
PluginAsyncSurrogate::ScriptableHasProperty(NPObject* aObject,
NPIdentifier aName)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
RecursionGuard guard;
if (guard.IsRecursive()) {
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
MOZ_ASSERT(object);
bool checkPluginObject = !object->mSurrogate->mInstantiated &&
!object->mSurrogate->mAcceptCalls;
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
bool result = realObject->_class->hasProperty(realObject, aName);
const NPNetscapeFuncs* npn = object->mSurrogate->mParent->GetNetscapeFuncs();
NPUTF8* idstr = npn->utf8fromidentifier(aName);
npn->memfree(idstr);
if (!result && checkPluginObject) {
// We may be calling into this object because properties in the WebIDL
// object hadn't been set yet. Now that we're further along in
// initialization, we should try again.
NPObject* pluginObject = nullptr;
NPError nperror = npn->getvalue(object->mSurrogate->mInstance,
NPNVPluginElementNPObject,
(void*)&pluginObject);
if (nperror == NPERR_NO_ERROR) {
NPPAutoPusher nppPusher(object->mSurrogate->mInstance);
result = nsJSObjWrapper::HasOwnProperty(pluginObject, aName);
npn->releaseobject(pluginObject);
idstr = npn->utf8fromidentifier(aName);
npn->memfree(idstr);
}
}
return result;
}
// static
bool
PluginAsyncSurrogate::ScriptableGetProperty(NPObject* aObject,
NPIdentifier aName,
NPVariant* aResult)
{
PLUGIN_LOG_DEBUG_FUNCTION;
// See GetPropertyHelper below.
NS_NOTREACHED("Shouldn't ever call this directly!");
return false;
}
// static
bool
PluginAsyncSurrogate::ScriptableSetProperty(NPObject* aObject,
NPIdentifier aName,
const NPVariant* aValue)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
return realObject->_class->setProperty(realObject, aName, aValue);
}
// static
bool
PluginAsyncSurrogate::ScriptableRemoveProperty(NPObject* aObject,
NPIdentifier aName)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
return realObject->_class->removeProperty(realObject, aName);
}
// static
bool
PluginAsyncSurrogate::ScriptableEnumerate(NPObject* aObject,
NPIdentifier** aIdentifiers,
uint32_t* aCount)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
return realObject->_class->enumerate(realObject, aIdentifiers, aCount);
}
// static
bool
PluginAsyncSurrogate::ScriptableConstruct(NPObject* aObject,
const NPVariant* aArgs,
uint32_t aArgCount,
NPVariant* aResult)
{
PLUGIN_LOG_DEBUG_FUNCTION;
if (aObject->_class != GetClass()) {
NS_ERROR("Don't know what kind of object this is!");
return false;
}
AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
if (!object->mSurrogate->WaitForInit()) {
return false;
}
NPObject* realObject = object->GetRealObject();
if (!realObject) {
return false;
}
return realObject->_class->construct(realObject, aArgs, aArgCount, aResult);
}
const NPClass PluginAsyncSurrogate::sNPClass = {
NP_CLASS_STRUCT_VERSION,
PluginAsyncSurrogate::ScriptableAllocate,
PluginAsyncSurrogate::ScriptableDeallocate,
PluginAsyncSurrogate::ScriptableInvalidate,
PluginAsyncSurrogate::ScriptableHasMethod,
PluginAsyncSurrogate::ScriptableInvoke,
PluginAsyncSurrogate::ScriptableInvokeDefault,
PluginAsyncSurrogate::ScriptableHasProperty,
PluginAsyncSurrogate::ScriptableGetProperty,
PluginAsyncSurrogate::ScriptableSetProperty,
PluginAsyncSurrogate::ScriptableRemoveProperty,
PluginAsyncSurrogate::ScriptableEnumerate,
PluginAsyncSurrogate::ScriptableConstruct
};
PushSurrogateAcceptCalls::PushSurrogateAcceptCalls(PluginInstanceParent* aInstance)
: mSurrogate(nullptr)
, mPrevAcceptCallsState(false)
{
MOZ_ASSERT(aInstance);
mSurrogate = aInstance->GetAsyncSurrogate();
if (mSurrogate) {
mPrevAcceptCallsState = mSurrogate->SetAcceptingCalls(true);
}
}
PushSurrogateAcceptCalls::~PushSurrogateAcceptCalls()
{
if (mSurrogate) {
mSurrogate->SetAcceptingCalls(mPrevAcceptCallsState);
}
}
} // namespace plugins
} // namespace mozilla

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

@ -1,179 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef dom_plugins_ipc_PluginAsyncSurrogate_h
#define dom_plugins_ipc_PluginAsyncSurrogate_h
#include "mozilla/UniquePtr.h"
#include "npapi.h"
#include "npfunctions.h"
#include "npruntime.h"
#include "nsAutoPtr.h"
#include "nsISupportsImpl.h"
#include "nsPluginHost.h"
#include "nsString.h"
#include "nsTArray.h"
#include "PluginDataResolver.h"
namespace mozilla {
namespace plugins {
class PluginInstanceParent;
class PluginModuleParent;
class PluginAsyncSurrogate : public PluginDataResolver
{
public:
NS_INLINE_DECL_REFCOUNTING(PluginAsyncSurrogate)
bool Init(NPMIMEType aPluginType, NPP aInstance, uint16_t aMode,
int16_t aArgc, char* aArgn[], char* aArgv[]);
nsresult NPP_New(NPError* aError);
NPError NPP_Destroy(NPSavedData** aSave);
NPError NPP_GetValue(NPPVariable aVariable, void* aRetval);
NPError NPP_SetValue(NPNVariable aVariable, void* aValue);
NPError NPP_NewStream(NPMIMEType aType, NPStream* aStream, NPBool aSeekable,
uint16_t* aStype);
NPError NPP_SetWindow(NPWindow* aWindow);
nsresult AsyncSetWindow(NPWindow* aWindow);
void NPP_Print(NPPrint* aPrintInfo);
int16_t NPP_HandleEvent(void* aEvent);
int32_t NPP_WriteReady(NPStream* aStream);
void OnInstanceCreated(PluginInstanceParent* aInstance);
static bool Create(PluginModuleParent* aParent, NPMIMEType aPluginType,
NPP aInstance, uint16_t aMode, int16_t aArgc,
char* aArgn[], char* aArgv[]);
static const NPClass* GetClass() { return &sNPClass; }
static void NP_GetEntryPoints(NPPluginFuncs* aFuncs);
static PluginAsyncSurrogate* Cast(NPP aInstance);
virtual PluginAsyncSurrogate*
GetAsyncSurrogate() { return this; }
virtual PluginInstanceParent*
GetInstance() { return nullptr; }
NPP GetNPP() { return mInstance; }
bool GetPropertyHelper(NPObject* aObject, NPIdentifier aName,
bool* aHasProperty, bool* aHasMethod,
NPVariant* aResult);
PluginModuleParent*
GetParent() { return mParent; }
bool SetAcceptingCalls(bool aAccept)
{
bool prevState = mAcceptCalls;
if (mInstantiated) {
aAccept = true;
}
mAcceptCalls = aAccept;
return prevState;
}
void AsyncCallDeparting();
void AsyncCallArriving();
void NotifyAsyncInitFailed();
private:
explicit PluginAsyncSurrogate(PluginModuleParent* aParent);
virtual ~PluginAsyncSurrogate();
bool WaitForInit();
static bool SetStreamType(NPStream* aStream, uint16_t aStreamType);
static NPError NPP_Destroy(NPP aInstance, NPSavedData** aSave);
static NPError NPP_GetValue(NPP aInstance, NPPVariable aVariable, void* aRetval);
static NPError NPP_SetValue(NPP aInstance, NPNVariable aVariable, void* aValue);
static NPError NPP_NewStream(NPP aInstance, NPMIMEType aType, NPStream* aStream,
NPBool aSeekable, uint16_t* aStype);
static NPError NPP_SetWindow(NPP aInstance, NPWindow* aWindow);
static void NPP_Print(NPP aInstance, NPPrint* aPrintInfo);
static int16_t NPP_HandleEvent(NPP aInstance, void* aEvent);
static int32_t NPP_WriteReady(NPP aInstance, NPStream* aStream);
static NPObject* ScriptableAllocate(NPP aInstance, NPClass* aClass);
static void ScriptableInvalidate(NPObject* aObject);
static void ScriptableDeallocate(NPObject* aObject);
static bool ScriptableHasMethod(NPObject* aObject, NPIdentifier aName);
static bool ScriptableInvoke(NPObject* aObject, NPIdentifier aName,
const NPVariant* aArgs, uint32_t aArgCount,
NPVariant* aResult);
static bool ScriptableInvokeDefault(NPObject* aObject, const NPVariant* aArgs,
uint32_t aArgCount, NPVariant* aResult);
static bool ScriptableHasProperty(NPObject* aObject, NPIdentifier aName);
static bool ScriptableGetProperty(NPObject* aObject, NPIdentifier aName,
NPVariant* aResult);
static bool ScriptableSetProperty(NPObject* aObject, NPIdentifier aName,
const NPVariant* aValue);
static bool ScriptableRemoveProperty(NPObject* aObject, NPIdentifier aName);
static bool ScriptableEnumerate(NPObject* aObject, NPIdentifier** aIdentifiers,
uint32_t* aCount);
static bool ScriptableConstruct(NPObject* aObject, const NPVariant* aArgs,
uint32_t aArgCount, NPVariant* aResult);
private:
struct PendingNewStreamCall
{
PendingNewStreamCall(NPMIMEType aType, NPStream* aStream, NPBool aSeekable);
~PendingNewStreamCall() {}
nsCString mType;
NPStream* mStream;
NPBool mSeekable;
};
private:
PluginModuleParent* mParent;
// These values are used to construct the plugin instance
nsCString mMimeType;
NPP mInstance;
uint16_t mMode;
InfallibleTArray<nsCString> mNames;
InfallibleTArray<nsCString> mValues;
// This is safe to store as a pointer because the spec says it will remain
// valid until destruction or a subsequent NPP_SetWindow call.
NPWindow* mWindow;
nsTArray<PendingNewStreamCall> mPendingNewStreamCalls;
UniquePtr<PluginDestructionGuard> mPluginDestructionGuard;
bool mAcceptCalls;
bool mInstantiated;
bool mAsyncSetWindow;
bool mInitCancelled;
int32_t mAsyncCallsInFlight;
static const NPClass sNPClass;
};
struct AsyncNPObject : NPObject
{
explicit AsyncNPObject(PluginAsyncSurrogate* aSurrogate);
~AsyncNPObject();
NPObject* GetRealObject();
nsRefPtr<PluginAsyncSurrogate> mSurrogate;
NPObject* mRealObject;
};
class MOZ_STACK_CLASS PushSurrogateAcceptCalls
{
public:
explicit PushSurrogateAcceptCalls(PluginInstanceParent* aInstance);
~PushSurrogateAcceptCalls();
private:
PluginAsyncSurrogate* mSurrogate;
bool mPrevAcceptCallsState;
};
} // namespace plugins
} // namespace mozilla
#endif // dom_plugins_ipc_PluginAsyncSurrogate_h

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

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef dom_plugins_ipc_PluginDataResolver_h
#define dom_plugins_ipc_PluginDataResolver_h
namespace mozilla {
namespace plugins {
class PluginAsyncSurrogate;
class PluginInstanceParent;
class PluginDataResolver
{
public:
virtual PluginAsyncSurrogate* GetAsyncSurrogate() = 0;
virtual PluginInstanceParent* GetInstance() = 0;
};
} // namespace plugins
} // namespace mozilla
#endif // dom_plugins_ipc_PluginDataResolver_h

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

@ -119,16 +119,8 @@ CreateDrawTargetForSurface(gfxASurface *aSurface)
return drawTarget;
}
PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
: mPluginIface(aPluginIface)
, mMimeType(aMimeType)
, mMode(aMode)
, mNames(aNames)
, mValues(aValues)
#if defined(XP_MACOSX)
, mContentsScaleFactor(1.0)
#endif
@ -218,54 +210,6 @@ PluginInstanceChild::~PluginInstanceChild()
#endif
}
NPError
PluginInstanceChild::DoNPP_New()
{
// unpack the arguments into a C format
int argc = mNames.Length();
NS_ASSERTION(argc == (int) mValues.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(mNames[i]));
argv[i] = const_cast<char*>(NullableStringGet(mValues[i]));
}
NPP npp = GetNPP();
NPError rv = mPluginIface->newp((char*)NullableStringGet(mMimeType), npp,
mMode, argc, argn, argv, 0);
if (NPERR_NO_ERROR != rv) {
return rv;
}
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 (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.
SendNegotiatedCarbon();
// Fail to instantiate.
rv = NPERR_MODULE_LOAD_FAILED_ERROR;
}
#endif
return rv;
}
int
PluginInstanceChild::GetQuirks()
{
@ -2290,86 +2234,21 @@ PluginInstanceChild::RecvPPluginScriptableObjectConstructor(
}
bool
PluginInstanceChild::RecvPBrowserStreamConstructor(
PluginInstanceChild::AnswerPBrowserStreamConstructor(
PBrowserStreamChild* aActor,
const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyChild* notifyData,
const nsCString& headers)
{
return true;
}
NPError
PluginInstanceChild::DoNPP_NewStream(BrowserStreamChild* actor,
const nsCString& mimeType,
const bool& seekable,
uint16_t* stype)
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype)
{
AssertPluginThread();
NPError rv = actor->StreamConstructed(mimeType, seekable, stype);
return rv;
}
bool
PluginInstanceChild::AnswerNPP_NewStream(PBrowserStreamChild* actor,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype)
{
*rv = DoNPP_NewStream(static_cast<BrowserStreamChild*>(actor), mimeType,
seekable, stype);
return true;
}
class NewStreamAsyncCall : public ChildAsyncCall
{
public:
NewStreamAsyncCall(PluginInstanceChild* aInstance,
BrowserStreamChild* aBrowserStreamChild,
const nsCString& aMimeType,
const bool aSeekable)
: ChildAsyncCall(aInstance, nullptr, nullptr)
, mBrowserStreamChild(aBrowserStreamChild)
, mMimeType(aMimeType)
, mSeekable(aSeekable)
{
}
void Run() MOZ_OVERRIDE
{
RemoveFromAsyncList();
uint16_t stype = NP_NORMAL;
NPError rv = mInstance->DoNPP_NewStream(mBrowserStreamChild, mMimeType,
mSeekable, &stype);
DebugOnly<bool> sendOk =
mBrowserStreamChild->SendAsyncNPP_NewStreamResult(rv, stype);
MOZ_ASSERT(sendOk);
}
private:
BrowserStreamChild* mBrowserStreamChild;
const nsCString mMimeType;
const bool mSeekable;
};
bool
PluginInstanceChild::RecvAsyncNPP_NewStream(PBrowserStreamChild* actor,
const nsCString& mimeType,
const bool& seekable)
{
// Reusing ChildAsyncCall so that the task is cancelled properly on Destroy
BrowserStreamChild* child = static_cast<BrowserStreamChild*>(actor);
NewStreamAsyncCall* task = new NewStreamAsyncCall(this, child, mimeType,
seekable);
{
MutexAutoLock lock(mAsyncCallMutex);
mPendingAsyncCalls.AppendElement(task);
}
MessageLoop::current()->PostTask(FROM_HERE, task);
*rv = static_cast<BrowserStreamChild*>(aActor)
->StreamConstructed(mimeType, seekable, stype);
return true;
}
@ -2378,12 +2257,16 @@ PluginInstanceChild::AllocPBrowserStreamChild(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyChild* notifyData,
const nsCString& headers)
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype)
{
AssertPluginThread();
return new BrowserStreamChild(this, url, length, lastmodified,
static_cast<StreamNotifyChild*>(notifyData),
headers);
headers, mimeType, seekable, rv, stype);
}
bool

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

@ -143,31 +143,29 @@ protected:
virtual bool
RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor) MOZ_OVERRIDE;
virtual bool
RecvPBrowserStreamConstructor(PBrowserStreamChild* aActor, const nsCString& url,
const uint32_t& length, const uint32_t& lastmodified,
PStreamNotifyChild* notifyData, const nsCString& headers);
virtual bool
AnswerNPP_NewStream(
PBrowserStreamChild* actor,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype) MOZ_OVERRIDE;
virtual bool
RecvAsyncNPP_NewStream(
PBrowserStreamChild* actor,
const nsCString& mimeType,
const bool& seekable) MOZ_OVERRIDE;
virtual PBrowserStreamChild*
AllocPBrowserStreamChild(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyChild* notifyData,
const nsCString& headers) MOZ_OVERRIDE;
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype) MOZ_OVERRIDE;
virtual bool
AnswerPBrowserStreamConstructor(
PBrowserStreamChild* aActor,
const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t* stype) MOZ_OVERRIDE;
virtual bool
DeallocPBrowserStreamChild(PBrowserStreamChild* stream) MOZ_OVERRIDE;
@ -204,22 +202,10 @@ protected:
#endif
public:
PluginInstanceChild(const NPPluginFuncs* aPluginIface,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues);
explicit PluginInstanceChild(const NPPluginFuncs* aPluginIface);
virtual ~PluginInstanceChild();
NPError DoNPP_New();
// Common sync+async implementation of NPP_NewStream
NPError DoNPP_NewStream(BrowserStreamChild* actor,
const nsCString& mimeType,
const bool& seekable,
uint16_t* stype);
bool Initialize();
NPP GetNPP()
@ -366,10 +352,6 @@ private:
#endif
const NPPluginFuncs* mPluginIface;
nsCString mMimeType;
uint16_t mMode;
InfallibleTArray<nsCString> mNames;
InfallibleTArray<nsCString> mValues;
NPP_t mData;
NPWindow mWindow;
#if defined(XP_MACOSX)

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

@ -10,7 +10,6 @@
#include "mozilla/Telemetry.h"
#include "PluginInstanceParent.h"
#include "BrowserStreamParent.h"
#include "PluginAsyncSurrogate.h"
#include "PluginBackgroundDestroyer.h"
#include "PluginModuleParent.h"
#include "PluginStreamParent.h"
@ -22,7 +21,6 @@
#include "gfxPlatform.h"
#include "gfxSharedImageSurface.h"
#include "nsNPAPIPluginInstance.h"
#include "nsPluginInstanceOwner.h"
#ifdef MOZ_X11
#include "gfxXlibSurface.h"
#endif
@ -77,9 +75,7 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
NPP npp,
const nsCString& aMimeType,
const NPNetscapeFuncs* npniface)
: mParent(parent)
, mSurrogate(PluginAsyncSurrogate::Cast(npp))
, mUseSurrogate(true)
: mParent(parent)
, mNPP(npp)
, mNPNIface(npniface)
, mWindowType(NPWindowTypeWindow)
@ -171,7 +167,11 @@ PluginInstanceParent::AllocPBrowserStreamParent(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers)
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype)
{
NS_RUNTIMEABORT("Not reachable");
return nullptr;
@ -783,12 +783,6 @@ PluginInstanceParent::EndUpdateBackground(gfxContext* aCtx,
return NS_OK;
}
PluginAsyncSurrogate*
PluginInstanceParent::GetAsyncSurrogate()
{
return mSurrogate;
}
bool
PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
{
@ -1315,37 +1309,25 @@ PluginInstanceParent::NPP_NewStream(NPMIMEType type, NPStream* stream,
BrowserStreamParent* bs = new BrowserStreamParent(this, stream);
if (!SendPBrowserStreamConstructor(bs,
NullableString(stream->url),
stream->end,
stream->lastmodified,
static_cast<PStreamNotifyParent*>(stream->notifyData),
NullableString(stream->headers))) {
return NPERR_GENERIC_ERROR;
}
Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_STREAM_INIT_MS>
timer(Module()->GetHistogramKey());
NPError err = NPERR_NO_ERROR;
if (mParent->IsStartingAsync()) {
MOZ_ASSERT(mSurrogate);
mSurrogate->AsyncCallDeparting();
if (SendAsyncNPP_NewStream(bs, NullableString(type), seekable)) {
*stype = UINT16_MAX;
} else {
err = NPERR_GENERIC_ERROR;
}
} else {
bs->SetAlive();
if (!CallNPP_NewStream(bs, NullableString(type), seekable, &err, stype)) {
err = NPERR_GENERIC_ERROR;
}
if (NPERR_NO_ERROR != err) {
unused << PBrowserStreamParent::Send__delete__(bs);
NPError err;
{ // Scope for timer
Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_STREAM_INIT_MS>
timer(Module()->GetHistogramKey());
if (!CallPBrowserStreamConstructor(bs,
NullableString(stream->url),
stream->end,
stream->lastmodified,
static_cast<PStreamNotifyParent*>(stream->notifyData),
NullableString(stream->headers),
NullableString(type), seekable,
&err, stype)) {
return NPERR_GENERIC_ERROR;
}
}
if (NPERR_NO_ERROR != err)
unused << PBrowserStreamParent::Send__delete__(bs);
return err;
}
@ -1654,49 +1636,6 @@ PluginInstanceParent::RecvNegotiatedCarbon()
return true;
}
nsPluginInstanceOwner*
PluginInstanceParent::GetOwner()
{
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(mNPP->ndata);
if (!inst) {
return nullptr;
}
return inst->GetOwner();
}
bool
PluginInstanceParent::RecvAsyncNPP_NewResult(const NPError& aResult)
{
// NB: mUseSurrogate must be cleared before doing anything else, especially
// calling NPP_SetWindow!
mUseSurrogate = false;
mSurrogate->AsyncCallArriving();
if (aResult == NPERR_NO_ERROR) {
mSurrogate->SetAcceptingCalls(true);
}
nsPluginInstanceOwner* owner = GetOwner();
if (!owner) {
// This is possible in async plugin land; the instance may outlive
// the owner
return true;
}
if (aResult != NPERR_NO_ERROR) {
owner->NotifyHostAsyncInitFailed();
return true;
}
// Now we need to do a bunch of exciting post-NPP_New housekeeping.
owner->NotifyHostCreateWidget();
MOZ_ASSERT(mSurrogate);
mSurrogate->OnInstanceCreated(this);
return true;
}
#if defined(OS_WIN)
/*
@ -1936,29 +1875,3 @@ PluginInstanceParent::AnswerPluginFocusChange(const bool& gotFocus)
return false;
#endif
}
PluginInstanceParent*
PluginInstanceParent::Cast(NPP aInstance, PluginAsyncSurrogate** aSurrogate)
{
PluginDataResolver* resolver =
static_cast<PluginDataResolver*>(aInstance->pdata);
// If the plugin crashed and the PluginInstanceParent was deleted,
// aInstance->pdata will be nullptr.
if (!resolver) {
return nullptr;
}
PluginInstanceParent* instancePtr = resolver->GetInstance();
if (instancePtr && aInstance != instancePtr->mNPP) {
NS_RUNTIMEABORT("Corrupted plugin data.");
}
if (aSurrogate) {
*aSurrogate = resolver->GetAsyncSurrogate();
}
return instancePtr;
}

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

@ -22,7 +22,6 @@
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsRect.h"
#include "PluginDataResolver.h"
#ifdef MOZ_X11
class gfxXlibSurface;
@ -31,7 +30,6 @@ class gfxXlibSurface;
class gfxASurface;
class gfxContext;
class nsPluginInstanceOwner;
namespace mozilla {
namespace layers {
@ -44,7 +42,6 @@ class PBrowserStreamParent;
class PluginModuleParent;
class PluginInstanceParent : public PPluginInstanceParent
, public PluginDataResolver
{
friend class PluginModuleParent;
friend class BrowserStreamParent;
@ -77,7 +74,11 @@ public:
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers) MOZ_OVERRIDE;
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
NPError* rv,
uint16_t *stype) MOZ_OVERRIDE;
virtual bool
DeallocPBrowserStreamParent(PBrowserStreamParent* stream) MOZ_OVERRIDE;
@ -209,9 +210,6 @@ public:
virtual bool
RecvNegotiatedCarbon() MOZ_OVERRIDE;
virtual bool
RecvAsyncNPP_NewResult(const NPError& aResult) MOZ_OVERRIDE;
NPError NPP_SetWindow(const NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void* retval);
@ -256,12 +254,6 @@ public:
return mNPP;
}
bool
UseSurrogate() const
{
return mUseSurrogate;
}
virtual bool
AnswerPluginFocusChange(const bool& gotFocus) MOZ_OVERRIDE;
@ -279,13 +271,6 @@ public:
const nsIntRect& aRect);
void DidComposite() { unused << SendNPP_DidComposite(); }
virtual PluginAsyncSurrogate* GetAsyncSurrogate();
virtual PluginInstanceParent* GetInstance() { return this; }
static PluginInstanceParent* Cast(NPP instance,
PluginAsyncSurrogate** aSurrogate = nullptr);
private:
// Create an appropriate platform surface for a background of size
// |aSize|. Return true if successful.
@ -306,12 +291,8 @@ private:
PPluginScriptableObjectParent** aValue,
NPError* aResult);
nsPluginInstanceOwner* GetOwner();
private:
PluginModuleParent* mParent;
nsRefPtr<PluginAsyncSurrogate> mSurrogate;
bool mUseSurrogate;
NPP mNPP;
const NPNetscapeFuncs* mNPNIface;
NPWindowType mWindowType;

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

@ -95,13 +95,6 @@ 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,
@ -1888,21 +1881,7 @@ PluginModuleChild::AnswerNP_GetEntryPoints(NPError* _retval)
}
bool
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)
PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError* _retval)
{
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
@ -1921,11 +1900,12 @@ PluginModuleChild::DoNP_Initialize(const PluginSettings& aSettings)
SendBackUpXResources(FileDescriptor(xSocketFd));
#endif
NPError result;
#if defined(OS_LINUX) || defined(OS_BSD)
result = mInitializeFunc(&sBrowserFuncs, &mFunctions);
*_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions);
return true;
#elif defined(OS_WIN) || defined(OS_MACOSX)
result = mInitializeFunc(&sBrowserFuncs);
*_retval = mInitializeFunc(&sBrowserFuncs);
return true;
#else
# error Please implement me for your platform
#endif
@ -1933,8 +1913,6 @@ PluginModuleChild::DoNP_Initialize(const PluginSettings& aSettings)
#ifdef XP_WIN
CleanupProtectedModeHook();
#endif
return result;
}
#if defined(XP_WIN)
@ -2057,7 +2035,8 @@ PPluginInstanceChild*
PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
const InfallibleTArray<nsCString>& aValues,
NPError* rv)
{
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
@ -2073,8 +2052,7 @@ PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
}
#endif
return new PluginInstanceChild(&mFunctions, aMimeType, aMode, aNames,
aValues);
return new PluginInstanceChild(&mFunctions);
}
void
@ -2127,39 +2105,68 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
}
bool
PluginModuleChild::RecvPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv)
{
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);
AssertPluginThread();
*rv = childInstance->DoNPP_New();
return true;
}
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
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,10 +78,6 @@ 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,
@ -91,19 +87,19 @@ protected:
AllocPPluginInstanceChild(const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
MOZ_OVERRIDE;
const InfallibleTArray<nsCString>& aValues,
NPError* rv) MOZ_OVERRIDE;
virtual bool
DeallocPPluginInstanceChild(PPluginInstanceChild* aActor) MOZ_OVERRIDE;
virtual bool
RecvPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
MOZ_OVERRIDE;
AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues,
NPError* rv) MOZ_OVERRIDE;
virtual bool
AnswerNP_Shutdown(NPError *rv) MOZ_OVERRIDE;
@ -290,7 +286,6 @@ 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;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -40,7 +40,6 @@ namespace plugins {
//-----------------------------------------------------------------------------
class BrowserStreamParent;
class PluginAsyncSurrogate;
class PluginInstanceParent;
#ifdef XP_WIN
@ -80,8 +79,8 @@ protected:
AllocPPluginInstanceParent(const nsCString& aMimeType,
const uint16_t& aMode,
const InfallibleTArray<nsCString>& aNames,
const InfallibleTArray<nsCString>& aValues)
MOZ_OVERRIDE;
const InfallibleTArray<nsCString>& aValues,
NPError* rv) MOZ_OVERRIDE;
virtual bool
DeallocPPluginInstanceParent(PPluginInstanceParent* aActor) MOZ_OVERRIDE;
@ -90,13 +89,6 @@ public:
explicit PluginModuleParent(bool aIsChrome);
virtual ~PluginModuleParent();
bool RemovePendingSurrogate(const nsRefPtr<PluginAsyncSurrogate>& aSurrogate);
/** @return the state of the pref that controls async plugin init */
bool IsStartingAsync() const { return mIsStartingAsync; }
/** @return whether this modules NP_Initialize has successfully completed
executing */
bool IsInitialized() const { return mNPInitialized; }
bool IsChrome() const { return mIsChrome; }
virtual void SetPlugin(nsNPAPIPlugin* plugin) MOZ_OVERRIDE
@ -116,8 +108,6 @@ public:
void ProcessRemoteNativeEventsInInterruptCall();
virtual bool WaitForIPCConnection() { return true; }
nsCString GetHistogramKey() const {
return mPluginName + mPluginVersion;
}
@ -169,11 +159,8 @@ protected:
virtual bool
RecvNPN_ReloadPlugins(const bool& aReloadPages) MOZ_OVERRIDE;
virtual bool
RecvNP_InitializeResult(const NPError& aError) MOZ_OVERRIDE;
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s,
PluginAsyncSurrogate** aSurrogate = nullptr);
static PluginInstanceParent* InstCast(NPP instance);
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
protected:
virtual void UpdatePluginTimeout() {}
@ -182,11 +169,6 @@ protected:
void SetPluginFuncs(NPPluginFuncs* aFuncs);
nsresult NPP_NewInternal(NPMIMEType pluginType, NPP instance, uint16_t mode,
InfallibleTArray<nsCString>& names,
InfallibleTArray<nsCString>& values,
NPSavedData* saved, NPError* error);
// NPP-like API that Gecko calls are trampolined into. These
// messages then get forwarded along to the plugin instance,
// and then eventually the child process.
@ -253,11 +235,8 @@ protected:
virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor);
#endif
void InitAsyncSurrogates();
protected:
void NotifyPluginCrashed();
void OnInitFailure();
bool GetSetting(NPNVariable aVariable);
void GetSettings(PluginSettings* aSettings);
@ -266,7 +245,7 @@ protected:
bool mShutdown;
bool mClearSiteDataSupported;
bool mGetSitesWithDataSupported;
NPNetscapeFuncs* mNPNIface;
const NPNetscapeFuncs* mNPNIface;
nsNPAPIPlugin* mPlugin;
ScopedMethodFactory<PluginModuleParent> mTaskFactory;
nsString mPluginDumpID;
@ -287,29 +266,18 @@ protected:
GetPluginDetails(nsACString& aPluginName, nsACString& aPluginVersion);
friend class mozilla::dom::CrashReporterParent;
friend class mozilla::plugins::PluginAsyncSurrogate;
bool mIsStartingAsync;
bool mNPInitialized;
nsTArray<nsRefPtr<PluginAsyncSurrogate>> mSurrogateInstances;
nsresult mAsyncNewRv;
NPPluginFuncs* mAsyncInitPluginFuncs;
};
class PluginModuleContentParent : public PluginModuleParent
{
public:
explicit PluginModuleContentParent();
static PluginLibrary* LoadModule(uint32_t aPluginId);
static PluginModuleContentParent* Initialize(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess);
static void OnLoadPluginResult(const uint32_t& aPluginId, const bool& aResult);
static void AssociatePluginId(uint32_t aPluginId, base::ProcessId aProcessId);
static PluginModuleContentParent* Create(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess);
private:
explicit PluginModuleContentParent();
#ifdef MOZ_CRASHREPORTER_INJECTOR
void OnCrash(DWORD processID) MOZ_OVERRIDE {}
@ -345,17 +313,6 @@ class PluginModuleChromeParent
OnHangUIContinue();
#endif // XP_WIN
virtual bool WaitForIPCConnection() MOZ_OVERRIDE;
virtual bool
RecvNP_InitializeResult(const NPError& aError) MOZ_OVERRIDE;
void
SetContentParent(dom::ContentParent* aContentParent);
bool
SendAssociatePluginId();
void CachedSettingChanged();
private:
@ -384,14 +341,8 @@ private:
PluginProcessParent* Process() const { return mSubprocess; }
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) MOZ_OVERRIDE;
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) MOZ_OVERRIDE;
#endif
#if defined(XP_WIN) || defined(XP_MACOSX)
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) MOZ_OVERRIDE;
#if !defined(XP_UNIX) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);
#endif
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
@ -470,45 +421,17 @@ private:
#endif
friend class mozilla::dom::CrashReporterParent;
friend class mozilla::plugins::PluginAsyncSurrogate;
#ifdef MOZ_CRASHREPORTER_INJECTOR
void InitializeInjector();
void OnCrash(DWORD processID) MOZ_OVERRIDE;
DWORD mFlashProcess1;
DWORD mFlashProcess2;
#endif
void OnProcessLaunched(const bool aSucceeded);
class LaunchedTask : public LaunchCompleteTask
{
public:
explicit LaunchedTask(PluginModuleChromeParent* aModule)
: mModule(aModule)
{
MOZ_ASSERT(aModule);
}
void Run() MOZ_OVERRIDE
{
mModule->OnProcessLaunched(mLaunchSucceeded);
}
private:
PluginModuleChromeParent* mModule;
};
friend class LaunchedTask;
bool mInitOnAsyncConnect;
nsresult mAsyncInitRv;
NPError mAsyncInitError;
dom::ContentParent* mContentParent;
nsCOMPtr<nsIObserver> mOfflineObserver;
bool mIsFlashPlugin;
};
} // namespace plugins

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

@ -12,7 +12,6 @@
#include "mozilla/ipc/BrowserProcessSubThread.h"
#include "mozilla/plugins/PluginMessageUtils.h"
#include "mozilla/Telemetry.h"
#include "nsThreadUtils.h"
using std::vector;
using std::string;
@ -31,9 +30,7 @@ struct RunnableMethodTraits<PluginProcessParent>
PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath) :
GeckoChildProcessHost(GeckoProcessType_Plugin),
mPluginFilePath(aPluginFilePath),
mMainMsgLoop(MessageLoop::current()),
mRunCompleteTaskImmediately(false)
mPluginFilePath(aPluginFilePath)
{
}
@ -42,7 +39,7 @@ PluginProcessParent::~PluginProcessParent()
}
bool
PluginProcessParent::Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask)
PluginProcessParent::Launch(int32_t timeoutMs)
{
ProcessArchitecture currentArchitecture = base::GetCurrentProcessArchitecture();
uint32_t containerArchitectures = GetSupportedArchitecturesForProcessType(GeckoProcessType_Plugin);
@ -77,16 +74,10 @@ PluginProcessParent::Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask)
}
}
mLaunchCompleteTask = Move(aLaunchCompleteTask);
vector<string> args;
args.push_back(MungePluginDsoPath(mPluginFilePath));
bool result = AsyncLaunch(args, selectedArchitecture);
if (!result) {
mLaunchCompleteTask = nullptr;
}
return result;
Telemetry::AutoTimer<Telemetry::PLUGIN_STARTUP_MS> timer;
return SyncLaunch(args, timeoutMs, selectedArchitecture);
}
void
@ -103,50 +94,3 @@ PluginProcessParent::Delete()
ioLoop->PostTask(FROM_HERE,
NewRunnableMethod(this, &PluginProcessParent::Delete));
}
void
PluginProcessParent::SetCallRunnableImmediately(bool aCallImmediately)
{
mRunCompleteTaskImmediately = aCallImmediately;
}
bool
PluginProcessParent::WaitUntilConnected(int32_t aTimeoutMs)
{
bool result = GeckoChildProcessHost::WaitUntilConnected(aTimeoutMs);
if (mRunCompleteTaskImmediately && mLaunchCompleteTask) {
if (result) {
mLaunchCompleteTask->SetLaunchSucceeded();
}
mLaunchCompleteTask->Run();
mLaunchCompleteTask = nullptr;
}
return result;
}
void
PluginProcessParent::OnChannelConnected(int32_t peer_pid)
{
GeckoChildProcessHost::OnChannelConnected(peer_pid);
if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
mLaunchCompleteTask->SetLaunchSucceeded();
mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
}
}
void
PluginProcessParent::OnChannelError()
{
GeckoChildProcessHost::OnChannelError();
if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
}
}
bool
PluginProcessParent::IsConnected()
{
mozilla::MonitorAutoLock lock(mMonitor);
return mProcessState == PROCESS_CONNECTED;
}

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

@ -11,32 +11,15 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/task.h"
#include "base/thread.h"
#include "base/waitable_event.h"
#include "chrome/common/child_process_host.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/UniquePtr.h"
#include "nsCOMPtr.h"
#include "nsIRunnable.h"
namespace mozilla {
namespace plugins {
class LaunchCompleteTask : public Task
{
public:
LaunchCompleteTask()
: mLaunchSucceeded(false)
{
}
void SetLaunchSucceeded() { mLaunchSucceeded = true; }
protected:
bool mLaunchSucceeded;
};
//-----------------------------------------------------------------------------
class PluginProcessParent : public mozilla::ipc::GeckoChildProcessHost
{
@ -45,13 +28,10 @@ public:
~PluginProcessParent();
/**
* Launch the plugin process. If the process fails to launch,
* this method will return false.
*
* @param aLaunchCompleteTask Task that is executed on the main
* thread once the asynchonous launch has completed.
* Synchronously launch the plugin process. If the process fails to launch
* after timeoutMs, this method will return false.
*/
bool Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask = UniquePtr<LaunchCompleteTask>());
bool Launch(int32_t timeoutMs);
void Delete();
@ -65,19 +45,8 @@ public:
using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent;
using mozilla::ipc::GeckoChildProcessHost::GetChannel;
void SetCallRunnableImmediately(bool aCallImmediately);
virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0) MOZ_OVERRIDE;
virtual void OnChannelConnected(int32_t peer_pid) MOZ_OVERRIDE;
virtual void OnChannelError() MOZ_OVERRIDE;
bool IsConnected();
private:
std::string mPluginFilePath;
UniquePtr<LaunchCompleteTask> mLaunchCompleteTask;
MessageLoop* mMainMsgLoop;
bool mRunCompleteTaskImmediately;
DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
};

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

@ -1281,7 +1281,5 @@ PluginScriptableObjectChild::CollectForInstance(NPObjectData* d, void* userArg)
PluginScriptableObjectChild::NotifyOfInstanceShutdown(PluginInstanceChild* aInstance)
{
AssertPluginThread();
if (sObjectMap) {
sObjectMap->EnumerateEntries(CollectForInstance, aInstance);
}
sObjectMap->EnumerateEntries(CollectForInstance, aInstance);
}

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

@ -12,7 +12,6 @@
#include "mozilla/plugins/PluginTypes.h"
#include "mozilla/unused.h"
#include "nsNPAPIPlugin.h"
#include "PluginAsyncSurrogate.h"
#include "PluginScriptableObjectUtils.h"
using namespace mozilla;
@ -111,7 +110,6 @@ inline void
ReleaseVariant(NPVariant& aVariant,
PluginInstanceParent* aInstance)
{
PushSurrogateAcceptCalls acceptCalls(aInstance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(aInstance);
if (npn) {
npn->releasevariantvalue(&aVariant);
@ -645,7 +643,6 @@ PluginScriptableObjectParent::CreateProxyObject()
NS_ASSERTION(mInstance, "Must have an instance!");
NS_ASSERTION(mType == Proxy, "Shouldn't call this for non-proxy object!");
PushSurrogateAcceptCalls acceptCalls(mInstance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(mInstance);
NPObject* npobject = npn->createobject(mInstance->GetNPP(),
@ -764,7 +761,6 @@ PluginScriptableObjectParent::AnswerHasMethod(const PluginIdentifier& aId,
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -805,7 +801,6 @@ PluginScriptableObjectParent::AnswerInvoke(const PluginIdentifier& aId,
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -895,7 +890,6 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const InfallibleTArray<Variant
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -976,7 +970,6 @@ PluginScriptableObjectParent::AnswerHasProperty(const PluginIdentifier& aId,
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -1019,7 +1012,6 @@ PluginScriptableObjectParent::AnswerGetParentProperty(
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -1076,7 +1068,6 @@ PluginScriptableObjectParent::AnswerSetProperty(const PluginIdentifier& aId,
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -1123,7 +1114,6 @@ PluginScriptableObjectParent::AnswerRemoveProperty(const PluginIdentifier& aId,
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -1162,7 +1152,6 @@ PluginScriptableObjectParent::AnswerEnumerate(InfallibleTArray<PluginIdentifier>
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_WARNING("No netscape funcs?!");
@ -1215,7 +1204,6 @@ PluginScriptableObjectParent::AnswerConstruct(const InfallibleTArray<Variant>& a
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");
@ -1308,7 +1296,6 @@ PluginScriptableObjectParent::AnswerNPN_Evaluate(const nsCString& aScript,
return true;
}
PushSurrogateAcceptCalls acceptCalls(instance);
const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
if (!npn) {
NS_ERROR("No netscape funcs?!");

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

@ -16,7 +16,6 @@
namespace mozilla {
namespace plugins {
class PluginAsyncSurrogate;
class PluginInstanceParent;
class PluginScriptableObjectParent;

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

@ -21,9 +21,7 @@ EXPORTS.mozilla.plugins += [
'NPEventOSX.h',
'NPEventUnix.h',
'NPEventWindows.h',
'PluginAsyncSurrogate.h',
'PluginBridge.h',
'PluginDataResolver.h',
'PluginInstanceChild.h',
'PluginInstanceParent.h',
'PluginMessageUtils.h',
@ -82,7 +80,6 @@ UNIFIED_SOURCES += [
'BrowserStreamParent.cpp',
'ChildAsyncCall.cpp',
'ChildTimer.cpp',
'PluginAsyncSurrogate.cpp',
'PluginBackgroundDestroyer.cpp',
'PluginInstanceParent.cpp',
'PluginMessageUtils.cpp',

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

@ -315,6 +315,8 @@ GeckoChildProcessHost::SyncLaunch(std::vector<std::string> aExtraOpts, int aTime
{
PrepareLaunch();
PRIntervalTime timeoutTicks = (aTimeoutMs > 0) ?
PR_MillisecondsToInterval(aTimeoutMs) : PR_INTERVAL_NO_TIMEOUT;
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
NS_ASSERTION(MessageLoop::current() != ioLoop, "sync launch from the IO thread NYI");
@ -322,40 +324,8 @@ GeckoChildProcessHost::SyncLaunch(std::vector<std::string> aExtraOpts, int aTime
NewRunnableMethod(this,
&GeckoChildProcessHost::RunPerformAsyncLaunch,
aExtraOpts, arch));
return WaitUntilConnected(aTimeoutMs);
}
bool
GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts,
base::ProcessArchitecture arch)
{
PrepareLaunch();
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
ioLoop->PostTask(FROM_HERE,
NewRunnableMethod(this,
&GeckoChildProcessHost::RunPerformAsyncLaunch,
aExtraOpts, arch));
// This may look like the sync launch wait, but we only delay as
// long as it takes to create the channel.
MonitorAutoLock lock(mMonitor);
while (mProcessState < CHANNEL_INITIALIZED) {
lock.Wait();
}
return true;
}
bool
GeckoChildProcessHost::WaitUntilConnected(int32_t aTimeoutMs)
{
// NB: this uses a different mechanism than the chromium parent
// class.
PRIntervalTime timeoutTicks = (aTimeoutMs > 0) ?
PR_MillisecondsToInterval(aTimeoutMs) : PR_INTERVAL_NO_TIMEOUT;
MonitorAutoLock lock(mMonitor);
PRIntervalTime waitStart = PR_IntervalNow();
PRIntervalTime current;
@ -384,6 +354,27 @@ GeckoChildProcessHost::WaitUntilConnected(int32_t aTimeoutMs)
return mProcessState == PROCESS_CONNECTED;
}
bool
GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts)
{
PrepareLaunch();
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
ioLoop->PostTask(FROM_HERE,
NewRunnableMethod(this,
&GeckoChildProcessHost::RunPerformAsyncLaunch,
aExtraOpts, base::GetCurrentProcessArchitecture()));
// This may look like the sync launch wait, but we only delay as
// long as it takes to create the channel.
MonitorAutoLock lock(mMonitor);
while (mProcessState < CHANNEL_INITIALIZED) {
lock.Wait();
}
return true;
}
bool
GeckoChildProcessHost::LaunchAndWaitForProcessHandle(StringVector aExtraOpts)
{

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

@ -52,10 +52,7 @@ public:
// Block until the IPC channel for our subprocess is initialized,
// but no longer. The child process may or may not have been
// created when this method returns.
bool AsyncLaunch(StringVector aExtraOpts=StringVector(),
base::ProcessArchitecture arch=base::GetCurrentProcessArchitecture());
virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0);
bool AsyncLaunch(StringVector aExtraOpts=StringVector());
// Block until the IPC channel for our subprocess is initialized and
// the OS process is created. The subprocess may or may not have

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

@ -298,7 +298,6 @@ MessageChannel::MessageChannel(MessageListener *aListener)
mRecvdErrors(0),
mRemoteStackDepthGuess(false),
mSawInterruptOutMsg(false),
mIsWaitingForIncoming(false),
mAbortOnError(false),
mBlockScripts(false),
mFlags(REQUIRE_DEFAULT),
@ -665,8 +664,7 @@ MessageChannel::OnMessageReceivedFromLink(const Message& aMsg)
}
bool shouldWakeUp = AwaitingInterruptReply() ||
(AwaitingSyncReply() && !ShouldDeferMessage(aMsg)) ||
AwaitingIncomingMessage();
(AwaitingSyncReply() && !ShouldDeferMessage(aMsg));
// There are three cases we're concerned about, relating to the state of the
// main thread:
@ -989,35 +987,6 @@ MessageChannel::Call(Message* aMsg, Message* aReply)
return true;
}
bool
MessageChannel::WaitForIncomingMessage()
{
#ifdef OS_WIN
SyncStackFrame frame(this, true);
#endif
{ // Scope for lock
MonitorAutoLock lock(*mMonitor);
AutoEnterWaitForIncoming waitingForIncoming(*this);
if (mChannelState != ChannelConnected) {
return false;
}
if (!HasPendingEvents()) {
return WaitForInterruptNotify();
}
}
return OnMaybeDequeueOne();
}
bool
MessageChannel::HasPendingEvents()
{
AssertWorkerThread();
mMonitor->AssertCurrentThreadOwns();
return Connected() && !mPending.empty();
}
bool
MessageChannel::InterruptEventOccurred()
{
@ -1577,7 +1546,7 @@ MessageChannel::OnChannelErrorFromLink()
if (InterruptStackDepth() > 0)
NotifyWorkerThread();
if (AwaitingSyncReply() || AwaitingIncomingMessage())
if (AwaitingSyncReply())
NotifyWorkerThread();
if (ChannelClosing != mChannelState) {

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

@ -124,9 +124,6 @@ class MessageChannel : HasResultCodes
// Make an Interrupt call to the other side of the channel
bool Call(Message* aMsg, Message* aReply);
// Wait until a message is received
bool WaitForIncomingMessage();
bool CanSend() const;
void SetReplyTimeoutMs(int32_t aTimeoutMs);
@ -217,7 +214,6 @@ class MessageChannel : HasResultCodes
void DispatchOnChannelConnected();
bool InterruptEventOccurred();
bool HasPendingEvents();
bool ProcessPendingRequest(const Message &aUrgent);
@ -323,30 +319,6 @@ class MessageChannel : HasResultCodes
mMonitor->AssertCurrentThreadOwns();
return !mInterruptStack.empty();
}
bool AwaitingIncomingMessage() const {
mMonitor->AssertCurrentThreadOwns();
return mIsWaitingForIncoming;
}
class MOZ_STACK_CLASS AutoEnterWaitForIncoming
{
public:
explicit AutoEnterWaitForIncoming(MessageChannel& aChannel)
: mChannel(aChannel)
{
aChannel.mMonitor->AssertCurrentThreadOwns();
aChannel.mIsWaitingForIncoming = true;
}
~AutoEnterWaitForIncoming()
{
mChannel.mIsWaitingForIncoming = false;
}
private:
MessageChannel& mChannel;
};
friend class AutoEnterWaitForIncoming;
// Returns true if we're dispatching a sync message's callback.
bool DispatchingSyncMessage() const {
@ -667,11 +639,6 @@ class MessageChannel : HasResultCodes
// ExitedCxxStack(), from which this variable is reset.
bool mSawInterruptOutMsg;
// Are we waiting on this channel for an incoming message? This is used
// to implement WaitForIncomingMessage(). Must only be accessed while owning
// mMonitor.
bool mIsWaitingForIncoming;
// Map of replies received "out of turn", because of Interrupt
// in-calls racing with replies to outstanding in-calls. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=521929.

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

@ -966,7 +966,7 @@ MessageChannel::WaitForInterruptNotify()
return WaitForSyncNotify();
}
if (!InterruptStackDepth() && !AwaitingIncomingMessage()) {
if (!InterruptStackDepth()) {
// There is currently no way to recover from this condition.
NS_RUNTIMEABORT("StackDepth() is 0 in call to MessageChannel::WaitForNotify!");
}

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

@ -2369,8 +2369,6 @@ pref("dom.ipc.plugins.reportCrashURL", true);
// Defaults to 30 seconds.
pref("dom.ipc.plugins.unloadTimeoutSecs", 30);
pref("dom.ipc.plugins.asyncInit", false);
pref("dom.ipc.processCount", 1);
// Enable caching of Moz2D Path objects for SVG geometry elements

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

@ -7029,15 +7029,6 @@
"keyed": true,
"description": "Time (ms) that the main thread has been blocked on NPP_NewStream in an IPC plugin"
},
"BLOCKED_ON_PLUGINASYNCSURROGATE_WAITFORINIT_MS": {
"expires_in_version": "40",
"kind": "exponential",
"high": "10000",
"n_buckets": 20,
"extended_statistics_ok": true,
"keyed": true,
"description": "Time (ms) that the main thread has been blocked on PluginAsyncSurrogate::WaitForInit in an IPC plugin"
},
"BLOCKED_ON_PLUGIN_INSTANCE_DESTROY_MS": {
"expires_in_version": "40",
"kind": "exponential",

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

@ -330,7 +330,6 @@
ERROR(NS_ERROR_PLUGIN_BLOCKLISTED, FAILURE(1002)),
ERROR(NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED, FAILURE(1003)),
ERROR(NS_ERROR_PLUGIN_CLICKTOPLAY, FAILURE(1004)),
ERROR(NS_PLUGIN_INIT_PENDING, SUCCESS(1005)),
#undef MODULE