Bug 1178261 - make BroadcastChannel CC skippable, r=smaug

This commit is contained in:
Andrea Marchesini 2015-06-29 17:42:41 +01:00
Родитель 3fb4f10250
Коммит c72540ed84
5 изменённых файлов: 25 добавлений и 30 удалений

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

@ -105,6 +105,11 @@ private:
void UpdateMustKeepAlive();
bool IsCertainlyAliveForCC() const override
{
return mIsKeptAlive;
}
nsRefPtr<BroadcastChannelChild> mActor;
nsTArray<nsRefPtr<BroadcastChannelMessage>> mPendingMessages;

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

@ -48,10 +48,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(DOMEventTargetHelper)
if (tmp->IsBlack()) {
if (tmp->IsBlack() || tmp->IsCertainlyAliveForCC()) {
if (tmp->mListenerManager) {
tmp->mListenerManager->MarkForCC();
}
if (!tmp->IsBlack() && tmp->PreservingWrapper()) {
// This marks the wrapper black.
tmp->GetWrapper();
}
return true;
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END

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

@ -167,6 +167,14 @@ protected:
nsresult WantsUntrusted(bool* aRetVal);
// If this method returns true your object is kept alive until it returns
// false. You can use this method instead using
// NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN macro.
virtual bool IsCertainlyAliveForCC() const
{
return false;
}
nsRefPtr<EventListenerManager> mListenerManager;
// Make |event| trusted and dispatch |aEvent| to |this|.
nsresult DispatchTrustedEvent(nsIDOMEvent* aEvent);

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

@ -192,29 +192,6 @@ MessagePortBase::MessagePortBase()
NS_IMPL_CYCLE_COLLECTION_CLASS(MessagePort)
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(MessagePort)
bool isBlack = tmp->IsBlack();
if (isBlack || tmp->mIsKeptAlive) {
if (tmp->mListenerManager) {
tmp->mListenerManager->MarkForCC();
}
if (!isBlack && tmp->PreservingWrapper()) {
// This marks the wrapper black.
tmp->GetWrapper();
}
return true;
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(MessagePort)
return tmp->
IsBlackAndDoesNotNeedTracing(static_cast<DOMEventTargetHelper*>(tmp));
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(MessagePort)
return tmp->IsBlack();
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessagePort,
MessagePortBase)
if (tmp->mDispatchRunnable) {
@ -235,10 +212,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessagePort,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUnshippedEntangledPort);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MessagePort,
MessagePortBase)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MessagePort)
NS_INTERFACE_MAP_ENTRY(nsIIPCBackgroundChildCreateCallback)
NS_INTERFACE_MAP_ENTRY(nsIObserver)

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

@ -75,8 +75,8 @@ public:
NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
NS_DECL_NSIOBSERVER
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(MessagePort,
DOMEventTargetHelper)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MessagePort,
MessagePortBase)
static already_AddRefed<MessagePort>
Create(nsPIDOMWindow* aWindow, const nsID& aUUID,
@ -177,6 +177,11 @@ private:
// We release the object when the port is closed or disentangled.
void UpdateMustKeepAlive();
bool IsCertainlyAliveForCC() const override
{
return mIsKeptAlive;
}
nsAutoPtr<workers::WorkerFeature> mWorkerFeature;
nsRefPtr<DispatchEventRunnable> mDispatchRunnable;