Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/common/extensions/docs/examples/api/processes/process_monitor/popup.js

Issue 22584002: Move processes API to dev channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased again Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Shows an updating list of process statistics. 5 // Shows an updating list of process statistics.
6 function init() { 6 function init() {
7 chrome.experimental.processes.onUpdatedWithMemory.addListener( 7 chrome.processes.onUpdatedWithMemory.addListener(
8 function(processes) { 8 function(processes) {
9 var table = "<table>\n" + 9 var table = "<table>\n" +
10 "<tr><td><b>Process</b></td>" + 10 "<tr><td><b>Process</b></td>" +
11 "<td>OS ID</td>" + 11 "<td>OS ID</td>" +
12 "<td>Type</td>" + 12 "<td>Type</td>" +
13 "<td>Tabs</td>" + 13 "<td>Tabs</td>" +
14 "<td>CPU</td>" + 14 "<td>CPU</td>" +
15 "<td>Network</td>" + 15 "<td>Network</td>" +
16 "<td>Private Memory</td>" + 16 "<td>Private Memory</td>" +
17 "<td>FPS</td>" + 17 "<td>FPS</td>" +
18 "<td>JS Memory</td>" + 18 "<td>JS Memory</td>" +
19 "<td></td>" + 19 "<td></td>" +
20 "</tr>\n"; 20 "</tr>\n";
21 for (pid in processes) { 21 for (pid in processes) {
22 table = displayProcessInfo(processes[pid], table); 22 table = displayProcessInfo(processes[pid], table);
23 } 23 }
24 table += "</table>\n"; 24 table += "</table>\n";
25 var div = document.getElementById("process-list"); 25 var div = document.getElementById("process-list");
26 div.innerHTML = table; 26 div.innerHTML = table;
27 }); 27 });
28 28
29 document.getElementById("killProcess").onclick = function () { 29 document.getElementById("killProcess").onclick = function () {
30 var procId = parseInt(prompt("Enter process ID")); 30 var procId = parseInt(prompt("Enter process ID"));
31 chrome.experimental.processes.terminate(procId); 31 chrome.processes.terminate(procId);
32 } 32 }
33 } 33 }
34 34
35 function displayProcessInfo(process, table) { 35 function displayProcessInfo(process, table) {
36 // Format network string like task manager 36 // Format network string like task manager
37 var network = process.network; 37 var network = process.network;
38 if (network > 1024) { 38 if (network > 1024) {
39 network = (network / 1024).toFixed(1) + " kB/s"; 39 network = (network / 1024).toFixed(1) + " kB/s";
40 } else if (network > 0) { 40 } else if (network > 0) {
41 network += " B/s"; 41 network += " B/s";
(...skipping 28 matching lines...) Expand all
70 } else { 70 } else {
71 table += "<td>N/A</td>"; 71 table += "<td>N/A</td>";
72 } 72 }
73 73
74 table += 74 table +=
75 "<td></td>" + 75 "<td></td>" +
76 "</tr>\n"; 76 "</tr>\n";
77 return table; 77 return table;
78 } 78 }
79 79
80 document.addEventListener('DOMContentLoaded', init); 80 document.addEventListener('DOMContentLoaded', init);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698