diff options
author | creis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 21:19:31 +0000 |
---|---|---|
committer | creis@google.com <creis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 21:19:31 +0000 |
commit | 75e16bcd60ff7e60a375bbe0efd27f8ac919a756 (patch) | |
tree | 6a3aca93dc9e64ad58f1cef258bf3e9dc896af92 /chrome/common/extensions/docs/examples/api/processes | |
parent | eefb9b4e064b484a1490abbaddeb92dffbc5e1ff (diff) | |
download | chromium_src-75e16bcd60ff7e60a375bbe0efd27f8ac919a756.zip chromium_src-75e16bcd60ff7e60a375bbe0efd27f8ac919a756.tar.gz chromium_src-75e16bcd60ff7e60a375bbe0efd27f8ac919a756.tar.bz2 |
Expands the chrome.experimental.processes extension API.
Adds an onUpdated event that reports process metrics from the TaskManager,
and modifies the TaskManager to support multiple independent observers.
BUG=32302
TEST=ExtensionApiTest.Processes browsertest
TEST=process_monitor sample extension
Review URL: http://codereview.chromium.org/3597016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62458 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/examples/api/processes')
3 files changed, 83 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/examples/api/processes/process_monitor/icon.png b/chrome/common/extensions/docs/examples/api/processes/process_monitor/icon.png Binary files differnew file mode 100644 index 0000000..9a79a46 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/processes/process_monitor/icon.png diff --git a/chrome/common/extensions/docs/examples/api/processes/process_monitor/manifest.json b/chrome/common/extensions/docs/examples/api/processes/process_monitor/manifest.json new file mode 100644 index 0000000..ae633d3 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/processes/process_monitor/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "Process Monitor", + "version": "1.0", + "description": "Adds a browser action that monitors resource usage of all browser processes.", + "permissions": [ + "experimental", "tabs" + ], + "browser_action": { + "default_title": "Process Monitor", + "default_icon": "icon.png", + "popup": "popup.html" + } +} diff --git a/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.html b/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.html new file mode 100644 index 0000000..61e736b --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.html @@ -0,0 +1,70 @@ +<html> +<head> +<script> + // Shows an updating list of process statistics. + function init() { + chrome.experimental.processes.onUpdated.addListener(function(processes) { + var table = "<table>\n" + + "<tr><td><b>Process</b></td>" + + "<td>Type</td>" + + "<td>CPU</td>" + + "<td>Network</td>" + + "<td>Shared Memory</td>" + + "<td>Private Memory</td>" + + "</tr>\n"; + for (pid in processes) { + table = displayProcessInfo(processes[pid], table); + } + table += "</table>\n"; + var div = document.getElementById("process-list"); + div.innerHTML = table; + }); + } + + function displayProcessInfo(process, table) { + // Format network string like task manager + var network = process.network; + if (network > 1024) { + network = (network / 1024).toFixed(1) + " kB/s"; + } else if (network > 0) { + network += " B/s"; + } else if (network == -1) { + network = "N/A"; + } + + table += + "<tr><td>" + process.id + "</td>" + + "<td>" + process.type + "</td>" + + "<td>" + process.cpu + "</td>" + + "<td>" + network + "</td>" + + "<td>" + (process.sharedMemory / 1024) + "K</td>" + + "<td>" + (process.privateMemory / 1024) + "K</td>" + + "</tr>\n"; + return table; + } +</script> +<style> +body { + overflow: hidden; + margin: 0px; + padding: 0px; + background: white; +} + +div:first-child { + margin-top: 0px; +} + +div, td { + padding: 1px 3px; + font-family: sans-serif; + font-size: 10pt; + margin-top: 1px; +} +</style> +</head> +<body onload="init()"> +<div id="title"><b>Process Monitor</b></div> +<div id="process-list"><i>Loading...</i></div> +</body> +</html> |