summaryrefslogtreecommitdiffstats
path: root/devtools/client/memory/initializer.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/memory/initializer.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/client/memory/initializer.js')
-rw-r--r--devtools/client/memory/initializer.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/devtools/client/memory/initializer.js b/devtools/client/memory/initializer.js
new file mode 100644
index 000000000..adb6e40c1
--- /dev/null
+++ b/devtools/client/memory/initializer.js
@@ -0,0 +1,67 @@
+/* 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 { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
+const BrowserLoaderModule = {};
+Cu.import("resource://devtools/client/shared/browser-loader.js", BrowserLoaderModule);
+const { require } = BrowserLoaderModule.BrowserLoader({
+ baseURI: "resource://devtools/client/memory/",
+ window
+});
+const { Task } = require("devtools/shared/task");
+const { createFactory, createElement } = require("devtools/client/shared/vendor/react");
+const ReactDOM = require("devtools/client/shared/vendor/react-dom");
+const { Provider } = require("devtools/client/shared/vendor/react-redux");
+const App = createFactory(require("devtools/client/memory/app"));
+const Store = require("devtools/client/memory/store");
+const { assert } = require("devtools/shared/DevToolsUtils");
+
+/**
+ * The current target, toolbox, MemoryFront, and HeapAnalysesClient, set by this tool's host.
+ */
+var gToolbox, gTarget, gFront, gHeapAnalysesClient;
+
+/**
+ * Variables set by `initialize()`
+ */
+var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted, telemetry;
+
+var initialize = Task.async(function* () {
+ gRoot = document.querySelector("#app");
+ gStore = Store();
+ gApp = createElement(App, { toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient });
+ gProvider = createElement(Provider, { store: gStore }, gApp);
+ ReactDOM.render(gProvider, gRoot);
+ unsubscribe = gStore.subscribe(onStateChange);
+});
+
+var destroy = Task.async(function* () {
+ const ok = ReactDOM.unmountComponentAtNode(gRoot);
+ assert(ok, "Should successfully unmount the memory tool's top level React component");
+
+ unsubscribe();
+
+ gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted;
+});
+
+/**
+ * Fired on any state change, currently only handles toggling
+ * the highlighting of the tool when recording allocations.
+ */
+function onStateChange() {
+ let isRecording = gStore.getState().allocations.recording;
+ if (isRecording === isHighlighted) {
+ return;
+ }
+
+ if (isRecording) {
+ gToolbox.highlightTool("memory");
+ } else {
+ gToolbox.unhighlightTool("memory");
+ }
+
+ isHighlighted = isRecording;
+}