Bug 1217969 - Highlight the memory tool tab when recording allocations. r=fitzgen

This commit is contained in:
Jordan Santell 2015-10-28 07:47:53 -07:00
parent a5c5dae2ae
commit 210dc6fb6c

View File

@ -19,16 +19,39 @@ const Store = require("devtools/client/memory/store");
*/ */
var gToolbox, gTarget, gFront, gHeapAnalysesClient; var gToolbox, gTarget, gFront, gHeapAnalysesClient;
/**
* Variables set by `initialize()`
*/
var gStore, unsubscribe, isHighlighted;
function initialize () { function initialize () {
return Task.spawn(function*() { return Task.spawn(function*() {
let root = document.querySelector("#app"); let root = document.querySelector("#app");
let store = Store(); gStore = Store();
let app = createElement(App, { front: gFront, heapWorker: gHeapAnalysesClient }); let app = createElement(App, { front: gFront, heapWorker: gHeapAnalysesClient });
let provider = createElement(Provider, { store }, app); let provider = createElement(Provider, { store: gStore }, app);
render(provider, root); render(provider, root);
unsubscribe = gStore.subscribe(onStateChange);
}); });
} }
function destroy () { function destroy () {
return Task.spawn(function*(){}); return Task.spawn(function*(){
unsubscribe();
});
}
/**
* 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) {
isRecording ?
gToolbox.highlightTool("memory") :
gToolbox.unhighlightTool("memory");
isHighlighted = isRecording;
}
} }