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

Side by Side Diff: trunk/src/chrome/browser/resources/gcm_internals.js

Issue 240583002: Revert 264313 "Add activity recording capability to gcm internal..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 cr.define('gcmInternals', function() { 5 cr.define('gcmInternals', function() {
6 'use strict'; 6 'use strict';
7 7
8 var isRecording = false;
9
10 /** 8 /**
11 * If the info dictionary has property prop, then set the text content of 9 * If the info dictionary has property prop, then set the text content of
12 * element to the value of this property. Otherwise clear the content. 10 * element to the value of this property.
13 * @param {!Object} info A dictionary of device infos to be displayed. 11 * @param {!Object} info A dictionary of device infos to be displayed.
14 * @param {string} prop Name of the property. 12 * @param {string} prop Name of the property.
15 * @param {string} element The id of a HTML element. 13 * @param {string} element The id of a HTML element.
16 */ 14 */
17 function setIfExists(info, prop, element) { 15 function setIfExists(info, prop, element) {
18 if (info[prop] !== undefined) { 16 if (info[prop] !== undefined) {
19 $(element).textContent = info[prop]; 17 $(element).textContent = info[prop];
20 } else {
21 $(element).textContent = '';
22 } 18 }
23 } 19 }
24 20
25 /** 21 /**
26 * Display device informations. 22 * Display device informations.
27 * @param {!Object} info A dictionary of device infos to be displayed. 23 * @param {!Object} info A dictionary of device infos to be displayed.
28 */ 24 */
29 function displayDeviceInfo(info) { 25 function displayDeviceInfo(info) {
30 setIfExists(info, 'androidId', 'android-id'); 26 setIfExists(info, 'androidId', 'android-id');
31 setIfExists(info, 'profileServiceCreated', 'profile-service-created'); 27 setIfExists(info, 'profileServiceCreated', 'profile-service-created');
32 setIfExists(info, 'gcmEnabledState', 'gcm-enabled-state'); 28 setIfExists(info, 'gcmEnabledState', 'gcm-enabled-state');
33 setIfExists(info, 'signedInUserName', 'signed-in-username'); 29 setIfExists(info, 'signedInUserName', 'signed-in-username');
34 setIfExists(info, 'gcmClientCreated', 'gcm-client-created'); 30 setIfExists(info, 'gcmClientCreated', 'gcm-client-created');
35 setIfExists(info, 'gcmClientState', 'gcm-client-state'); 31 setIfExists(info, 'gcmClientState', 'gcm-client-state');
36 setIfExists(info, 'gcmClientReady', 'gcm-client-ready'); 32 setIfExists(info, 'gcmClientReady', 'gcm-client-ready');
37 setIfExists(info, 'connectionClientCreated', 'connection-client-created'); 33 setIfExists(info, 'connectionClientCreated', 'connection-client-created');
38 setIfExists(info, 'connectionState', 'connection-state'); 34 setIfExists(info, 'connectionState', 'connection-state');
39 setIfExists(info, 'registeredAppIds', 'registered-app-ids'); 35 }
40 setIfExists(info, 'sendQueueSize', 'send-queue-size'); 36
41 setIfExists(info, 'resendQueueSize', 'resend-queue-size'); 37 function initialize() {
38 chrome.send('getGcmInternalsInfo');
42 } 39 }
43 40
44 /** 41 /**
45 * Remove all the child nodes of the element.
46 * @param {HTMLElement} element A HTML element.
47 */
48 function removeAllChildNodes(element) {
49 element.textContent = '';
50 }
51
52 /**
53 * For each item in line, add a row to the table. Each item is actually a list
54 * of sub-items; each of which will have a corresponding cell created in that
55 * row, and the sub-item will be displayed in the cell.
56 * @param {HTMLElement} table A HTML tbody element.
57 * @param {!Object} list A list of list of item.
58 */
59 function addRows(table, list) {
60 for (var i = 0; i < list.length; ++i) {
61 var row = document.createElement('tr');
62
63 // The first element is always a timestamp.
64 var cell = document.createElement('td');
65 var d = new Date(list[i][0]);
66 cell.textContent = d;
67 row.appendChild(cell);
68
69 for (var j = 1; j < list[i].length; ++j) {
70 var cell = document.createElement('td');
71 cell.textContent = list[i][j];
72 row.appendChild(cell);
73 }
74 table.appendChild(row);
75 }
76 }
77
78 /**
79 * Refresh all displayed information.
80 */
81 function refreshAll() {
82 chrome.send('getGcmInternalsInfo', [false]);
83 }
84
85 /**
86 * Toggle the isRecording variable and send it to browser.
87 */
88 function setRecording() {
89 isRecording = !isRecording;
90 chrome.send('setGcmInternalsRecording', [isRecording]);
91 }
92
93 /**
94 * Clear all the activity logs.
95 */
96 function clearLogs() {
97 chrome.send('getGcmInternalsInfo', [true]);
98 }
99
100 function initialize() {
101 $('recording').disabled = true;
102 $('refresh').onclick = refreshAll;
103 $('recording').onclick = setRecording;
104 $('clear-logs').onclick = clearLogs;
105 chrome.send('getGcmInternalsInfo', [false]);
106 }
107
108 /**
109 * Callback function accepting a dictionary of info items to be displayed. 42 * Callback function accepting a dictionary of info items to be displayed.
110 * @param {!Object} infos A dictionary of info items to be displayed. 43 * @param {!Object} infos A dictionary of info items to be displayed.
111 */ 44 */
112 function setGcmInternalsInfo(infos) { 45 function setGcmInternalsInfo(infos) {
113 isRecording = infos.isRecording;
114 if (isRecording)
115 $('recording').textContent = 'Stop Recording';
116 else
117 $('recording').textContent = 'Start Recording';
118 $('recording').disabled = false;
119 if (infos.deviceInfo !== undefined) { 46 if (infos.deviceInfo !== undefined) {
120 displayDeviceInfo(infos.deviceInfo); 47 displayDeviceInfo(infos.deviceInfo);
121 } 48 }
122
123 removeAllChildNodes($('send-info'));
124 if (infos.sendInfo !== undefined) {
125 addRows($('send-info'), infos.sendInfo);
126 }
127 } 49 }
128 50
129 // Return an object with all of the exports. 51 // Return an object with all of the exports.
130 return { 52 return {
131 initialize: initialize, 53 initialize: initialize,
132 setGcmInternalsInfo: setGcmInternalsInfo, 54 setGcmInternalsInfo: setGcmInternalsInfo,
133 }; 55 };
134 }); 56 });
135 57
136 document.addEventListener('DOMContentLoaded', gcmInternals.initialize); 58 document.addEventListener('DOMContentLoaded', gcmInternals.initialize);
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/resources/gcm_internals.html ('k') | trunk/src/chrome/browser/services/gcm/gcm_client_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698