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

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

Issue 9289057: Changing manifest to v2 extension samples (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding zip files after rebasing with master Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Shows an updating list of process statistics.
6 function init() {
7 chrome.experimental.processes.onUpdated.addListener(function(processes) {
8 var table = "<table>\n" +
9 "<tr><td><b>Process</b></td>" +
10 "<td>Type</td>" +
11 "<td>CPU</td>" +
12 "<td>Network</td>" +
13 "<td>Shared Memory</td>" +
14 "<td>Private Memory</td>" +
15 "</tr>\n";
16 for (pid in processes) {
17 table = displayProcessInfo(processes[pid], table);
18 }
19 table += "</table>\n";
20 var div = document.getElementById("process-list");
21 div.innerHTML = table;
22 });
23 }
24
25 function displayProcessInfo(process, table) {
26 // Format network string like task manager
27 var network = process.network;
28 if (network > 1024) {
29 network = (network / 1024).toFixed(1) + " kB/s";
30 } else if (network > 0) {
31 network += " B/s";
32 } else if (network == -1) {
33 network = "N/A";
34 }
35
36 table +=
37 "<tr><td>" + process.id + "</td>" +
38 "<td>" + process.type + "</td>" +
39 "<td>" + process.cpu + "</td>" +
40 "<td>" + network + "</td>" +
41 "<td>" + (process.sharedMemory / 1024) + "K</td>" +
42 "<td>" + (process.privateMemory / 1024) + "K</td>" +
43 "</tr>\n";
44 return table;
45 }
46
47 document.addEventListener('DOMContentLoaded', init);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698