diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/server/actors/memory.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/server/actors/memory.js')
-rw-r--r-- | devtools/server/actors/memory.js | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/devtools/server/actors/memory.js b/devtools/server/actors/memory.js new file mode 100644 index 000000000..5c41a7dc1 --- /dev/null +++ b/devtools/server/actors/memory.js @@ -0,0 +1,83 @@ +/* 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/. */ + +"use strict"; + +const protocol = require("devtools/shared/protocol"); +const { Memory } = require("devtools/server/performance/memory"); +const { actorBridgeWithSpec } = require("devtools/server/actors/common"); +const { memorySpec } = require("devtools/shared/specs/memory"); +loader.lazyRequireGetter(this, "events", "sdk/event/core"); +loader.lazyRequireGetter(this, "StackFrameCache", + "devtools/server/actors/utils/stack", true); + +/** + * An actor that returns memory usage data for its parent actor's window. + * A tab-scoped instance of this actor will measure the memory footprint of its + * parent tab. A global-scoped instance however, will measure the memory + * footprint of the chrome window referenced by the root actor. + * + * This actor wraps the Memory module at devtools/server/performance/memory.js + * and provides RDP definitions. + * + * @see devtools/server/performance/memory.js for documentation. + */ +exports.MemoryActor = protocol.ActorClassWithSpec(memorySpec, { + initialize: function (conn, parent, frameCache = new StackFrameCache()) { + protocol.Actor.prototype.initialize.call(this, conn); + + this._onGarbageCollection = this._onGarbageCollection.bind(this); + this._onAllocations = this._onAllocations.bind(this); + this.bridge = new Memory(parent, frameCache); + this.bridge.on("garbage-collection", this._onGarbageCollection); + this.bridge.on("allocations", this._onAllocations); + }, + + destroy: function () { + this.bridge.off("garbage-collection", this._onGarbageCollection); + this.bridge.off("allocations", this._onAllocations); + this.bridge.destroy(); + protocol.Actor.prototype.destroy.call(this); + }, + + attach: actorBridgeWithSpec("attach"), + + detach: actorBridgeWithSpec("detach"), + + getState: actorBridgeWithSpec("getState"), + + saveHeapSnapshot: function (boundaries) { + return this.bridge.saveHeapSnapshot(boundaries); + }, + + takeCensus: actorBridgeWithSpec("takeCensus"), + + startRecordingAllocations: actorBridgeWithSpec("startRecordingAllocations"), + + stopRecordingAllocations: actorBridgeWithSpec("stopRecordingAllocations"), + + getAllocationsSettings: actorBridgeWithSpec("getAllocationsSettings"), + + getAllocations: actorBridgeWithSpec("getAllocations"), + + forceGarbageCollection: actorBridgeWithSpec("forceGarbageCollection"), + + forceCycleCollection: actorBridgeWithSpec("forceCycleCollection"), + + measure: actorBridgeWithSpec("measure"), + + residentUnique: actorBridgeWithSpec("residentUnique"), + + _onGarbageCollection: function (data) { + if (this.conn.transport) { + events.emit(this, "garbage-collection", data); + } + }, + + _onAllocations: function (data) { + if (this.conn.transport) { + events.emit(this, "allocations", data); + } + }, +}); |