Index: chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.js |
diff --git a/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.js b/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.js |
index 2582f06c1b78bc7d023694f87bb8809b52587206..b0ee28817c00ca629769d6728091d0329880ea34 100644 |
--- a/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.js |
+++ b/chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.js |
@@ -4,22 +4,32 @@ |
// 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; |
- }); |
+ chrome.experimental.processes.onUpdatedWithMemory.addListener( |
+ function(processes) { |
+ var table = "<table>\n" + |
+ "<tr><td><b>Process</b></td>" + |
+ "<td>OS ID</td>" + |
+ "<td>Type</td>" + |
+ "<td>Tabs</td>" + |
+ "<td>CPU</td>" + |
+ "<td>Network</td>" + |
+ "<td>Private Memory</td>" + |
+ "<td>FPS</td>" + |
+ "<td>JS Memory</td>" + |
+ "<td></td>" + |
+ "</tr>\n"; |
+ for (pid in processes) { |
+ table = displayProcessInfo(processes[pid], table); |
+ } |
+ table += "</table>\n"; |
+ var div = document.getElementById("process-list"); |
+ div.innerHTML = table; |
+ }); |
+ |
+ document.getElementById("killProcess").onclick = function () { |
+ var procId = parseInt(prompt("Enter process ID")); |
+ chrome.experimental.processes.terminate(procId); |
+ } |
} |
function displayProcessInfo(process, table) { |
@@ -35,11 +45,34 @@ function displayProcessInfo(process, table) { |
table += |
"<tr><td>" + process.id + "</td>" + |
+ "<td>" + process.osProcessId + "</td>" + |
"<td>" + process.type + "</td>" + |
+ "<td>" + process.tabs + "</td>" + |
"<td>" + process.cpu + "</td>" + |
- "<td>" + network + "</td>" + |
- "<td>" + (process.sharedMemory / 1024) + "K</td>" + |
- "<td>" + (process.privateMemory / 1024) + "K</td>" + |
+ "<td>" + network + "</td>"; |
+ |
+ if ("privateMemory" in process) { |
+ table += "<td>" + (process.privateMemory / 1024) + "K</td>"; |
+ } else { |
+ table += "<td>N/A</td>"; |
+ } |
+ if ("fps" in process) { |
+ table += "<td>" + process.fps.toFixed(2) + "</td>"; |
+ } else { |
+ table += "<td>N/A</td>"; |
+ } |
+ |
+ if ("jsMemoryAllocated" in process) { |
+ var allocated = process.jsMemoryAllocated / 1024; |
+ var used = process.jsMemoryUsed / 1024; |
+ table += "<td>" + allocated.toFixed(2) + "K (" + used.toFixed(2) + |
+ "K live)</td>"; |
+ } else { |
+ table += "<td>N/A</td>"; |
+ } |
+ |
+ table += |
+ "<td></td>" + |
"</tr>\n"; |
return table; |
} |