Ejemplo n.º 1
0
void
MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
                  bool aPrepareForCC)
{
  if (!aViewer) {
    return;
  }

  nsIDocument *doc = aViewer->GetDocument();
  if (doc &&
      doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
    doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
    if (aCleanupJS) {
      EventListenerManager* elm = doc->GetExistingListenerManager();
      if (elm) {
        elm->MarkForCC();
      }
      nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow());
      if (win) {
        elm = win->GetExistingListenerManager();
        if (elm) {
          elm->MarkForCC();
        }
        static_cast<nsGlobalWindow*>(win.get())->UnmarkGrayTimers();
      }
    } else if (aPrepareForCC) {
      // Unfortunately we need to still mark user data just before running CC so
      // that it has the right generation.
      doc->PropertyTable(DOM_USER_DATA)->
        EnumerateAll(MarkUserData, &nsCCUncollectableMarker::sGeneration);
    }
  }
  if (doc) {
    nsPIDOMWindow* inner = doc->GetInnerWindow();
    if (inner) {
      inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
    }
    nsPIDOMWindow* outer = doc->GetWindow();
    if (outer) {
      outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
    }
  }
}
void MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS) {
  if (!aViewer) {
    return;
  }

  Document* doc = aViewer->GetDocument();
  if (doc &&
      doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
    doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
    if (aCleanupJS) {
      EventListenerManager* elm = doc->GetExistingListenerManager();
      if (elm) {
        elm->MarkForCC();
      }
      nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow());
      if (win) {
        elm = win->GetExistingListenerManager();
        if (elm) {
          elm->MarkForCC();
        }
        static_cast<nsGlobalWindowInner*>(win.get())
            ->AsInner()
            ->TimeoutManager()
            .UnmarkGrayTimers();
      }
    }
  }
  if (doc) {
    if (nsPIDOMWindowInner* inner = doc->GetInnerWindow()) {
      inner->MarkUncollectableForCCGeneration(
          nsCCUncollectableMarker::sGeneration);
    }
    if (nsPIDOMWindowOuter* outer = doc->GetWindow()) {
      outer->MarkUncollectableForCCGeneration(
          nsCCUncollectableMarker::sGeneration);
    }
  }
}
static void
MarkChildMessageManagers(nsIMessageBroadcaster* aMM)
{
  aMM->MarkForCC();

  uint32_t tabChildCount = 0;
  aMM->GetChildCount(&tabChildCount);
  for (uint32_t j = 0; j < tabChildCount; ++j) {
    nsCOMPtr<nsIMessageListenerManager> childMM;
    aMM->GetChildAt(j, getter_AddRefs(childMM));
    if (!childMM) {
      continue;
    }

    nsCOMPtr<nsIMessageBroadcaster> strongNonLeafMM = do_QueryInterface(childMM);
    nsIMessageBroadcaster* nonLeafMM = strongNonLeafMM;

    nsCOMPtr<nsIMessageSender> strongTabMM = do_QueryInterface(childMM);
    nsIMessageSender* tabMM = strongTabMM;

    strongNonLeafMM = nullptr;
    strongTabMM = nullptr;
    childMM = nullptr;

    if (nonLeafMM) {
      MarkChildMessageManagers(nonLeafMM);
      continue;
    }

    tabMM->MarkForCC();

    //XXX hack warning, but works, since we know that
    //    callback is frameloader.
    mozilla::dom::ipc::MessageManagerCallback* cb =
      static_cast<nsFrameMessageManager*>(tabMM)->GetCallback();
    if (cb) {
      nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
      EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
      if (!et) {
        continue;
      }
      static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
      EventListenerManager* elm = et->GetExistingListenerManager();
      if (elm) {
        elm->MarkForCC();
      }
    }
  }
}
Ejemplo n.º 4
0
static void
MarkChildMessageManagers(ChromeMessageBroadcaster* aMM)
{
  aMM->MarkForCC();

  uint32_t tabChildCount = aMM->ChildCount();
  for (uint32_t j = 0; j < tabChildCount; ++j) {
    RefPtr<MessageListenerManager> childMM = aMM->GetChildAt(j);
    if (!childMM) {
      continue;
    }

    RefPtr<ChromeMessageBroadcaster> strongNonLeafMM =
      ChromeMessageBroadcaster::From(childMM);
    ChromeMessageBroadcaster* nonLeafMM = strongNonLeafMM;

    MessageListenerManager* tabMM = childMM;

    strongNonLeafMM = nullptr;
    childMM = nullptr;

    if (nonLeafMM) {
      MarkChildMessageManagers(nonLeafMM);
      continue;
    }

    tabMM->MarkForCC();

    //XXX hack warning, but works, since we know that
    //    callback is frameloader.
    mozilla::dom::ipc::MessageManagerCallback* cb = tabMM->GetCallback();
    if (cb) {
      nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
      EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
      if (!et) {
        continue;
      }
      static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
      EventListenerManager* elm = et->GetExistingListenerManager();
      if (elm) {
        elm->MarkForCC();
      }
    }
  }
}