Skip to content

Commit

Permalink
devtools: warm up namespace cache when switching panels
Browse files Browse the repository at this point in the history
Namespace cache is used for beautification function names. Unfortunately
devtools is not currently designed to allow async beautification,
so we can properly beautify only if the cache is already populated.
  • Loading branch information
darwin committed Jun 19, 2016
1 parent efa02d1 commit c931771
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions resources/unpacked/devtools/front_end/externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ var dirac = {

initConsole: function() {},
initRepl: function() {},
/**
* @param {!WebInspector.Panel} panel
*/
notifyPanelSwitch: function(panel) {},
getVersion: function() {},
getRuntimeTag: function() {},
/**
Expand Down
2 changes: 1 addition & 1 deletion resources/unpacked/devtools/front_end/ui/InspectorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ WebInspector.InspectorView.prototype = {
WebInspector.userMetrics.panelShown(panel.name);
panel.focus();

dirac.feedback("setCurrentPanel: "+panel.name);
dirac.notifyPanelSwitch(panel);
return panel;
},

Expand Down
11 changes: 10 additions & 1 deletion src/implant/dirac/implant.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
(defonce extra-specials #js ["dirac!" "*1" "*2" "*3" "*e"])
(defonce all-specials (.concat repl-specials extra-specials))

(defn warm-up-namespace-cache! []
(ocall (oget js/window "dirac") "extractNamespacesAsync"))

; -- public API -------------------------------------------------------------------------------------------------------------
; following functions will be exposed as helpers for devtools javascript code
; they should be called via dirac.something object, see the mapping in dirac-api-to-export below
Expand Down Expand Up @@ -86,13 +89,19 @@
(defn get-repl-specials-async []
(helpers/resolved-promise all-specials)) ; hard-coded for now

(defn notify-panel-switch [panel]
(let [panel-name (oget panel "name")]
(post-feedback! (str "setCurrentPanel: " panel-name))
(warm-up-namespace-cache!)))

; -- dirac object augumentation ---------------------------------------------------------------------------------------------

; !!! don't forget to update externs.js when touching this !!!
(def dirac-api-to-export
{"feedback" post-feedback!
"initConsole" init-console!
"initRepl" init-repl!
"notifyPanelSwitch" notify-panel-switch
"adoptPrompt" adopt-prompt!
"sendEvalRequest" send-eval-request!
"getVersion" get-version
Expand Down Expand Up @@ -122,4 +131,4 @@

; -- intialization ----------------------------------------------------------------------------------------------------------

(runonce (init-implant!))
(runonce (init-implant!))

0 comments on commit c931771

Please sign in to comment.