зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1191145 - Stop blocking scripts when handling IPC messages (r=dvander)
This commit is contained in:
Родитель
5bf2bbbbee
Коммит
c091f01a39
|
@ -673,10 +673,6 @@ ContentChild::Init(MessageLoop* aIOLoop,
|
|||
}
|
||||
sSingleton = this;
|
||||
|
||||
// Make sure there's an nsAutoScriptBlocker on the stack when dispatching
|
||||
// urgent messages.
|
||||
GetIPCChannel()->BlockScripts();
|
||||
|
||||
// If communications with the parent have broken down, take the process
|
||||
// down so it's not hanging around.
|
||||
bool abortOnError = true;
|
||||
|
|
|
@ -280,31 +280,6 @@ private:
|
|||
CxxStackFrame& operator=(const CxxStackFrame&) = delete;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
class MOZ_RAII MaybeScriptBlocker {
|
||||
public:
|
||||
explicit MaybeScriptBlocker(MessageChannel *aChannel, bool aBlock
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mBlocked(aChannel->ShouldBlockScripts() && aBlock)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (mBlocked) {
|
||||
nsContentUtils::AddScriptBlocker();
|
||||
}
|
||||
}
|
||||
~MaybeScriptBlocker() {
|
||||
if (mBlocked) {
|
||||
nsContentUtils::RemoveScriptBlocker();
|
||||
}
|
||||
}
|
||||
private:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
bool mBlocked;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
MessageChannel::MessageChannel(MessageListener *aListener)
|
||||
: mListener(aListener),
|
||||
mChannelState(ChannelClosed),
|
||||
|
@ -332,7 +307,6 @@ MessageChannel::MessageChannel(MessageListener *aListener)
|
|||
mSawInterruptOutMsg(false),
|
||||
mIsWaitingForIncoming(false),
|
||||
mAbortOnError(false),
|
||||
mBlockScripts(false),
|
||||
mFlags(REQUIRE_DEFAULT),
|
||||
mPeerPidSet(false),
|
||||
mPeerPid(-1)
|
||||
|
@ -868,9 +842,6 @@ MessageChannel::Send(Message* aMsg, Message* aReply)
|
|||
{
|
||||
nsAutoPtr<Message> msg(aMsg);
|
||||
|
||||
// See comment in DispatchSyncMessage.
|
||||
MaybeScriptBlocker scriptBlocker(this, true);
|
||||
|
||||
// Sanity checks.
|
||||
AssertWorkerThread();
|
||||
mMonitor->AssertNotCurrentThreadOwns();
|
||||
|
@ -1430,15 +1401,10 @@ MessageChannel::DispatchSyncMessage(const Message& aMsg, Message*& aReply)
|
|||
|
||||
int prio = aMsg.priority();
|
||||
|
||||
// We don't want to run any code that might run a nested event loop here, so
|
||||
// we avoid running event handlers. Once we've sent the response to the
|
||||
// urgent message, it's okay to run event handlers again since the parent is
|
||||
// no longer blocked.
|
||||
MOZ_ASSERT_IF(prio > IPC::Message::PRIORITY_NORMAL, NS_IsMainThread());
|
||||
MaybeScriptBlocker scriptBlocker(this, prio > IPC::Message::PRIORITY_NORMAL);
|
||||
|
||||
MessageChannel* dummy;
|
||||
MessageChannel*& blockingVar = ShouldBlockScripts() ? gParentProcessBlocker : dummy;
|
||||
MessageChannel*& blockingVar = mSide == ChildSide && NS_IsMainThread() ? gParentProcessBlocker : dummy;
|
||||
|
||||
Result rv;
|
||||
{
|
||||
|
@ -1978,13 +1944,6 @@ MessageChannel::CloseWithTimeout()
|
|||
mChannelState = ChannelTimeout;
|
||||
}
|
||||
|
||||
void
|
||||
MessageChannel::BlockScripts()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mBlockScripts = true;
|
||||
}
|
||||
|
||||
void
|
||||
MessageChannel::Close()
|
||||
{
|
||||
|
|
|
@ -120,13 +120,6 @@ class MessageChannel : HasResultCodes
|
|||
void SetChannelFlags(ChannelFlags aFlags) { mFlags = aFlags; }
|
||||
ChannelFlags GetChannelFlags() { return mFlags; }
|
||||
|
||||
void BlockScripts();
|
||||
|
||||
bool ShouldBlockScripts() const
|
||||
{
|
||||
return mBlockScripts;
|
||||
}
|
||||
|
||||
// Asynchronously send a message to the other side of the channel
|
||||
bool Send(Message* aMsg);
|
||||
|
||||
|
@ -776,9 +769,6 @@ class MessageChannel : HasResultCodes
|
|||
// a channel error occurs?
|
||||
bool mAbortOnError;
|
||||
|
||||
// Should we prevent scripts from running while dispatching urgent messages?
|
||||
bool mBlockScripts;
|
||||
|
||||
// See SetChannelFlags
|
||||
ChannelFlags mFlags;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче