Blink‎ > ‎



The ActiveDOMObject is used to implement DOM objects that can involve asynchronous operations such as loading data from network (e.g. XMLHttpRequest, WebSocket) to
  • keep them alive while async op is active
  • hold back actions resulting from async op while the document is suspended
The ActiveDOMObject has a counter called "pending activity count" which can be checked by hasPendingActivity() method. As long as hasPendingActivity() returns true, V8 prolongs its life so that it doesn't get garbage collected even when it becomes unreachable. setPendingActivity() increments the pending activity count and unsetPendingActivity() decrements it.

While hasPendingActivity() returns true, the life of the parent Document object is also prolonged (explanation TBA). You rarely need to override contextDestroyed() for ActiveDOMObject subclasses.

Typically, an ActiveDOMObject subclass calls setPendingActivity() when it starts an asynchronous operation to pin down itself, and calls unsetPendingActivity() on completion.

ActiveDOMObjects are notified of detach of the parent Document object (or shutdown of the parent WorkerThread) as stop() method call on it. Commonly, they start shutdown of the asynchronous operation in stop() if any.

suspend() is called when dialogs such as alert(), prompt(), etc. are going to be shown or the WebInspector's pause is going to be active. resume() is called when the dialog is closed or the WebInspector resumes script execution. Between suspend() and resume(), it's recommended that operations on the ActiveDOMObjects are suspended. Since resource loading is automatically suspended by Chrome's resource dispatched code, you may not need to manually hold back async method calls.

As of Nov 12 2003 by tyoshino@
Thanks kouhei@, haraken@, abarth@