Labs/Jetpack/JEP/25: Difference between revisions

Added sample code.
(added notes on memory tracking)
(Added sample code.)
Line 20: Line 20:
* An easy-to-learn documentation system capable of producing beautiful documentation.
* An easy-to-learn documentation system capable of producing beautiful documentation.
* A mechanism for tracking objects of interest belonging to the Chrome Booster to aid in memory profiling and leak detection.
* A mechanism for tracking objects of interest belonging to the Chrome Booster to aid in memory profiling and leak detection.
= Potential Code =
This code doesn't actually work; it's just aspirational.
Assume that the following code is contained in a file at <tt>chrome://some_extension/content/foo.html</tt>.
<pre>
<html>
<!-- This script makes the SecurableModule global available. -->
<script src="securable-module.js"></script>
<script>
// Create a loader for SecurableModules that gives them chrome
// privileges by default and roots the filesystem at (our URL)/lib.
var loader = SecurableModule.Loader({defaultPrincipal: "system",
                                    rootPath: "lib"});
// Load the 'foo' SecurableModule and call its exported doSomething()
// function.
loader.require('blarg').doSomething();
window.addEventListener(
  "unload",
  function() {
    // Send an unload signal to free any resources created by modules so
    // far.
    loader.require('unload').send();
  },
  false
);
</script>
</html>
</pre>
Note that the <tt>unload</tt> module conventions are laid out by the [http://narwhaljs.org/narwhal.html Narwhal] CommonJS-based platform.
874

edits